You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Name of the country does not translate into the emails

Started by Jose M., July 12, 2017, 13:58:12 PM

Previous topic - Next topic

Jose M.

I am doing a website in three languages, Spanish, Catalan and English, and I have the problem that the country field does not translate into the emails.
On all pages, the shopping process and the cart, the name of the country is displayed correctly in the chosen language, but in the mail it is always in English.
I have translated all the countries in the corresponding files, ca_ES.com_virtuemart_countries.ini and es_ES.com_virtuemart_countries.ini.

some idea?
Or in what php file are mounted the billing and delivery addresses that are displayed in the mail, I can check it.

Jose M.

Joomla 3.7.3


You can solve this if you add Spain in Spanish and Catalan to VM Configuration > Countries, publish them and eventually unpublish the English Country name Spain.
Note that you have to add the newly added countries to the Country lists of your Shop's payment and shipment methods, if you have assigned your available payment and shipment methods to certain countries.
Non-English Shops: Are your language files up to date?

Jose M.

Hi jjk,
This has not solved the problem.
For example, I have "Spain" as a "country reference name" in the database and in the three language files, the corresponding translation.

The problem is that the function rendering the addresses, must take the reference and do not search for the translation.
Pass with all countries.



Works perfectly in my case if I unpublish the English country names. I use for example Deutschland and Österreich instead of Germany and Austria. Deutschland and Österreich are also used in the order emails.
Non-English Shops: Are your language files up to date?

Jose M.

This is not a good solution because you should have all the countries in each language recorded in the database.

I think it must be easier to solve, VM should translate the name of the country when it reads the user's fields to show in the order and in the email.
In the cart, in the country's checkbox, the name of the country is correctly displayed in the selected language.


Jose M.

I have made a small change to the code to get out of the way.
Maybe it's not very orthodox, but it works in this case.

In the file /components/com_virtuemart/helpers/shopfunctionsf.php , I added this function:

static public function leeNomPais ($id, $valorcamp) {
if (empty($id)) {return $valorcamp; }
$db = JFactory::getDBO ();
$q = 'SELECT `country_3_code` FROM `#__virtuemart_countries` WHERE `virtuemart_country_id` = ' . (int)$id;
$db->setQuery ($q);
$cod3 = $db->loadResult();  if ($cod3 == '') return $valorcamp;
return vmText::_('COM_VIRTUEMART_COUNTRY_'.$cod3);

And in the files /components/com_virtuemart/views/invoice/tmpl/invoice_order.php and /components/com_virtuemart/views/invoice/tmpl/mail_html_shopperaddresses.php
I added this line to the beginning of each file:
if(!class_exists('ShopFunctionsF')) require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php');

I have modified the lines that print the fields:

foreach ($this->userfields['fields'] as $field) {
    if (!empty($field['value'])) {
    if ($field['name'] == 'virtuemart_country_id') echo shopFunctionsF::leeNomPais($this->orderDetails['details']['BT']->virtuemart_country_id, $field['value']); else echo $field['value'];

[code]foreach ($this->shipmentfields['fields'] as $field) {
    if (!empty($field['value'])) {
    if ($field['name'] == 'virtuemart_country_id') echo shopFunctionsF::leeNomPais($this->orderDetails['details']['ST']->virtuemart_country_id, $field['value']); else echo$field['value'];

I publish it in case it can help someone, while VM developers do not make a modification to solve this small problem.