You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nextcloud's translation system is powered by `Transifex <https://explore.transifex.com/nextcloud/>`_. To start translating sign up and enter a group. If your community app should be translated by the `Nextcloud community on Transifex <https://explore.transifex.com/nextcloud/>`_ just follow the setup section below.
8
+
9
+
Translation tool
10
+
----------------
11
+
12
+
.. note::
13
+
14
+
The tool-based translation currently only supports repositories hosted on ``github.com``. If your app is hosted elsewhere, you can try to follow the :ref:`manual-translation` instead.
15
+
16
+
The `translation tool <https://github.com/nextcloud/docker-ci/tree/master/translations/translationtool>`_ scrapes the source code for method calls to ``t()``
17
+
or ``n()`` to extract the strings that should be translated. If you check
18
+
in minified JS code for example then those method names are also quite
19
+
common and could cause wrong extractions. For this reason we allow to
20
+
specify a list of files that the translation tool will not scrape for
21
+
strings. You simply need to add a file named :file:`.l10nignore` into
22
+
the root folder of your app and specify the files one per line::
23
+
24
+
# compiled vue templates
25
+
js/bruteforcesettings.js
26
+
27
+
28
+
29
+
Setup of the transifex sync
30
+
---------------------------
31
+
32
+
Transifex configuration ``.tx/config``
33
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34
+
35
+
To setup the transifex sync within the Nextcloud community you need to add first the
36
+
transifex config to your app folder at :file:`.tx/config` (please replace ``MYAPP`` with your apps id):
After sending the invitation, please `open a ticket using the "Request translations" template <https://github.com/nextcloud/docker-ci/issues/new/choose>`_.
for default and stable branches. If you do that, you need to grant the
107
+
`@nextcloud-bot <https://github.com/nextcloud-bot>`_ ``admin`` permissions and allow administrators to bypass the protection.
108
+
This feature however is only possible for repositories owned by organizations, not in repositories owned by individuals!
109
+
You can `create your own organization <https://docs.github.com/en/organizations/collaborating-with-groups-in-organizations/creating-a-new-organization-from-scratch>`_
110
+
111
+
If you need help just `open a ticket with the request <https://github.com/nextcloud/docker-ci/issues/new/choose>`_
112
+
and we can also guide you through the steps.
113
+
114
+
.. _manual-translation:
115
+
116
+
Manual translation
117
+
------------------
118
+
119
+
If Transifex is not the right choice or the app is not accepted for translation,
120
+
generate the gettext strings by yourself by executing our
Copy file name to clipboardExpand all lines: developer_manual/basics/translations.rst
+70-38Lines changed: 70 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
-
===========
2
-
Translation
3
-
===========
1
+
.. _Translations:
2
+
3
+
============
4
+
Translations
5
+
============
4
6
5
7
.. sectionauthor:: Bernhard Posselt <dev@bernhard-posselt.com>, Kristof Hamann
6
8
@@ -60,27 +62,6 @@ Strings can then be translated in the following way:
60
62
}
61
63
}
62
64
63
-
FIXME
64
-
-----
65
-
66
-
Correct plurals
67
-
^^^^^^^^^^^^^^^
68
-
69
-
If you use a plural, you **must** also use the ``%n`` placeholder. The placeholder defines the plural and the word without the number preceding is wrong. If you don't know/have a number for your translation, e.g. because you don't know how many items are going to be selected, just use an undefined plural. They exist in every language and have one form. They do not follow the normal plural pattern.
@@ -121,7 +102,7 @@ In every template the global variable ``$l`` can be used to translate the string
121
102
// Date string
122
103
<em><?php p($l->l('date', time())); ?></em>
123
104
124
-
JavaScript / Typescript / Vue
105
+
JavaScript / TypeScript / Vue
125
106
-----------------------------
126
107
127
108
There are global functions ``t()`` and ``n()`` available for translating strings in javascript code.
@@ -138,13 +119,15 @@ They differ a bit in terms of usage compared to php:
138
119
t('myapp', '{name} is available. Get {linkstart}more information{linkend}', {name:'Nextcloud 16', linkstart:'<a href="...">', linkend:'</a>'});
139
120
n('myapp', 'Import %n calendar into {collection}', 'Import %n calendars into {collection}', selectionLength, {collection:'Nextcloud'});
140
121
141
-
142
122
Guidelines
143
123
----------
144
124
145
125
Please also look through the following hints to improve your strings and make them better translatable by the community
146
126
and therefore improving the experience for non-english users.
147
127
128
+
Dos and Don'ts
129
+
^^^^^^^^^^^^^^
130
+
148
131
.. list-table::
149
132
:header-rows: 1
150
133
@@ -191,17 +174,49 @@ and therefore improving the experience for non-english users.
191
174
- "Error: %s"
192
175
- Instead of concatenating errors or part messages, make them a proper placeholder
193
176
177
+
Correct plurals
178
+
^^^^^^^^^^^^^^^
179
+
180
+
If you use a plural, you **must** also use the ``%n`` placeholder. The placeholder defines the plural and the word without the number preceding is wrong. If you don't know/have a number for your translation, e.g. because you don't know how many items are going to be selected, just use an undefined plural. They exist in every language and have one form. They do not follow the normal plural pattern.
/* BEST: Simple string with undefined plural not using any number in the string */
204
+
t('myapp', 'Import calendars')
205
+
194
206
Improving your translations
195
207
^^^^^^^^^^^^^^^^^^^^^^^^^^^
196
208
197
-
You shall **never split** sentences and **never concatenate** two translations (e.g. "Enable" and "dark mode" can not be combined to "Enable dark mode", because languages might have to use different cases)! Translators lose the context and they have no chance to possibly re-arrange words/parts as needed.
198
-
199
-
Bad example:
209
+
Starting with the following example, improving it step by step:
You shall **never split** sentences and **never concatenate** two translations (e.g. "Enable" and "dark mode" can not be combined to "Enable dark mode", because languages might have to use different cases)! Translators lose the context and they have no chance to possibly re-arrange words/parts as needed.
219
+
205
220
Translators will translate:
206
221
207
222
* ``Select file from``
@@ -217,13 +232,21 @@ So the following code is a bit better, but suffers from another issue:
217
232
218
233
<?php p($l->t('Select file from <ahref="#"id="browselink">local filesystem</a> or <ahref="#"id="cloudlink">cloud</a>'));?>
219
234
235
+
Step 2: HTML Markup
236
+
"""""""""""""""""""
237
+
220
238
In this case the translators can re-arrange as they like, but have to deal with your markup and can mess it up easily. It is better to **keep the markup out** of your code, so the following translation is even better:
221
239
222
240
.. code-block:: php
223
241
224
242
<?php p($l->t('Select file from %slocal filesystem%s or %scloud%s', ['<ahref="#"id="browselink">', '</a>', '<ahref="#"id="cloudlink">', '</a>']));?>
225
243
226
-
But there is one last problem with this. In case the language has to turn things around, your code will still insert the parameters in the given order and they can not re-order them. To prevent this last hurdle simply **use positioned placeholders** like ``%1$s``:
244
+
But there is one last problem with this.
245
+
246
+
Step 3: Placeholders
247
+
""""""""""""""""""""
248
+
249
+
In case the language has to turn things around, your code will still insert the parameters in the given order and they can not re-order them. To prevent this last hurdle simply **use positioned placeholders** like ``%1$s``:
227
250
228
251
.. code-block:: php
229
252
@@ -234,11 +257,15 @@ This allows translators to have the cloudlink before the browselink in case the
234
257
.. _Hints:
235
258
236
259
Provide context hints for translators
237
-
-------------------------------------
260
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
238
261
239
-
In case some translation strings may be translated wrongly because they have multiple meanings, you can add hints which will be shown in the Transifex web-interface:
262
+
In case some translation strings may be translated wrongly because they have multiple meanings.
263
+
Especially translations strings that only contain a single word often result in problems.
264
+
The most famous example in the Nextcloud code base is ``Share`` which can which can be the verb and action ``To share something`` or the noun ``A share``.
265
+
The added hints will be shown in the Transifex web-interface:
240
266
241
-
**PHP**
267
+
PHP
268
+
"""
242
269
243
270
.. code-block:: php
244
271
@@ -251,14 +278,16 @@ In case some translation strings may be translated wrongly because they have mul
251
278
</li>
252
279
</ul>
253
280
254
-
**Javascript / Typescript**
281
+
JavaScript / TypeScript
282
+
"""""""""""""""""""""""
255
283
256
284
.. code-block:: javascript
257
285
258
286
// TRANSLATORS name that is appended to copied files with the same name, will be put in parenthesis and appended with a number if it is the second+ copy
259
287
var copyNameLocalized =t('files', 'copy');
260
288
261
-
**Vue**
289
+
Vue
290
+
"""
262
291
263
292
This covers vue html templates in vue sfc components.
264
293
For vue js code, see the javascript section.
@@ -270,21 +299,24 @@ For vue js code, see the javascript section.
270
299
{{ t('forms', 'Required') }}
271
300
</NcActionCheckbox>
272
301
273
-
**C++ (Qt)**
302
+
C++ (Qt) / Desktop client
303
+
"""""""""""""""""""""""""
274
304
275
305
.. code-block:: c++
276
306
277
307
//: Example text: "Progress of sync process. Shows the currently synced filename"
0 commit comments