Hi,
If the country field is displayed and so on the state / province field's values are displayed from ajax function, the title of the field "state / province" is not translated (or is very unstable).
Thanks to codycraven to this great module, i hope can help to improve it.
Cheers
Timos
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | addresses-6.x-1.10-translation-support-ca-sortorder.patch | 3.97 KB | alxp |
| #5 | addresses-6.x-1.10-translation-support.patch | 2.17 KB | alxp |
| #5 | canadian-provinces.fr_.po | 949 bytes | alxp |
| #2 | prov-china.po | 1.75 KB | ebenfarnworth |
Comments
Comment #1
codycraven commentedtimos thanks for the catch.
I think this has to do with how the Ajax call is made to the server and Drupal not being told a translated call is being requested.
I need to do some reading up on the translation system to address the issue.
Comment #2
ebenfarnworth commentedI have the same problem. I can translate the Country field but not the State / Province field. Thanks in advance to anyone who can find a solution.
I have attached a po file of provinces in China, translated to Chinese that can be used when this is fixed.
Thanks and good luck.
Comment #3
timos commented@codycraven
Yep, thanks for your reactivity
Cheers,
Comment #4
sdsheridanI think I figured out a way to do this, albeit perhaps somewhat round-about. I made changes to three modules, as follows:
addresses.module
I made a change here in function addresses_elements_process to work with the patch for Customization of field titles and help text, to pass the title of the page to the javascript as follows:
addresses.js
Here I made a small addition to the function performProvinceAjax, adding the passing of that label text back to the ajax function:
addresses.settings.inc
It's in the function addresses_province_ajax where the label actually gets set. So here, I added the line to retrieve the label passed back, as follows:
...and then used it later in the function to build the html as follows:
It's working for me. Of course, something struck me as I was doing this, that in fact it might be good to in each country's file (i.e., country_code.inc) to have a function that returns the appropriate default label(s) for that country. For example, you could have a function such as the following:
This way, the labels would travel with the country, making for less configuration me thinks.
Comment #5
alxp commentedHere's a patch that makes the t() function calls in the addresses_province_list_xx() functions work correctly. It follows the format of #4 but doesn't deal with the labels, instead it detects the site's language when building the form, sets a Drupal.settings.addresses.language setting for JavaScript, and then adds a language parameter to the get_provinces_ajax call. The ajax function then sees this parameter and sets Drupal's global $language object accordingly before creating the province list.
I've also attached a language translation file with a list of Canadian provinces translated to French.
I'm still new to the process of submitting patches, if this doesn't work for everyone I'd appreciate any tips or help people want to provide.
Cheers,
-- alexander
Comment #6
alxp commentedThis is an update to the patch in #5 which fixes a problem we were having with the sort order of Canadian provinces when the translation was being done. We wanted the French province names to be in the correct alphabetical order when the list was displayed in French, but still have the territories appear at the end, so I made a change to the ca.inc file in the countries folder to accomplish this. It has no effect if t('Quebec') != 'Québec ', so as to account for sites that haven't put in translations for province names but might still be making the site available in French.
Comment #7
AlexisWilke commentedHi Alxp,
Okay... The first patch looks good, although if $languages[$_GET['language']] is undefined, you should not set $language (to null).
Now, for the provinces, there is only one place where we get the province names as shown in the snippet of code below:
Couldn't we just call asort() on $provinces[$country_code] and get the same result (but for all languages and all provinces)?
I do not know whether provinces of other countries are often translated though (i.e. in France "Bretagne" could be translated into "Little Britain," but I don't think anyone does that.)
Thank you.
Alexis
Comment #8
AlexisWilke commentedAlxp,
Okay, the first patch is checked in. If you would please verify that it works as I moved a few things around.
In regard to the .po file, you are now expected to enter the translation on the Drupal translation system. Search around and see how it works... I have not used it as I do not spend any time translating. 8-)
Let me know if my solution for the sorting works for you. If so, then I'd rather use that as a universal solution rather than a specialized solution for just Canada.
Thank you,
Alexis
Comment #9
alxp commentedHi Alexis,
Canada has 10 provinces and 3 territories, and it's customary to list the territories at the end, and it was something our client asked for specifically, which produced a need for non-standard sorting in both languages. In general, however, I think you're right that a more graceful solution would just be to sort the names alphabetically.
Everything else works as expected, I'm glad I could be of help with this.
Cheers,
-- alexander
Comment #10
bwinett commented