diff --git a/developer_manual/basics/translations.rst b/developer_manual/basics/translations.rst index 529b5314024..4ee51205f44 100644 --- a/developer_manual/basics/translations.rst +++ b/developer_manual/basics/translations.rst @@ -220,6 +220,8 @@ JS Example: /* BEST: Simple string with undefined plural not using any number in the string */ t('myapp', 'Import calendars') +.. _improving-translations: + Improving your translations ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -284,37 +286,49 @@ The added hints will be shown in the Transifex web-interface: PHP """ +Place the comment on the line before the ``->t()`` or ``->n()`` call: + +.. code-block:: php + + // TRANSLATORS Will be shown inside a popup and asks the user to add a new file + p($l->t('Add new file')); + + // TRANSLATORS The placeholder refers to the software product name, e.g. "Add to your Nextcloud" + $l->t('Add to your %s', [$productName]); + +For multi-line context or example output, use consecutive comment lines: + .. code-block:: php - + // TRANSLATORS + // Indicates when a calendar event will happen, shown on invitation emails. + // Output example: "In 1 hour on July 1, 2024 for the entire day" + $l->t('In %1$s on %2$s for the entire day', [$relativeTime, $date]); JavaScript / TypeScript """"""""""""""""""""""" +Place the comment on the line before the ``t()`` or ``n()`` call: + .. code-block:: javascript - // 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 + // TRANSLATORS: name that is appended to copied files, will be put in parenthesis with a number for the second+ copy var copyNameLocalized = t('files', 'copy'); + // TRANSLATORS: {relativeDueDate} will be replaced with a relative time, e.g. "2 hours ago" or "in 3 days" + t('files_reminders', 'We will remind you of this file {relativeDueDate}', { relativeDueDate }) + Vue """ -This covers vue html templates in vue sfc components. -For vue js code, see the javascript section. +In the ``