Locale Development

It's easy to make your own locale/translation for Opal. Here's how you do it:

Create a Translation File

Locale translation files are stored in several places:

  • config/locales - core translation files
  • config/locales/seeds - new installations
  • config/locales/samples - sample installation data
  • vendor/locales - translations used by gems and other 3rd party code

You should start by making a copy of existing locale files, such as config/locales/en.yml. This way you can see all of the different fields and labels that you need to change to make a complete translation for Opal. Be sure to rename the file to the locale you'll be using, eg: ru.yml for Russian.

  • The name of your translation should be IETF language tag compatible. This means if you want to make an english translation for people in Great Britain, your translation name would be en-GB. If you need help finding out what you should name your file, here's a list of example translation files.

You'll also need to change the locale key in your translation files, which is at the top of the file. For example, if you copied your translation file from the en translation file, you'd change...

en:

...to...

ru:
  • Important Note: Any translation file in config/locales is automatically found by Opal and is added to the drop-down menu that's seen in any place you can change locale.

Get to Work!

Now it's time for the time-consuming part. Open up the file, and translate it line by line using your awesome multilingual skills.

Important Notes

YAML

Localization files are written in YAML, which is a markup language(similar to XML, etc.). YAML is usually pretty human-readable, but if you see some strange symbols that look different than regular text, leave them be. Here's an example of a YAML interpolation variable:

item_save_success: This %{item} has been saved!

The YAML variable, %{item} needs to stay there! So if I'm writing a Spanish translation, the same line would look like this:

item_save_success: este %{item} se ha salvado!

Pluralization

Opal supports special pluralization cases, in case your language/locale has more than just a singular and plural state for a noun.
To add special pluralization cases for your locale, define them in config/locales/pluralize.rb.
You can read more about this here:

Submit It

If you've added a translation to Opal, send it to us and we'll add it to Opal's core!

There's a number of ways you can submit changes to us:

Resources

If you need any help, check out these resources: