VirtueMart Forum

VirtueMart 2 + 3 + 4 => Language/Translations => Topic started by: Jose M. on July 12, 2017, 13:58:12 PM

Title: Name of the country does not translate into the emails
Post by: Jose M. on July 12, 2017, 13:58:12 PM
Hello,
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.

Thanks
Jose M.

VM 3.2.3.9587
Joomla 3.7.3
Title: Re: Name of the country does not translate into the emails
Post by: jjk on July 13, 2017, 18:25:25 PM
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.
Title: Re: Name of the country does not translate into the emails
Post by: Jose M. on July 13, 2017, 21:26:27 PM
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.

Thanks
Jose
Title: Re: Name of the country does not translate into the emails
Post by: jjk on July 13, 2017, 22:15:31 PM
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.
Title: Re: Name of the country does not translate into the emails
Post by: Jose M. on July 14, 2017, 20:28:10 PM
Hello,
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
Title: Re: Name of the country does not translate into the emails
Post by: Jose M. on July 24, 2017, 14:22:45 PM
Well,
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;
vmLanguage::loadJLang('com_virtuemart_countries');
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'];

and
[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'];
[/code]

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

Greetings
Jose