.. include:: /Includes.rst.txt .. _extending-translations-icons: ====================== Translations and Icons ====================== Every text of the interface exists in English and German, in XLIFF catalogues used by PHP, Fluid templates and the TypeScript frontend. Icons come from the Lucide icon set or from the package. Catalogues ========== A package puts its catalogues in ``translations/``, one file per language: .. code-block:: text packages/web-vision/adsum-working-time/translations/ messages+intl-icu.en.xlf messages+intl-icu.de.xlf Both files have exactly the same keys; English is the fallback. The files are XLIFF 2.0, one ```` per message, with the key as ``source`` and the text as ``target``: .. code-block:: xml nav.myWorkingDays My working days In the German file ``trgLang`` is ``de`` and the ``target`` is the German text. ``id`` and ``name`` repeat the key. Keys ==== Keys are camelCase words separated by dots. Common prefixes: - ``nav.`` for entries of the navigation (``nav.myDays``) and ``nav.group.`` for its groups - ``screen.`` for titles, labels and values on screens (``screen.model.code``, ``screen.model.scheduleType.fixed``) - ``notification.type..title`` and ``notification.type..body`` for notifications (see :ref:`extending-events-notifications`) - ``clock.`` for the clock of the attendance package Prefix keys with the topic of the package. Message format ============== Messages use ICU MessageFormat: placeholders in curly braces, ``plural`` and ``select`` for counts and alternatives: .. code-block:: xml {count, plural, one {# missing punch in your team} other {# missing punches in your team}} {requesterName} and {colleagueName} swapped, {approved, select, yes {approved} other {rejected}}. Use translations ================ In PHP, inject ``Symfony\Contracts\Translation\TranslatorInterface`` and pass the placeholders as parameters: .. code-block:: php $text = $this->translator->trans('notification.type.time.workOnAbsence.body', ['employeeName' => $name, 'date' => $date], 'messages', $locale); In TypeScript, ``translate()`` takes the key and the values of the placeholders: .. code-block:: typescript import { translate } from '@adsum/core/i18n/translations.js'; const text = translate('clock.state.working.since', { time }); In Fluid templates, use the ViewHelper ``tt:translate``. Further arguments are placeholders: .. code-block:: html The frontend loads ``public/translations/.json`` of each package, built from the XLIFF files, in the language of the user's account with English as the fallback. Check the catalogues ==================== ``Build/Scripts/runTests.sh -s checkIntegrityXliff`` checks that all languages have the same keys and that every key used in a template or component is defined. Icons ===== The icons a package uses are listed in ``Build/Sources/Icons//icons.json``: .. code-block:: json [ "calendar-check", "calendar-clock", "repeat", "settings-2" ] Every name is a Lucide icon. An SVG file of the same name next to ``icons.json`` replaces it or adds an own icon. The build copies the icons to ``public/icons/.svg`` of the package. An icon name can be used: - as ``icon`` of a navigation entry (see :ref:`extending-navigation-access`) - as ``icon`` of a row action of a screen (see :ref:`extending-screens`) - in a component, with ````