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

Problem with pattern and locale long code like 'en_US' or 'fr_FR #9

Open
weierophinney opened this issue Dec 31, 2019 · 0 comments
Open

Comments

@weierophinney
Copy link
Member

I see that this package only provides translation for locale short codes like fr or en. It is a problem when you want to translate framework messages with a locale detected as fr_FR or en_US and using the pattern method.

Why not providing those messages in folder names using the long code format ?

Anyway, I managed to get this working by adding this peace of code in my translator delegator factory:

    $languageMap = array(
        'fr' => array(
            'fr_BE',
            'fr_CA',
            'fr_CH',
            'fr_FR',
            'fr_LU',
            'fr_MC'
        ),
        'en' => array(
            'en_029',
            'en_AU',
            'en_BZ',
            'en_CA',
            'en_GB',
            'en_IE',
            'en_IN',
            'en_JM',
            'en_MY',
            'en_NZ',
            'en_PH',
            'en_SG',
            'en_TT',
            'en_US',
            'en_ZA',
            'en_ZW',
        )
    );
    foreach($languageMap as $shortCode => $shortCodeMap) {
        foreach($shortCodeMap as $longCode) {
            // Insère les traductions du framework dans le translator pour les validators et le Captcha
            $i18ntrans->addTranslationFile('phpArray', Resources::getBasePath() . '/' . $shortCode . '/Zend_Validate.php', 'default', $longCode);
            $i18ntrans->addTranslationFile('phpArray', Resources::getBasePath() . '/' . $shortCode . '/Zend_Captcha.php', 'default', $longCode);
        }
    }

Originally posted by @berturion at zendframework/zend-i18n#6

@froschdesign froschdesign transferred this issue from laminas/laminas-i18n Feb 12, 2020
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

1 participant