Closed (fixed)
Project:
Country codes API
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Jun 2009 at 14:42 UTC
Updated:
12 Jun 2009 at 10:37 UTC
Hi,
Great the dutch translation is there: http://drupal.org/node/382828
It is great that on screen the dutch country names are shown.
Great it is possible to get from countryname to countryid (http://drupal.org/node/487296)
But...to use location and to get to country_id's I need to get back from the dutch to the exact english iso country name.
How can I get the Exact english countryname using also in general the dutch translation?
Is there a function for this in the api? Is there another method please?
Thanks a lot in advance for your reply!
Greetings, Martijn
Comments
Comment #1
summit commentedMy usecase is the following:
My default language is dutch. And the different country-possibilities will be in dutch "Amerika", "Verenigde staten", "Verenigde staten van Amerika"
they will be changed to the dutch correct translation "Verenigde Staten".
But then to get to the correct country code the english translation "United States" need to be get.
How to get from a dutch to the english message? While my default language is set to dutch and the .po file for country codes api is loaded. How to get to the english version then?
greetings, Martijn
Comment #2
mrfelton commentedPerhaps with t()?
Comment #3
summit commentedCOuld you explain it with code please? May be I am stupid, but t() is from english to the default language isn't it?
While I want to have the English equivalent, while my default language is set to dutch..?
Thanks for your quick reply!
Greetings, Martijn
Comment #4
mrfelton commentedI've never done this before, so can't provide the code for you. How about this http://drupal.org/node/152968 - first link on google when I type in drupal translate string!... looks promising no?
Comment #5
summit commentedHi, Yes I have seen this post, and lot's of others, but no answer yet.
On this post I can set the $langcode to english: http://drupal.org/node/364841, but how to go further..
Localizer is not on D6,
EDIT may be t() has the answer. it seems looking at http://drupal.org/node/82499 t($string, $vars, $langcode) could work..
greetings, Martijn
Comment #6
mrfelton commentedCan you use the locale() function?
EDIT: Actually, I guess this works from English strings only too :(
Comment #7
summit commentedmay be t() has the answer. it seems looking at http://drupal.org/node/82499 t($string, $vars, $langcode) could work..will investigate further..
Comment #8
summit commentedi think it should be possible using t(), don't know how yet..see: http://drupalcontrib.org/api/function/t/6
Comment #9
mrfelton commentedActually, I don't think so... from the t() documentation page:
Comment #10
summit commentedMy usecase.
1) I want first all sort of posiibilities be placed back to the original Dutch translation of the country_name. Say for instanse "Verenigde Staten" <= the dutch translation of "United States".
2) Then I want to get to the english original for this particular country, while the Iso-countrycodes are matched with the english equivalent.
Wouldn't something like this not work for 2):
Comment #11
mrfelton commentedI don't think so since the first parameter to t() is supposed to be an English string. However, that aside there are still a couple of other errors in your code and it would actually be either
note: I'm using printable_name rather than name in the lookup since in countries_api_countries:
name = 'UNITED KINGDOM'
printable_name = 'United Kingdom'
ALSO, another problem with your code, assuming that t() would do the job (which it wont) - it's the third parameter of t() that is the lang code... so it would be
t($dutch_country, NULL, 'en');. Or better still, I think you would use locale() directly as inlocale($dutch_country, 'en');.However, since both t() and locale() can only translate from an English string its irrelevant!
Comment #12
summit commentedSo back to the drawing board..how to translate from another language than english, back to english...?
Comment #13
mrfelton commentedHow about doing a manual lookup in the {locales_target} and {locales_source) tables:
Comment #14
summit commentedThat could may be work. Will try to put the whole code together these days...thanks for all your support till now!
Comment #15
mrfelton commentedoh, and that should probably include the language code in the lookup too:
Comment #16
summit commentedSo for the whole usecase:
1) I want first all sort of posiibilities be placed back to the original Dutch translation of the country_name. Say for instanse "Verenigde Staten" <= the dutch translation of "United States".
2) Then I want to get to the english original for this particular country, while the Iso-countrycodes are matched with the english equivalent.
Comment #17
summit commentedShouldn't it not be
so dutch_country in str_replace instead of $countryname?
Comment #18
summit commentedHi Tom, closing this issue, because I think the further coding is not related to country codes api immidiately.
whole issue is within feedapi_mapper: http://drupal.org/node/489680
Thanks a lot for your help until now!
greetings, Martijn