Custom locales (for instance en_SE, en_NO etc)

#1

Hi!

We’ve developed a multilingual site using Pimcore5, and it’s been a pleasant experience overall. But now we need to add english versions for each country of the site (the site is available in the Scandinavian countries), so apart from sv_SE, nb_NO, fi_FI and da_DK, we would need en_SE, en_NO, en_FI and en_DK. Yep, per country, not one english version of the site, but four.

Those however are not existing locales. Any suggestions on how to set this up? :slight_smile:

Thanks,
Stefan

0 Likes

#2

Hi, you could try following:

Add a custom locale implementation

namespace AppBundle\Pimcore\Localization;

class Locale extends \Pimcore\Localization\Locale
{
    public function getLocaleList()
    {
        $locales = parent::getLocaleList();
        $locales[] = 'en_SE';
        $locales[] = 'en_NO';

        return $locales;
    }
}

And overwrite the default Pimcore locale service with your custom implementation:

services:

    Pimcore\Localization\Locale:
        class: AppBundle\Pimcore\Localization\Locale
        arguments:
            $translator: '@Pimcore\Translation\Translator'

BR
Christian

0 Likes

#3

Thanks, I will have a look at this! I also tried just adding them in system.xml and that seems to work too, I even get correct language and region when using Locale::getDisplayRegion() etc.

0 Likes