TYPO3/Overwrite translations

From Aimeos documentation

Other languages:
English 100% • ‎русский 42%

There is the possibility to overwrite translations from the core or other Aimeos extensions via TypoScript. This is very comfortable if you only want to replace certain existing translations by your own one. For each translation, you need the ISO language code, the translation domain, the original string and the new translation, e.g.

  1. plugin.tx_aimeos.settings.i18n.<ISO language code>.<number> {
  2.   domain = <translation domain>
  3.   string = <original English singular from source code>
  4.   trans = <new translation>
  5. }

This should be used only to replace a few translations. If you would like to translate Aimeos to a new language, please use the Transifex website instead. It will be available in the next Aimeos release automatically. Also, if you need to overwrite more than a few translations, you should read the article about adding translations.

Required information

ISO language code 
To specify the language for the translation, the two letter ISO language codes (639-1) are necessary. It's also possible to add the two letter ISO country codes to refer to country specific language variants like "en_GB" for British English. You can use all languages that are mapped via TypoScript from the TYPO3 language IDs, e.g. L=0 is the default language in TYPO3 and can be mapped with config.language=en to English. Please make sure the language code is always in lower case while the the optional country code is always in upper case.
This is a continuous number to distinguish between the different translations added to the TypoScript configuration. If you are using a number twice, the later translation definition will overwrite the former one.
The translation domain where the original string is from. The Aimeos core has six translation domains: "mshop" (core lib with managers), "controller/frontend" (basic business logic for the frontend), "client" (frontend HTML parts), "controller/jobs" (asynchronous cronjob tasks), "controller/extjs" (server side processing of request from the administration interface) and "admin" (administration interface). To find out the domain a string is from, you have to look at the .pot files in the Aimeos core for the string.
It's the original singular string from the source code or the .pot file. The string must be exactly the same (character case, white spaces, etc.) as in the English source code / .pot file! You can not use an already translated string as source.
New translation for the original string. This can be also an array if one or more plural forms are necessary.

Singular translations

For 2.x versions use "client/html" instead of "client"

A simple singular translation to English:

  1. plugin.tx_aimeos.settings.i18n.en.0 {
  2.   domain = client
  3.   string = address
  4.   trans = Addresses
  5. }

A simple singular translation to US English:

  1. plugin.tx_aimeos.settings.i18n.en_US.0 {
  2.   domain = client
  3.   string = basket
  4.   trans = Shopping cart
  5. }

Several singular translations to English:

  1. plugin.tx_aimeos.settings.i18n.en {
  2.   0 {
  3.     domain = client
  4.     string = basket
  5.     trans = Basket
  6.   }
  7.   1 {
  8.     domain = client
  9.     string = address
  10.     trans = Address
  11.   }
  12. }

Plural translation to English:

  1. plugin.tx_aimeos.settings.i18n.en.0 {
  2.   domain = client
  3.   string = address
  4.   trans {
  5.     0 = Address
  6.     1 = Addresses
  7.   }
  8. }

Plural translations

A translations including one or more plural forms can be defined if the original string in the source code also supports plurals. In this case the source code looks like

<translation method>( '<domain>', '<singular>, '<plural>', <count> );

and the translation methods for plurals can be translate() or dn(). To overwrite a plural translation, the simplest form is:

  1. plugin.tx_aimeos.settings.i18n.<ISO language code>.<number> {
  2.   domain = <translation domain>
  3.   string = <original singular>
  4.   trans {
  5.     0 = <singular translation>
  6.     <index> = <plural translation>
  7. }

The index "0" is always the singular translation. Most languages only have one plural form, so it must be defined by using the index "1". But some languages use several plural forms depending on the count given in the last parameter of the translation method. In this case, the index depends on the language and the value of <count>. To find out the right index for the language, you have to have a look into the _getPluralIndex() method that maps <count> to the index for the language you want to translate. An example for Czech would be:

  1. plugin.tx_aimeos.settings.i18n.cz.0 {
  2.   domain = client
  3.   string = hour
  4.   trans {
  5.     0 = dlouhá hodina # one hour
  6.     1 = dlouhé hodiny # two to four hours
  7.     2 = dlouhých hodin # more than four hours
  8.   }
  9. }

Special characters

Sometimes, the source string that should be translated contains special characters like new lines (\n) or backslashes (\). There is no problem if you place them in a .po file of your project specific extension (same location as the original .po file) and transform its content using the Unix Gettext command, e.g.

msgfmt -c -o de de.po

Using them in TypoScript is more difficult because TypoScript for example doesn't allow new lines in values. Therefore, you have to use a backslash and the character "n" as replacement:

  1. plugin.tx_aimeos.settings.i18n.de.0 {
  2.   domain = client
  3.   string = The payment was canceled.\nDo you wish to retry your order?
  4.   trans = Die Zahlung wurde abgebrochen.\nMöchten Sie ihre Bestellung wiederholen?

If the source translation contains a backslash, it must remain in TypoScript:

  1. plugin.tx_aimeos.settings.i18n.de.0 {
  2.   domain = client
  3.   string = You\'ve chosen to pay in advance
  4.   trans = Sie haben Vorauskasse gewählt