Skip to content

Adding a translation

Hans Fredrik Nordhaug edited this page Dec 19, 2013 · 8 revisions

Creating a Bolt translation

If you want to provide a translation for the Bolt backend in your language, your help will be greatly appreciated. To make a translation, do the the following:

Step 1: Install Bolt

Install Bolt as normal, see instructions, and get it running. Any database-type is OK, so choose whatever's most convenient.

Step 2: Select language for backend

Edit config.yml, set the locale to the language you wish to add:

# The locale that'll be used by the application. If no locale is set the
# fallback locale is 'en_GB'. For available options, see: docs.bolt.cm/locales
locale: pt_BR

Obviously, replace the pt_BR with the language/locale you wish to add. If necessary, check the list of common locales.

Now, when you go to the backend as a 'developer' user, you'll see three new options under 'Settings':

shot1

Step 3: Creating the files

If you click one of these options, you'll most likely get a notice like this:

shot2

Either create this file and make it writable, or just create the folder and (temporarily) make it writable. Now, click all three links, and make sure all three are initialised by clicking the 'save' button at the bottom.

You should now have three files, like this:

[15:48:39] bob@macmini:bolt $ dir app/resources/translations/pt/
total 40
 0 drwxrwxrwx  5 bob  staff   170 Mar 19 15:48 .
 0 drwxr-xr-x  6 bob  staff   204 Mar 19 15:39 ..
 8 -rw-r--r--  1 bob  staff  2484 Mar 19 15:42 contenttypes.pt.yml
16 -rw-r--r--  1 bob  staff  5421 Mar 19 15:48 infos.pt.yml
16 -rw-r--r--  1 bob  staff  7443 Mar 19 15:43 messages.pt.yml
[15:48:55] bob@macmini:bolt $ 

Step 3a: Translating the files

Now the real work can start: translating the files. You can edit the labels in the Bolt interface, but be aware that since these are .yml files, things will break if you 'save' a non-valid file. This means that if you've added a lot of labels and you've 'broken' the yml, that your changes are lost when you click 'save'.

What we suggest is this: Edit the files in a standard editor to do the bulk of the work. Save often, check the Bolt backend to see your work in progress. You can use the interface in Bolt to fine-tune your results.

Step 3b: Translating the files efficiently

Translating the files in the Bolt interface is very inefficient since there is no built-in translation support, like is common in translation tools like Virtaal or Poedit. Unfortunately these tools don't support '.yml' files. However, '.po' files are very well supported and you can convert between Bolt's '.yml' files and standard '.po' files using the PHP script yaml2po.

The workflow becomes:

  1. Convert the '.yml' file you want to translate to a '.po' file:
php yaml2po.php messages.pt.yml messages.pt.po
  1. Translate the '.po' file in your preferred translation tool. We recommend Virtaal.
  2. Convert the now (partly) translated '.po' file to a '.yml' file (overwriting the existing '.yml' file):
php yaml2po.php -r messages.pt.yml messages.pt.po
  1. In the Bolt interface, open the translation and check the status. Save it, if you want Bolt to insert it's statistics into the '.yml' file.

Step 4: Submitting your results

When you're done, you can either do a fork/pull-request, or just email us the new files at info [@] bolt.cm. Whatever's most convenient for you.

Thank you for helping us improve! :-)

Clone this wiki locally