Extraction of strings to translate from sources - SUPLA/supla-cloud GitHub Wiki
Flow for updating translations
- Run
composer run-script collect-translations - Open the
src/SuplaBundle/Resources/translations/messages.XX.yml, whereXXis the language you want to update. - Collect all of the strings below the
Translations below are missing.comment (at the end of the file). - Send them for translating.
- When you receive the translations, delete all missing strings from
yml(i.e. strings belowTranslations below are missing.comment). - Paste the new translations.
- Run
composer run-script collect-translationsagain. - Ensure that the
missingsection of the file is now empty.
Marking translations in sources
For a string to be collected by extraction mechanism from sources, you need to mark it. Please find all of the markings below. They are given in the preferred order.
- Use
vue-i18nfunction to translate static content. The following constucts used in Vue components will automatically extract translations:$t('SUPLA'),$t("SUPLA"),$t("SUPLA {var}", {var: state}),this.$t('SUPLA'); the following WILL NOT:$t(`SUPLA ${var}`) - Mark string in the current line with
// i18ncomment (works in PHP and JS); there must be ONLY ONE string in that line. - If you desing a component that translates its properties inside, name them explicite with
-i18nsuffix. I.e. the component should declare for exampleprops: ['titleI18n']and you use it liketitle-i18n="Text to translate". - For very tricky cases, provide an array of strings to translate in a comment (JS/PHP/HTML) in the form:
i18n:['SUPLA','CLOUD'].