Given the multilingual capabilities of Drupal 7, it would be useful if when translating content into another language, that the drop-down list also changes to show the list of countries in that language. So when a user has created a content item with the value Belgium for the English-language version of that page, when translating it to French, the country appears in French as Belgique (both when page is being edited and/or viewed).

CommentFileSizeAuthor
#3 addressfield-country_l10n-1405336-3.patch614 bytesg10
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

j0rd’s picture

Looking for this as well. Any progress or plans?

kojow7’s picture

+1

g10’s picture

translation of country values on node view w/ patch in attachment
(does not changes the dropdown values, only part of fix)

rv0’s picture

strangely, the list of countries comes from iso.inc
http://api.drupal.org/api/drupal/includes%21iso.inc/function/_country_ge...

where it is already prepended with $t().
this might need another type of fix.

frank.schram’s picture

Is there a plan to fix this definately?
It is really a pain that the dropdown list of the countries is not getting translated.

williamsowen’s picture

Any updates on this? Really need it

kumkum29’s picture

Hello,

i have the same problem on a multilingual site (french/english). The countries list on the node edit page is French. The name of country is french on the view node in english and french pages.

Thanks.

Anonymous’s picture

for multilingual drupal site I would also like to have the possibility to offer the names of countries in the language chosen by the user.
I also need to sort the records in the view by country name in the language:
USA (english) or Etats-Unis (french) brings a totally different ordering of the records

frank.schram’s picture

Issue summary: View changes

Any plans to fix this? this is really annoying.
I also have the issue in 7.x-1.0-beta5, even when displaying the content, the countries don't get translated.

frank.schram’s picture

Priority: Normal » Major
le72’s picture

Any update?

estebant’s picture

Apart from using #3...

In order to translate the dropdown values, add the following code to the function
function _addressfield_country_options_list($field = NULL, $instance = NULL)
(in addressfield.module)

+  global $language;
+  if($language->language != 'en') {  
+    $countries_aux = Array();
+    foreach($countries as $key => $value) {
+      $countries_aux[$key] = t($value);  
+    }
+    asort($countries_aux);
+    $countries = $countries_aux;
+  }

  return $countries;
}
jansete’s picture

#12 works for me :P

firfin’s picture

Component: User interface » Code
Assigned: Unassigned » firfin
Category: Feature request » Bug report
Priority: Major » Normal
Status: Active » Needs work

Manually applying patch works for me on addressfield version 1.0-beta5
Will make a patch for dev version ASAP. Probably this weekend.

hosais’s picture

@firfin

Waht do you mean? #13 or #3 (the patch file) works for you?

Thanks

hosais

bojanz’s picture

You can't pass a variable for t(), so a real fix would definitely need to be somewhere else.

estebant’s picture

@bojanz, I works perfectly passing the variable to t() ;-)

hosais’s picture

Hello estebant,

Thank you for the idea of fix this problem. I just would like to clarify the issue here:

In the API it says
t($text);
, unless the text that the variable holds has been passed through t() elsewhere (e.g., $text is one of several translated literal strings in an array). It is especially important never to call.

I think the countries names has been translated of course, but I am not sure how can I be sure of that. Could you help explain more? Thanks.

hosais

estebant’s picture

Hello hosais,
I don't know what to respond you. I made this workaround some time ago and it worked well.
And I do not know why it should not do it. You are free to use it or find another solution :)

hosais’s picture

Hi estebant,

First of all, thank you for your work and I suppose the solution works because the name of countries definitely should be translated already.

However, on the other hand, the t() should not has variable as parameter because the translators need to know What to translate BEFORE the t() is called. If the content is dynamic, how can the translators translate the terms before it is called. That is there is no guarantee the text would be translated correctly every time.

In theory, in my mind (I did not trace the code about how t() is working), I suppose there is no risk in this case. If t() did not find the translation info, it just not translate it. Also in this case there is nothing saved to the database (I mean the address field itself). I mention this because I try to be supportive to clarify the right thing to do. On the other hand, I am very cautious to the patches/code modification since I will put it to my production site.

I really appreciate that you gave me your opinion as a contributor. Thank you again.

hosais

estebant’s picture

You are welcome mate!

adam1’s picture

hello,
i am glad having found this thread. problem is, i tried to apply patch #3 in the recent module version 1.2 and the recent dev version also, but this error was thrown out:

Hunk #1 FAILED at 209.
1 out of 1 hunk FAILED -- saving rejects to file addressfield.module.rej

Since i am not coding-savvy, if someone could update the patch, i would be much obliged.

markdc’s picture

Is this issue old? Because translation works perfectly fine for me out of the box. I'm running this module on an English/German website, and I see the German names of countries when translating content. However, I'm not using core content translation, rather field translation through the Entity Translation module.

firfin’s picture

Assigned: firfin » Unassigned
Status: Needs work » Closed (cannot reproduce)

Seems to work now.