Adding Additional Locales
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:
- Click on the locale’s filename in Yii’s GitHub repo.
- Click the “Raw” button in the toolbar above the file contents.
- Save the file within your craft/app/framework/i18n/data/ folder, using the same filename as the one it had in the repo.
- In Craft’s Control Panel, go to Settings → Locales, 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:
- 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
- Duplicate that file, and append a custom suffix to the file (e.g.
- 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', // ...
- In Craft’s Control Panel, go to Settings → Locales, 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.