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
Copy file name to clipboardExpand all lines: developer_manual/basics/front-end/l10n.rst
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,8 @@ Translation
7
7
Nextcloud provides mechanisms for internationalization (make an application translatable) and localization (add translations for specific languages). This section provides detailed instructions for both aspects.
8
8
In order to make your app translatable (internationalization), you should use Nextcloud's methods for translating strings. They are available for both the server-side (PHP, Templates) as well as for the client-side (JavaScript).
9
9
10
-
PHP
11
-
---
10
+
PHP Backend
11
+
-----------
12
12
13
13
If localized strings are used in the backend code, simply inject the ``\OCP\IL10N`` class into your service via type hinting it in the constructor. You will automatically get the language object containing the translations of your app:
14
14
@@ -105,8 +105,8 @@ the ``force_language`` and ``default_language`` configuration options to conside
105
105
}
106
106
107
107
108
-
Templates
109
-
---------
108
+
PHP Templates
109
+
-------------
110
110
111
111
In every template the global variable ``$l`` can be used to translate the strings using its methods ``t()`` and ``n()``:
112
112
@@ -121,8 +121,8 @@ In every template the global variable ``$l`` can be used to translate the string
121
121
// Date string
122
122
<em><?php p($l->l('date', time())); ?></em>
123
123
124
-
JavaScript
125
-
----------
124
+
JavaScript / Typescript / Vue
125
+
-----------------------------
126
126
127
127
There are global functions ``t()`` and ``n()`` available for translating strings in javascript code.
128
128
If your app is build, you can import the translation functions from the `@nextcloud/l10n package <https://github.com/nextcloud-libraries/nextcloud-l10n>`_.
@@ -234,7 +234,7 @@ This allows translators to have the cloudlink before the browselink in case the
234
234
.. _Hints:
235
235
236
236
Provide context hints for translators
237
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
237
+
-------------------------------------
238
238
239
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:
240
240
@@ -251,7 +251,7 @@ In case some translation strings may be translated wrongly because they have mul
0 commit comments