Author Topic: Name of the country does not translate into the emails  (Read 342 times)

Jose M.

  • Beginner
  • *
  • Posts: 47
Name of the country does not translate into the emails
« 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

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3167
  • using Piwik instead of Google Analytics
Re: Name of the country does not translate into the emails
« Reply #1 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.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Jose M.

  • Beginner
  • *
  • Posts: 47
Re: Name of the country does not translate into the emails
« Reply #2 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

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3167
  • using Piwik instead of Google Analytics
Re: Name of the country does not translate into the emails
« Reply #3 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.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Jose M.

  • Beginner
  • *
  • Posts: 47
Re: Name of the country does not translate into the emails
« Reply #4 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

Jose M.

  • Beginner
  • *
  • Posts: 47
Re: Name of the country does not translate into the emails
« Reply #5 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:

Code: [Select]
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:
Code: [Select]
if(!class_exists('ShopFunctionsF')) require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php');
I have modified the lines that print the fields:

Code: [Select]
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: [Select]
[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