Laravel/Overwrite translations

From Aimeos documentation

Laravel
Other languages:
English 100%


There is the possibility to overwrite translations from the core or other Aimeos extensions via the config/shop.php file. 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. 'i18n' => array(
  2.     '<ISO language code>' => array(
  3.         '<translation domain>' => array(
  4.             '<original English singular from source code>' => array('<new translation>'),
  5.         ),
  6.     ),
  7. ),

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. Please make sure the language code is always in lower case while the the optional country code is always in upper case.
translation domain 
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.
original singular 
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 source code / .pot file. You can not use already translated strings as source.
new translation 
New translation for the original string. This must be an array to support one or more plural forms.

Singular translations

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

A simple singular translation to English:

  1. 'i18n' => array(
  2.     'en' => array(
  3.         'client' => array(
  4.             'address' => array('Addresses'),
  5.         ),
  6.     ),
  7. ),

A simple singular translation to US English:

  1. 'i18n' => array(
  2.     'en_US' => array(
  3.         'client' => array(
  4.             'basket' => array('Shopping cart'),
  5.         ),
  6.     ),
  7. ),

Several singular translations to English:

  1. 'i18n' => array(
  2.     'en_US' => array(
  3.         'client' => array(
  4.             'address' => array('Address'),
  5.             'basket' => array('Basket'),
  6.         ),
  7.     ),
  8. ),

Plural translation to English:

  1. 'i18n' => array(
  2.     'en' => array(
  3.         'client' => array(
  4.             'address' => array('Address','Addresses'),
  5.         ),
  6.     ),
  7. ),

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. 'i18n' => array(
  2.     '<ISO language code>' => array(
  3.         '<translation domain>' => array(
  4.             '<original singular>' => array('<singular translation>','<plural translation>'),
  5.         ),
  6.     ),
  7. ),

The index "0" is always the singular translation and most languages only have one plural form, so it must be defined by using the index "1" (PHP arrays always start with index "0" automatically). 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. 'i18n' => array(
  2.     'cz' => array(
  3.         'client' => array(
  4.             'hour' => array(
  5.                 'dlouhá hodina', // one hour
  6.                 'dlouhé hodiny', // two to four hours
  7.                 'dlouhých hodin', // more than four hours
  8.             ),
  9.         ),
  10.     ),
  11. ),