Project

General

Profile

Translating » History » Revision 6

Revision 5 (Lukas Zapletal, 04/09/2013 11:06 AM) → Revision 6/73 (Lukas Zapletal, 04/10/2013 03:44 AM)

h1. Translating (for contributors) 

 How to translate Foreman 

 h2. Before you start 

 There are model names in the translation strings, you can get the full list here: https://github.com/lzap/foreman/blob/develop/locale/model_attributes.rb 

 These model names are in two formats: "Model name" (name of the database table) and "Modelname|Column name" for contributors column name. Here are few examples how to translate them: 

  _('Compute resource') -> "Compute Resource" 

  _('ComputeResource|Description') -> "Description" 

 Several models have prefixes in the form something/ or Something:: - you can ignore these. Example: 

  _('Audited/adapters/active record/audit') -> "Audit" 

  _('Audited::Adapters::ActiveRecord::Audit|Associated name') -> "Associated Name" 

 h2. Using Transifex 

 Go to https://www.transifex.com/projects/p/foreman and register/login. Then you can use the Transifex interface to do all translations. The project on Transifex automatically updates when we add new strings into git. Foreman team regularly downloads new translations to the develop branch in git as well, therefore there is no action needed when you finish with translations. It will be pulled eventually (e.g. before the next release). 

 Read the tips bellow if you want to start translating now. 

 h2. Manually 

 If you prefer, you can edit PO files directly using your preferred editor. Please make sure the encoding of the files is UTF-8. It is also recommended to test your translations before submitting a Pull Request on the github using either: 

   foreman# rake gettext:pack 

 or 

   foreman# make -C locale 

 The above command should not print any error message. Also you should start Foreman UI and see if your translations do fit (sometimes longer strings can wrap or even break the UI). If you start Foreman in the production mode, you need to do one of the above commands every time you change your translation. In the development mode, you only need to restart Foreman to see the changes. 

 More info about contributing your translation directly is on our [[Contribute]] wiki page.  

 h2. Tips when translating 

 There are model names in the translation strings, you can get the full list here: https://github.com/lzap/foreman/blob/develop/locale/model_attributes.rb 

 These model names are in two formats: "Model name" (name of the database table) and "Modelname|Column name" for column name. Here are few examples how to translate them: 

  _('Compute resource') -> "Compute Resource" 

  _('ComputeResource|Description') -> "Description" 

 Several models have prefixes in the form something/ or Something:: - you can ignore these. Example: 

  _('Audited/adapters/active record/audit') -> "Audit" 

  _('Audited::Adapters::ActiveRecord::Audit|Associated name') -> "Associated Name" 

 h1. Translating for developers 

 h2. Extracting strings 

 There are several rules to follow when marking strings for translations: 

  * Do not break strings with newlines because then the strings have many whitespace and it looks confusing for translators like "blah      \\n       blah". If you must separate string on several lines, you can use HEREDOC or you can contatenate strings like "line1" + "line2" because Ruby Gettext detects them both. 
  * If you want to leave a note to the translator, just drop a comment before the string in the format of # TRANSLATORS: your comment here 
  * Note that all HEREDOC strings are automatically extracted, when adding API documentation descriptions via HEREDOC, leave a message to translators not to translate these (API documentation will not be translated at the moment). 

 h2. How to pull translations (for developers) 

 To get updated translations from Transifex you will need account there (https://www.transifex.com) and the tx cli tool. 

 On Fedora: 

   # yum -y install transifex-client gettext make intltool 

 On Debian: 

   # apt-get install transifex-client gettext make intltool-debian 

 Then configure your account: 

   $ cat ~/.transifexrc 
   [https://www.transifex.net] 
   hostname = https://www.transifex.net 
   username = <your_username> 
   password = <your_password> 
   token = <should be empty> 

 And then prepare new topic branch (because the following command will make new commits to your git repo): 

   git checkout -b update-translations 

 Finally do the translation pull 

   make -C locale tx-update 

 And then you can push changes. 

   git push ...