Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Language Association in FLEXIContent – zh-TW tag not mapping to /tw/ URL #1176

Open
iamrobert opened this issue Jan 7, 2024 · 2 comments

Comments

@iamrobert
Copy link
Contributor

iamrobert commented Jan 7, 2024

Hi,

I am experiencing an issue with language association in Joomla using FLEXIContent. Specifically, the zh-TW language tag does not map correctly to the desired URL language code /tw/. Instead, it defaults to zh. This issue persists

With the latest language file - doesn't allow me to switch URLs.

The URLs for both en-GB and zh-TW are identical in SEF mode. In non-SEF mode, the URL for zh-TW incorrectly includes &lang=en instead of &lang=tw.

Example:
index.php?option=com_flexicontent&view=item&cid=37&id=193&Itemid=1233&lang=en

The URL should be:
index.php?option=com_flexicontent&view=item&cid=37&id=193&Itemid=1233&lang=tw

OLDER VERSION
Reverting to an earlier version of the association helper partially resolves the issue; the URL works with /zh/ but not with /tw/.

Suspected Cause:
It appears that the line $lang_code = substr($tag, 0, 2) is extracting zh as the language code for zh-TW. The following array output showing the language associations:

// Debug: Print the entire associations array
echo "<pre>"; print_r($associations); echo "</pre>";
die;

(
    [en-GB] => stdClass Object
        (
            [language] => en-GB
            [type_id] => 1
            [id] => 178
            [catid] => 33
            [title_slug] => 178:Facilities
            [cat_slug] => 33:facilities
        )

    [zh-TW] => stdClass Object
        (
            [language] => zh-TW
            [type_id] => 1
            [id] => 201
            [catid] => 39
            [title_slug] => 201:facilities
            [cat_slug] => 39:facilities
        )

)

Temporary Solution:
Implementing the following condition resolves the issue but is not ideal:

if ($tag == 'zh-TW') {
    $lang_code = 'tw';
} else {
    $lang_code = substr($tag, 0, 2);
}

Any help or assistance would be wonderful.

@desbear
Copy link

desbear commented Jan 10, 2024

When I used the universal module before, Flexicontent always get zh-CN items also when I needed to retrieve only zh-TW.

@ggppdk
Copy link
Member

ggppdk commented Feb 21, 2024

we need to use something like:

$site_languages = FLEXIUtilities::getLanguages();
$lang_code = $site_languages->{$tag}->sef;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants