Reputation: 4342
I am trying to see if I can use Google Closure library form my webapp's internationalization and localization needs. I tried to find any tutorials on the subject, but could not find any and it seems I am stuck when trying on my own.
I am interested in getting the native name of a country.
I am not sure how I should use the the goog.locale component, though. It seems that for example, goog.locale.getNativeCountryName('EE')
always returns 'EE', instead of 'Eesti' as I would expect it to.
goog.require('goog.locale');
...
console.log( goog.locale.getNativeCountryName('EE') ) // Outputs: 'EE'
Maybe I am missing some dependencies?
EDIT: After fiddling around a little bit I discovered that if I use et_EE instead of EE, I get the expected 'Eesti'. However, that just seems plain wrong. et_EE is a locale code, not a country code, and the function clearly expects a country code... Maybe I am still doing something wrong?
Upvotes: 1
Views: 566
Reputation: 1965
getNativeCountryName()
receives a language code (in this case et
) and not a country code (EE
). See the API docs:
Returns the country name of the provided language code in its native language.
Therefore:
goog.require('goog.locale');
...
console.log( goog.locale.getNativeCountryName('et') ) // Should return 'Eesti'
Upvotes: 1