Extraction of strings to translate from sources - SUPLA/supla-cloud GitHub Wiki

Flow for updating translations

  1. Run composer run-script collect-translations
  2. Open the src/SuplaBundle/Resources/translations/messages.XX.yml, where XX is the language you want to update.
  3. Collect all of the strings below the Translations below are missing. comment (at the end of the file).
  4. Send them for translating.
  5. When you receive the translations, delete all missing strings from yml (i.e. strings below Translations below are missing. comment).
  6. Paste the new translations.
  7. Run composer run-script collect-translations again.
  8. Ensure that the missing section 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.

  1. Use vue-i18n function 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}`)
  2. Mark string in the current line with // i18n comment (works in PHP and JS); there must be ONLY ONE string in that line.
  3. If you desing a component that translates its properties inside, name them explicite with -i18n suffix. I.e. the component should declare for example props: ['titleI18n'] and you use it like title-i18n="Text to translate".
  4. For very tricky cases, provide an array of strings to translate in a comment (JS/PHP/HTML) in the form: i18n:['SUPLA','CLOUD'].