diff --git a/developer_manual/app/l10n.rst b/developer_manual/app/l10n.rst index c6d853571..43cb94084 100644 --- a/developer_manual/app/l10n.rst +++ b/developer_manual/app/l10n.rst @@ -97,17 +97,13 @@ In every template the global variable **$l** can be used to translate the string JavaScript ========== -There is currently no good way to translate JavaScript strings. One way to still use translated strings in the scripts is to create an invisible HTML element with all the translations in it which can be parsed in the JavaScript code: - -.. code-block:: php - - +There is a global function **t()** available for translating strings. The first argument is your app name, the second argument is the string to translate. .. code-block:: js - var addNewTranslation = $('#add-new').text(); + t('myapp', 'Hello World!'); + +For advanced usage, refer to the source code **core/js/l10n.js**, **t()** is bind to **OC.L10N.translate()**. Hints =====