It's about translation from countries. I use Entity translation, but the location fields were not translated. When I translate some other fields in a node the result is that the updated note shows the country in the language I updated at last.

E.g. I create a node in English. I see germany as Country name.
Then I translate some other fields into german and update. Then i see Deutschland either at the English or the German version.

So is this a location or drupal core Problem?

THX in advance

maen

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

maen’s picture

Now I know the problem:

Neither with i18n nor with entity translation switcher the country names are correct.

E.g. in a German/English site the country names should be Deutschland and Germany when the language is switched. But either the name is shown as Germany/Germany or as Deutschland/Deutschland. The modules addressfield and the ubercart-location module do it correctly.

I saw that when I cleared the cache of Drupal the country name was shown in the appropriate language. For instance I switched from English to German, it was shown as Germany, then cleared the cache, Deutschland was shown, then switched to the English version, again Deutschland, cleared the cache ....

Debugging of the location module shows the following:

In line 1165 the function location_load_location gives the country_name in line 1201 by calling the function location_country_name (line 610 from location.inc). This function calls "location_get_iso3166_list" in which the function country_get_list is called and the result is cached as $countries.

Which means that after the string is cached in the active language of the moment, the country name holds up until the cache expires. So the actual country name is randomized by the time the cache expires and the user language the site is called next.

But I can't find a hook to change this.

So does anyone has an idea to solve this?

THX in advance

Marc

maen’s picture

Category: Support request » Bug report

After my research and asking some people I believe this is a bug!???

bluesman2014’s picture

I was having this issue, but then it turned out my strings translations had vanished. I re-installed the .po files and now it's ok

mcalabrese’s picture

After doing some research I noticed that the country_name is being cached. Because of this a user who saves a location field will have the country_name cached in the language it was saved in. To avoid this I am supplying a patch which sets the country_name inside the template preprocessor instead of at time of load.

This patch needs testing and is my first attempt at fixing this issue.
I suspect this will cause some errors with other aspects of the module.

bluesman2014’s picture

I just tried applying the patch in #4. It gave me a WSOD and the following error:

PHP Parse error: syntax error, unexpected 'include_once' (T_INCLUDE_ONCE), expecting '{' in /home/***/public_html/sites/all/modules/location/location.module on line 22

Schroeffu’s picture

Same problem here, f.e. it always display "Germany" instead of "Deutschland" with DE Langauge. Any further ideas?

kenorb’s picture

Status: Active » Needs review
legolasbo’s picture

Retesting to see if the patch still applies correctly

alexfarr’s picture

Hi All,

I have come across this issue too. I found the issue to be that the translated country_name and province_name were stored in the field cache. The output of the location_load_location function gets stored in the field cache so should not have any translated strings in it. comment #4 does go some way to fix this by moving the action to the preprocess but it did not also take into account the province, plus in some situations where country code is hidden the country_name was not outputted also. Here is an updated patch.

mansspams’s picture

Version: 7.x-3.6 » 7.x-3.x-dev

Needs re-roll.

Graham Leach’s picture

Hello,

A bunch of countries are not translated to Chinese, and appear as ENGLISH whenever a country dropdown is populated, even if the language context is zh-hans or zh-hant:

Extensive discussion of this issue is here

https://mymanthemaker.blogspot.com/2019/10/drupal-7-ubercart-7-translate...
(I cover dozens of Drupal 7 shortcomings on this website, usually along with fixes)

Here's the countries in question. The corresponding .po files (drupal-X.Y.zh-hans.po, drupal-X.Y.zh-hant.po) need to be checked and updated.

I have verified that translation strings do not appear in the latest zh-hans for Drupal 7 (drupal-7.67.zh-hans.po) for the following places:

Bolivia, Plurinational State of
Bonaire, Saint Eustatius and Saba
Brunei Darussalam
Congo
Congo, the Democratic Republic of the
Côte d'Ivoire
Falkland Islands (Malvinas)
Heard Island and McDonald Islands
Holy See (Vatican City State)
Hong Kong
Iran, Islamic Republic of
Korea, Democratic People's Republic of
Korea, Republic of
Lao People's Democratic Republic
Macau
Micronesia, Federated States of
Moldovoa, Republic of
Nauru (諾魯)
Palestinian Territory, Occupied
Russian Federation
Réunion
Saint Helena, Ascension and Tristan da Cunha
Syrian Arab Republic
Taiwan, Province of China
Tanzania, United Republic of
Venezuela, Bolivarian Republic of
Viet Nam
Virgin Islands, British
Virgin Islands, U.S.
Åland Islands

Here's an example of what should be added to these files to properly translate the entry for Viet Nam:

Traditional Chinese

msgid "Viet Nam"
msgid "越南"

Simplified Chinese

msgid "Viet Nam"
msgid "越南"