Adding Additional Locales in Craft 2

Craft ships with locale data for just over 100 locales, which is only a small subset of the 774 locales supported by Yii. If you need to add support for one of the locales Craft has omitted, just follow these steps:

  1. Click on the locale’s filename in Yii’s GitHub repo.
  2. Click Raw in the toolbar above the file contents.
  3. Save the file within your craft/app/framework/i18n/data/ folder, using the same filename as the one it had in the repo.
  4. In Craft’s control panel, go to SettingsLocales, and search for your new locale. It will appear in the results list just like all the others.

If you perform steps 1-3 before installing Craft, the locale will be available from the “Locale” dropdown menu in Craft’s installation wizard.

Creating custom locales #

If you need a locale that isn’t supported by Yii, you can create a new one manually by following these steps:

  1. Go to craft/app/framework/i18n/data/ and find the locale file that has the closest language and country code match to your custom locale. For example, if visitors to this locale are going to be speaking U.S. English, look for en_us.php.
  2. Duplicate that file, and append a custom suffix to the file (e.g. en_us_foobar.php).
  3. Open up each of the locale files that your site will be using (including the one you just created) and search for 'languages'. In the array that follows it, add a new entry that defines the user-facing name of your new custom locale. For example:
    'languages' => array (
        'en_us_foobar' => 'Foobar',
        // ...
    )
    
  4. In Craft’s control panel, go to SettingsLocales and search for your new custom locale. It will appear in the results list just like all the others.

It’s possible (but unlikely) that future Craft 2 auto-updates updates will overwrite the Yii locale data files you edited, so keep an eye on any changes to your craft/app/framework/i18n/data/ folder to ensure your custom locale keys don’t get reverted. If you do a manual update, then they will definitely be overwritten.

Applies to Craft CMS 2.