Localization (l10n)

Most web apps at Mozilla are localized. We make use of gettext.

See also Localization (L10n) in Playdoh docs

SVN

By convention Mozilla puts locales in locale/ and that folder is a working copy from SVN. This allows localizers to use tools like Verbatim to add new localized content.

You can create an empty subdirectory off of https://svn.mozilla.org/projects/l10n-misc/trunk/ to store your .po files:

svn mkdir \
    https://svn.mozilla.org/projects/l10n-misc/trunk/$MYPROJECTNAME \
    -m "Creating $MYPROJECTNAME"

Where $MYPROJECTNAME is the name of your project.

You’ll also want to add *.mo to the list of global-ignores in your ~/.subversion/config file. .mo files can be compiled at deploy time.

Warning

.mo files are compiled and therefore have no place in version control.

Now in your project root:

svn co https://svn.mozilla.org/projects/l10n-misc/trunk/$MYPROJECTNAME \
locale

Anytime you make changes using the merge or extract commands you’ll need to commit them back to SVN:

cd locale/
svn add *
svn commit -m 'Locale update'

See Localization (L10n) in Playdoh docs for more info on the merge and extract commands

Adding new locales (non-django)

Note

See Localization (L10n) in Playdoh for django instructions

To add a new locale to an existing project, go to the Verbatim project admin page, e.g., https://localize.mozilla.org/projects/mdn/admin.html

Use the dropdown at the bottom of the list of locales to add the new locale to verbatim

ssh to the verbatim box and add the new locale to svn:

ssh sm-verbatim01
cd /var/lib/pootle/po/<project>
svn add <locale>
svn ci <locale> -m "Adding <locale>"

Warning

Only commit the new locale directory and do not update the svn working copy.

Adding a new text domain (non-django)

Note

These instructions are only for localizing text outside of django/playdoh projects. See Localization (L10n) in Playdoh for django instructions

Sometimes in a single project you need to use more than one translatable module. A text domain is a handle for each module with different .po files. For example, MDN uses separate text domains for the MDN website and the Promote MDN WordPress plugin.

You can still use Verbatim to translate these other text domains alongside the primary domain.

Generate your .pot file, and then generate a .po file for each locale e.g.,:

msginit --no-translator -l <locale> -i templates/LC_MESSAGES/promote-mdn.pot \
-o <locale>/LC_MESSAGES/promote-mdn.po

Add the .pot file and the .po files to svn e.g.,:

svn add */LC_MESSAGES/promote-mdn.*
svn commit */LC_MESSAGES/promote-mdn.*

Now go to each locale’s project directory and click the “Update all from version control” button.

Make this better

This process is merely a suggestion. If you think localization can be improved or perhaps automated, by all means... DO IT! If your improvement takes off update this, so others can benefit.