Translating NorfelloCMMS
This article explains how you can translate NorfelloCMMS OS to your language. We will go through the translation process step by step.
Install NorfelloCMMS OS
First you have to install NorfelloCMMS OS to your system. Follow the documentation under Installing and configuring NorfelloCMMS OS. You can either install a stable release or the latest development version. For translating we recommend you to install the latest development version from the Subversion repository - This way your translations will be more complete for the next NorfelloCMMS release.
Translation basics
NorfelloCMMS uses Gettext for translations. Translations are written to human-readable text files called po-files. The po-files will be processed with Gettext to make mo-files which NorfelloCMMS uses to translate itself.
Making translations for a new language
Setting up a new translation language
Go to the directory where you installed NorfelloCMMS OS. If you followed the instructions precisely you can do this with the command:
cd /opt/norfello_cmms # or on Windows: cd C:\norfello_cmms
or you can use a graphical file browser to do the same. The translations are located in the po-directory where will go next:
cd po ls -F # or on Windows: cd po dir
Each sub-directory corresponds to a language. For example the fi_FI directory contains translations for the Finnish language (fi) as it's spoken in Finland (FI).
Suppose you want to translate NorfelloCMMS to the Swedish language. So we create a directory for the language: Swedish (sv) as it's spoken in Sweden (SV)
mkdir sv_SV
You can find the official language code for your language from this page. You can take the Finnish po-files as a starting point by copying them to your new directory:
cp fi_FI/*.po sv_SV # or on Windows: copy C:\norfello_cmms\fi_FI\*.po C:\norfello_cmms\sv_SV
(If you want a fresh norfello_cmms.po file instead of the Finnish one you can take a copy from the norfello_cmms.pot file found from the po-direcory.) Now you should have the po-files norfello_cmms.po and rails.po in your new directory
Translating
Settings
Now you are ready to start translating! The po-files are plain text, so you can edit them by using any text editor which supports UTF-8 encoding. However, there are graphical programs desingned for editing po-files. Especially a program called poedit is very good and it runs on many operating systems (Linux, Windows, Mac OS X).
Open the norfello_cmms.po file in the sv_SV directory. First you have to configure the po-file for your language. If you are using poedit, you can do this by choosing Catalog -> Settings. With a text editor the beginning of the po-file looks like:
msgid "" msgstr "" "Project-Id-Version: NorfelloCMMS SVN trunk\n" "POT-Creation-Date: 2007-11-12 14:24+0200\n" "PO-Revision-Date: 2007-11-08 13:17+0200\n" "Last-Translator: Markku Oksanen <markku.oksanen@norfello.com>\n" "Language-Team: Norfello Ltd. <contact@norfello.com>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: Finnish\n" "X-Poedit-Country: FINLAND\n" "Plural-Forms: nplurals=2; plural=n != 1;\n"
First fill in your name and email in the Last-Translator field. The last three settings (language, country and plural forms) are very important. The first two are longer forms from the directory name, i.e. sv_SV in this case. The Plural-Forms setting defines when plurals are used in your language. In this case we don't have to edit it because Swedish has the same plural form as Finnish (and English and many others). You can find out your plural form from the Gettext manual - nplurals= is the number of plural forms and plural= defines when each plural form is used. Our final settings look like:
msgid "" msgstr "" "Project-Id-Version: NorfelloCMMS SVN trunk\n" "POT-Creation-Date: 2007-11-12 14:24+0200\n" "PO-Revision-Date: 2007-11-08 13:17+0200\n" "Last-Translator: Your Name <your.name@example.com>\n" "Language-Team: Norfello Ltd. <contact@norfello.com>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: Swedish\n" "X-Poedit-Country: SWEDEN\n" "Plural-Forms: nplurals=2; plural=n != 1;\n"
Translating messages
Finally you can start to translate the messages. Lets take few examples:
Plain text message
#: app/helpers/customer_interface_helper.rb:96 #: app/helpers/application_helper.rb:451 msgid "Task" msgstr "Tehtävä"
The lines starting with a # are comments which you can ignore. The msgid is the original message and msgstr is the (Finnish) translation. We edit the translated message to a Swedish one:
#: app/helpers/customer_interface_helper.rb:96 #: app/helpers/application_helper.rb:451 msgid "Task" msgstr "Uppgift"
and move on to next message.
Message with text formatting %s
When a message contains a '%s' it means that a character string will be substituted in its place before the message is shown. In general your translation should have a '%s' placeholder if the original message has one. Example:
#: app/helpers/customer_interface_helper.rb:143 #: app/views/timeline/_display_event.rhtml:39 msgid "Modified by %s" msgstr "Muokattu käyttäjän %s toimesta"
The Swedish translation is:
#: app/helpers/customer_interface_helper.rb:143 #: app/views/timeline/_display_event.rhtml:39 msgid "Modified by %s" msgstr "Modifierad av %s"
Message with numeral formatting %d, %i, %f
When a message contains '%d', '%i' or '%f' it means that a number will be substituted in its place. '%d' and '%i' will be replaced by decimal numbers (integers) and %f by a floating point number. All formatting placeholders can have numeral parameters between '%' and the letter 's', 'd', 'i' or 'f' - especially '%f' often looks like for example '%5.2f' - but you don't have to care about these. Example:
#: app/models/action_key.rb:28 msgid "%d key" msgid_plural "%d keys" msgstr[0] "%d avain" msgstr[1] "%d avainta"
The Swedish translation is:
#: app/models/action_key.rb:28 msgid "%d key" msgid_plural "%d keys" msgstr[0] "%d nyckel" msgstr[1] "%d nycklar"
When the numeral argument is 1 we have the singular translation "1 nyckel" and when the argument N is not 1 we the plural translation "N nycklar".
rails.po
Also the rails.po file containing translations for Ruby on Rails has to be translated. Someone may already have translated this file for your language, so search the web before translating it yourself. If you aren't lucky repeate the translation process for the file.
Processing translations
Before the translations can be used you have process them with Gettext. Go to the installation directory and give the command:
rake makemo
Update language options
Stable release 2.0 and the development version
Now you have translated NorfelloCMMS OS but you can't choose the new language for your users yet. In the config sub-directory find the file language_options.rb and open it with your text editor. The file looks like this:
# Supported language options CMMS_LANGUAGE_OPTIONS.push(['Suomi', 'fi_FI']) CMMS_LANGUAGE_OPTIONS.push(['English', 'en'])
Add your new language to the available options. We add the Swedish language to the options as the first option like this:
# Supported language options CMMS_LANGUAGE_OPTIONS.push(['Svenska', 'sv_SV']) CMMS_LANGUAGE_OPTIONS.push(['Suomi', 'fi_FI']) CMMS_LANGUAGE_OPTIONS.push(['English', 'en'])
Stable release 1.0.1 and prior versions
If you are using the stable release 1.0.1 or any version older than it, the file language_options.rb doesn't exist. Instead you have to open the file app/controllers/user_controllor.rb and find the line
@language_options = [['Suomi', 'fi_FI'], ['English', 'en']]
and add the new language option to it. We add the Swedish language to the options as the first option like this:
@language_options = [['Svenska', 'sv_SV'], ['Suomi', 'fi_FI'], ['English', 'en']]
Trying it out
Start the program, log in with your web-browser and go to the User menu. You should see the new language option and after choosing and saving the changes, the user interface should be translated to the new language.