Translating » History » Version 10
Lukas Zapletal, 04/15/2013 09:50 AM
1 | 6 | Lukas Zapletal | h1. Translating for contributors |
---|---|---|---|
2 | 1 | Lukas Zapletal | |
3 | 7 | Lukas Zapletal | h2. General tips |
4 | |||
5 | It is important not to change punctuation and whitespace. For example if the English string is "blah." it must be translated as "xyz." with the dot at the end. The same for an extra space - e.g. "blah " must be "xyz ". Although we try to eliminate all the extra spaces, there are rare cases where we need them. There is a checker (pofilter) which is executed regularly by developers to catch and fix all these types of mistakes. |
||
6 | |||
7 | 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 |
||
8 | |||
9 | 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: |
||
10 | |||
11 | _('Compute resource') -> "Compute Resource" |
||
12 | |||
13 | _('ComputeResource|Description') -> "Description" |
||
14 | |||
15 | Several models have prefixes in the form something/ or Something:: - you can ignore these. Example: |
||
16 | |||
17 | _('Audited/adapters/active record/audit') -> "Audit" |
||
18 | |||
19 | _('Audited::Adapters::ActiveRecord::Audit|Associated name') -> "Associated Name" |
||
20 | |||
21 | 6 | Lukas Zapletal | h2. Using Transifex |
22 | |||
23 | 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). |
||
24 | |||
25 | Read the tips bellow if you want to start translating now. |
||
26 | 1 | Lukas Zapletal | |
27 | 2 | Lukas Zapletal | h2. Manually |
28 | |||
29 | 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: |
||
30 | |||
31 | foreman# rake gettext:pack |
||
32 | 1 | Lukas Zapletal | |
33 | 2 | Lukas Zapletal | or |
34 | 1 | Lukas Zapletal | |
35 | 7 | Lukas Zapletal | foreman# make -C locale check all-mo |
36 | 2 | Lukas Zapletal | |
37 | 1 | Lukas Zapletal | 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. |
38 | |||
39 | More info about contributing your translation directly is on our [[Contribute]] wiki page. |
||
40 | |||
41 | 6 | Lukas Zapletal | h1. Translating for developers |
42 | 1 | Lukas Zapletal | |
43 | 8 | Lukas Zapletal | h2. Adding new language |
44 | |||
45 | Adding new language into Foreman is easy. You need to take two steps - first of all create new gettext PO file as a copy from POT and edit the header (at least set plural configuration): |
||
46 | |||
47 | # cp locale/foreman.pot locale/xx/foreman.po |
||
48 | # vim locale/xx/foreman.po |
||
49 | |||
50 | Then pull Rails translation strings from upstream 3-x branch: |
||
51 | |||
52 | # cd config/locale |
||
53 | # touch xx.yml |
||
54 | # ./update.sh |
||
55 | |||
56 | And add the language to Transifex and Zanata using their web interfaces. |
||
57 | |||
58 | 6 | Lukas Zapletal | h2. Extracting strings |
59 | 2 | Lukas Zapletal | |
60 | 6 | Lukas Zapletal | There are several rules to follow when marking strings for translations: |
61 | 3 | Lukas Zapletal | |
62 | 6 | Lukas Zapletal | * 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. |
63 | * 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 |
||
64 | * 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). |
||
65 | 2 | Lukas Zapletal | |
66 | 6 | Lukas Zapletal | h2. How to pull translations |
67 | 1 | Lukas Zapletal | |
68 | 4 | Lukas Zapletal | To get updated translations from Transifex you will need account there (https://www.transifex.com) and the tx cli tool. |
69 | |||
70 | On Fedora: |
||
71 | |||
72 | # yum -y install transifex-client gettext make intltool |
||
73 | |||
74 | On Debian: |
||
75 | |||
76 | # apt-get install transifex-client gettext make intltool-debian |
||
77 | |||
78 | Then configure your account: |
||
79 | |||
80 | $ cat ~/.transifexrc |
||
81 | [https://www.transifex.net] |
||
82 | hostname = https://www.transifex.net |
||
83 | username = <your_username> |
||
84 | password = <your_password> |
||
85 | token = <should be empty> |
||
86 | |||
87 | And then prepare new topic branch (because the following command will make new commits to your git repo): |
||
88 | |||
89 | git checkout -b update-translations |
||
90 | |||
91 | Finally do the translation pull |
||
92 | |||
93 | make -C locale tx-update |
||
94 | |||
95 | And then you can push changes. |
||
96 | |||
97 | git push ... |
||
98 | 9 | Lukas Zapletal | |
99 | h2. Not translated |
||
100 | |||
101 | Some parts are (yet) not translated. These include: |
||
102 | |||
103 | 10 | Lukas Zapletal | * all JavaScript resources (components etc) |
104 | 9 | Lukas Zapletal | * permission names |
105 | * predefined role names |
||
106 | * predefined user names |
||
107 | * descriptions of settings |
||
108 | 10 | Lukas Zapletal | |
109 | Some items from the list above will never be translated due to technical reasons or to avoid confusion. |