Multilanguage

Written by Max Milbers. Posted in Concepts

Joomla settings

It is important to create always a menuitem for "all" languages as fallback. It is suggested to install and configure the page first as single language page. It is easier to add a language later, then to start directly with more than one language. There are also two settings which should be checked, according to the use case.

The joomla plugin "System - Language Filter" has an option to automatically change the language of a user who just logged in, when a menuitem is not set  for any language, the customer may be redirected to home. To prevent this, disable the feature "Automatic Language Change". Furthermore to prevent errors with payment plugins, the feature "Remove URL Language Code" should be enabled.

Two systems for different purposes

Static translations

Static translations are reusable translations and usually without dynamic content except the content is again static. The system just holds language keys which keep as value the translation, depending on the selected language. Or in other words, it is the translation for normal text and messages for example login, cart, "product not found" and so on. This translation is usually done by the joomla/virtuemart community. You can use the language overrides to adjust them to your taste. This translation is selected in the joomla language manager. You can easily display your shop in 20 languages.

Dynamic translation

Means that the content of any item is most time unique and has its own translation like the product description. Joomla handles this with an extra item per language, translations are associated to other entries. VirtueMart uses a completly different system. It uses for any translateable item own language tables. Dynamically translateable fields are signed with a flag, when the editing language got changed. 

Form Field Translations

VirtueMart allows you to translate many form fields by adding a language key into the form field instead of a single language value (string). This is possible for all fields which are usually set up once in the store configuration. Examples for such fields are custom fields, shopper fields, etc. You can  use the Joomla Extensions > Language Manager > Overrides to translate the VirtueMart language keys entered into your form fields.

Be aware that the language keys of the plugins and the countries, even though they are shown in the front-end (FE), are defined in the back-end (BE). Shopperfield and orderfield language keys are in the FE.

The main VirtueMart language files are stored in the following (this example is for English):-

  • /administrator/components/com_virtuemart/language/en-GB/en-gb.com_virtuemart.ini - used for back-end administration views
  • /components/com_virtuemart/language/en-GB/en-gb.com_virtuemart.ini - used for the front end shop display.

Additional languages are named to reflect the language and stored in a language subfolder. If your shop used German as the default language (or supported German as an additional language) there would be a folder and files e.g.:

  • /components/com_virtuemart/language/de-DE/de-DE.com_virtuemart.ini

Language File  Location

Since Joomla! 1.6 it has been encouraged placing extension's language files in the extension folder. By storing extension language files in the extension folder, we gain the benefit of isolating and protecting our extension's language files. For example, if an administrator removes a language from the Joomla! installation, our extension's language files will not be removed. They will remain in place and will be available if the language is installed again.

You will find for example the english language files for the VirtueMart 'Amazon Pay' plugin at
...\your-root-folder\plugins\vmpayment\amazon\language\en-GB\en-GB.plg_vmpayment_amazon.ini.

However, due to limitations of our translations management system powered by transifex/ctransifex, the translations of the en-GB source langauge files are still being stored in the Joomla main front-end and back-end language folders. From the user's point of view, that has the side effect that translations are still easy to locate in the central Joomla language folders and there is no risk for them to be deleted in case of uninstalling the extension by mistake or any other reason.

Language File Structure

The language file structure is very straightforward.  Within each language file the Language lookup key and text to display is stored.

For example:- The "Add to Cart" button text uses an entry in the en-gb.com_virtuemart.ini (front end store display).  When VirtueMart displays the "Add to Cart" the display text is "retrieved" from the relevant language file.

The entry in the  language file looks like this:-

COM_VIRTUEMART_CART_ADD_TO="Add to Cart"

  • COM_VIRTUEMART_CART_ADD_TO=   - Language key - used to lookup the text to display.
  • "Add to Cart"   - Display text - What the shopper will see.

The Language Key is used in the code of the VirtueMart display views NOT the Display text.

Making changes to the displayed text (Language Overrides)

It is very easy for store owners or administrators to modify the display text to meet their specific needs, without touching the "code"

If you want to change "Add to Cart" to "Add to Basket" you simply create an override using the Joomla Language override system.

Joomla Language overrides

Overrides are stored in separate override files and are not affected by VirtueMart or Joomla updates.

Note:- Directly making display text changes in the core VirtueMart language files is not recommended, as the changes will be lost if you upgrade VirtueMart.

A Few Special Cases

VirtueMart uses a generic system to generate the titles and messages for the standard views in the backend.

As a result, you will not find these translation keys by searching for them and missing_t won't help you.
But the system is quite easy, when you know how it works.

The system is built using the controllers, models, tables, and the title of a view.

Taking the Controller as an example:- The default call for storing a message is:-
vmText::sprintf('COM_VIRTUEMART_STRING_SAVED',$this->mainLangKey);

  • $this->mainLangKey is vmText::_('COM_VIRTUEMART_CONTROLLER_'.strtoupper($this->_cname));
  • $this->_cname is the name of the controller

To display the text we use the relevant variables:-

vmText::sprintf('COM_VIRTUEMART_STRING_SAVED','COM_VIRTUEMART_CONTROLLER_PRODUCT');

The two language file entries used look like this in the language file:-

COM_VIRTUEMART_STRING_SAVED="%s successfully saved"
COM_VIRTUEMART_CONTROLLER_PRODUCT="Product(s)"

The %s means that sprintf places the first parameter, translated here "Product(s)" to %s, so we get "Product(s) successfully saved"

VirtueMart language database tables

When you install VirtueMart for the first time, the installer looks for the current Joomla site (front-end) language and creates several VirtueMart language database tables. If your Joomla site language is English, it will create the database tables listed below.

#_virtuemart_categories_en_gb
#_virtuemart_manufacturercategories_en_gb
#_virtuemart_manufacturers_en_gb
#_virtuemart_paymentmethods_en_gb
#_virtuemart_products_en_gb
#_virtuemart_shipmentmethods_en_gb
#_virtuemart_vendors_en_gb

Note: "#"  is the database table prefix for your Joomla site.

If you install additional VirtueMart language packs, then VirtueMart must create the language tables first. Storing the configuration or running the update script will create the corresponding tables for each additional language stored in the vm config. e.g. For the German language tables -   #_virtuemart_categories_de_de

This allows for better segregation and management of languages. (Joomla stores all articles and their translations in a single database table, along with a language tag. )

Troubleshooting

The key for the override cannot be found in the joomla language system

look in the administrator language files or vice versa

Language tables are missing

Open your virtuemart config and store it, the tables are the created according to the selection of the virtuemart languages.

Products vanished

http://docs.virtuemart.net/faqs/38-troubleshooting/113-products-vanished.html