Why is the culture name for English (Caribbean) "en-029"? - c#

Why is the culture name for English (Caribbean) "en-029"?
I know "en-CA" is used for English (Canada), but why 029? What does it signify? Why was it chosen?

Michael Kaplan (aka Microsoft's Unicode guru) just wrote a blog post about that last week.
EDIT
And actually, if you read the comments you'll see that 029 isn't even an ISO 3166 code because ISO 3166 is only about countries. That's where UN M.49 comes in which defines codes that specify:
a wide variety of geographical, political, or economic regions, like a
continent, a country, or a specific “group of developing countries”.
And that's where you get code 029 for Caribbean.

It might have something to do with country area codes assigned by United Nations.
I might be wrong but I believe there is more than one country in the Caribbean area, therefore MS decided to assign the territory code rather than specific symbol (the latter probably is not registered).

Related

Get language and country code (ISO 639-1)

Is there a solution for xamarin-ios to get the current culture in the format like (en_US, de_CH, ..)? I read so many articles in the web and here on stackoverflow. But I can't find a nice solution for this.
Following code snippet returns not this format everytime. Sometimes I get "gsw_DE" and so on (ISO 639-2 instead of 639-1)
NSLocale.CurrentLocale.Identifier;
My current solution is to do it by myself:
var languagecode = NSLocale.PreferredLanguages[0];
var result = String.Format("{0}_{1}", languagecode.Substring(0, 2), NSLocale.CurrentLocale.CountryCode);
Above workaround is from: Get iOS current language (including country code)
I need to make sure that I get the value in this format.
Is there another way? Thanks
We are still in the C# world, aren't we?
You can use CultureInfo.CurrentUICulture.Name and it'll give you "en-US" for "default" English and "en-GB" for English UK. Language settings are in General - Language & Region - iPhone Language.

Get Culture by currency

Well... i search the web and found many solutions for the other way, but none for these.
I have a application which gets different currencys by the user. I dont know the currencys in before, it could be everything (russian rubels, usd, €, Yen...)
I need to convert the amount into a decimal, for that i need the current culture. My current solution is very bad 8and incomplete, cause i cant cover all cultures that way), it just checks the currency sign.
if (currency.Contains("zł"))
{
cult = CultureInfo.GetCultureInfo("PL-pl")
}
else if (currency.Contains("$"))
{
//blah blah blah
}
Is there a possiblility to get Culture base on the currency sign. Another maybe difficult thing is, that i dont know if the currency symbol is before or beyond the amount (varys by culture i.E: $45.00 <-> 45.00€)
Create a lookup once and use it for fast access. Notice that a particular currency symbol may be used by multiple cultures:
ILookup<string, CultureInfo> cultureByCurrency =
CultureInfo.GetCultures(CultureTypes.AllCultures)
.ToLookup(_ => _.NumberFormat.CurrencySymbol);
Then to lookup $ for example:
IEnumerable<CultureInfo> culturesThatUseDollar = cultureByCurrency["$"];
There is no exact mapping from a currency code or symbol to a culture. Consider basic examples like EUR (€), which is used as the official currency in 18 countries. There are many issues arising from this mere fact, like whether the symbol is placed before or after the value etc. You should ask the user about the specific formatting to use instead of trying to deduce it from the currency symbol.
Also, a single currency symbol is used for many currencies. Consider that $ can denote both USD, CAD, AUD and other currencies that call themselves as 'dollars'. You should use currency codes if you want an exact specification of a currency.
It is not possible.
EUR for example would map to de-DE, fr-FR, nl-NL and other countries.
There is no mapping from Currency to culture, because multiple countries share currencies
In your else if block, which culture would you assign after finding the $? en-US? fr-CA?
I would suggest a different approach that would remove any sort of ambiguity. Have the user specify their nationality before entering this chunk of code. Consider having the culture information given to you instead of attempting to guess it.
return CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => c.NumberFormat.CurrencySymbol.Equals("$"));

Why does RegionInfo.TwoLetterISORegionName return 3 chars for Caribbean?

Trying to generate currency type seed data for an application and iterating through the CultureInfo collection of System.Globalization. I kept getting truncation errors on my insert statements until I discovered that when Caribbean comes up (listed at MSDN as CB) a 3 character value of 029 on the TwoLetterISORegionName. I had a serious WTF moment.
Does anyone know why this happens?
To reproduce:
Instantiate the RegionInfo object for the Caribbean.
RegionInfo region = new RegionInfo(9225);
Access the TwoLetterISORegionName property.
Value should be CB. Actual value is 026.
It looks like there is no ISO-3166 2-letter ISO Country Code based on the ISO Website. The same goes for the Wikipedia ISO 3166-1 page.
It is quite interesting that Carribean is listed by MSDN. Maybe this is because RegionInfo also applies to geographical regions and not only to countries, but that's just a guess.

Pluralising and Localizing strings in C#

I've got a C# WPF application I'm attempting to globalize with resx files. It works splendidly. I've run into a hitch, however. I've got a relatively simple solution for pluralisation where I have a singular and plural form of the string I'm displaying and I pick one based on the number of whatever things I'm talking about.
However, I've recently come to terms with the fact that some cultures have multiple plural forms. Has anyone come across a good solution to this problem in C#, let alone WPF?
The canonical example that I've seen for this problem comes from the Polish language. Polish has a singular, paucal, and plural form. This example is for the translation of the word "file":
1 plik
2,3,4 pliki
5-21 pliko'w
22-24 pliki
25-31 pliko'w
Mozilla has implemented this in Firefox 3, and they have a guide describing how to use their implementation here.
Most notably, in the Developing with PluralForm section, they have a link
resource://gre/modules/PluralForm.jsm
to the source of their implementation. Must be opened from within Firefox 3 and higher.
I have not read through the whole thing, but this seems to be like a good place to at least get some ideas.
HTH.
Consider trying to just avoid the problem altogether. Instead of building sentences, try and build your UI to avoid the problem. Instead of saying "5 pages" try saying: "Pages: 5".
Localization like this takes consideration of the languages you want to translate to. Multiple plurals are fairly rare and I would imagine in most cases are interchangeable or context sensitive. Which unless it is being used in multiple places in your application you will not need to worry about. If you are doing this and a particular usage does create a grammatical error in plural usage then you need to add a new key across the board (all languages) for that one instance. Or, since you are detecting culture anyway, add an additional conditional for the affected language and use the single alternate plural form.
I would not suggest avoiding it as you can quickly lose the flow of natural language "Mins answered ago: 6".
Maybe you meant this in the first place but the far more common scenario is variations in syntactical placement across different cultures. For example, the string wanting to be localized "This page is viewed X times". You may want to make 3 localizable strings for this:
PageViewStart = "This page is viewed"
PageViewEnd = "time"
PageViewEndPlural = "times"
Then a simple pseudo-implementation would be
PageViewStart + pageCount.ToString() + pageCount == 1 ? PageViewEnd : PageViewEndPlural;
However in Dutch "Deze pagina is {0} keer bekeken" and in Korean "조회수 {0}". So you see you will immediatley run into problems with implementations on the multiple ways to format plural sentence structure across languages.
I purposely left a {0} in the examples as it alludes to my solution. Use a localization for the whole sentence in plural and non-plural.
PageView = "This page viewed 1 time."
PageViewPlural = "This page viewed {0} times."
This way you can write the conditional (pseudo again depending on your implementation):
pageCount > 1 ? PageView : String.Format(PageViewPlural, pageCount.ToString());
The only thing is that your translators will need to be instructed as to the meaning and placement of the {0} token in the resx file.
I guess yo uare aware of gettext's plural form handling. But generally, I'd try to avoid it (as Yuliy said).
It's not only the nouns - phrases can change (e.g. in German "1 Datei konnte nicht gelöscht werden" / "2 Dateien konnten nicht gelöscht werden").
It is much more friendly and elegant than the problem-evasive "Dateien, die nicht gelöscht werden konnten: 2", but there's a tradeoff in how many ressources you have for localization.

Best Practice - Format Multiple Currencies

What is best practice for the scenario listed below?
We have an application which we would like to support multiple currencies. The software will respect the users locale and regional settings to dictate the correct number format, i.e. $10,000.00 or 10.000,00₴ etc.
We would however like to be able to format different numbers based upon a currency ID (perhaps the three letter ISO4217 code). Our idea is to store a table in the database with each currency and then request from the user to select the currency symbol which will be used. The program will then format all numbers based upon the locale/region setting but will use the currency symbol as defined in our program.
So, given the following values and currencies
10000 AUD
5989.34 USD
450 EUR
the program would output
$10,000.00
$5,989.34
€450.00
or with a regional setting that formated numbers as #####,##$ the result would be;
10000,00$
5989,34$
450,00€
Respecting locale/region number formatting but displaying different currencies, what is best practice for this?
I hope this makes sense.
Technology used is c# .NET 2.0.
I think this Q is an excellent and clear answer as to WHAT you should be doing
SO - Proper currency format when not displaying the native currency of a culture
And this Q has a good answer of HOW to do this in C#
SO - Currency formatting
It sounds like you have a handle on the best practices for formatting data. If I were you I would worry less about what is technically the standard but focus more on what it is your users are accustomed to.
If you are operating in markets where users are fairly savvy about different currencies it is a very different thing than having more monocultural users. Depending on the case, you will need to design your interface in a different way.
Moreover, if your requirement is to display any currency to any locale, the ISO4217 standard is your best bet. It is what is shown at currency exchange shops across the world, on currency exchanges, invoices, etc. Otherwise, displaying currency symbols could be rather confusing to some users and the symbol by itself does not indicate what currency the amount actually is.
I would also reference the following SO questions. Not all of them directly relate to your problem, but they have very good meta discussions about the issues involved in supporting multiple currencies.
How do I round up currency values in Java
Representing Monetary Values in Java
What to do with Java BigDecimal performance?
Rather than storing just the currency symbol, you could store the culture string for each currency code, so AUD --> en-AU
CultureInfo ci = new CultureInfo("en-AU");
currencyValue.ToString( "c", ci );
I'm not sure how much flexibility there is in formatting available.
Not sure if this helps:
Formatting Numeric Data for a Specific Culture
You could store the money value as a decimal, then append the currency symbol on the UI.
Fowler discusses the Money pattern in Patterns of Enterprise Application Architecture here: http://www.martinfowler.com/eaaCatalog/money.html
I faced a similar situation. I found a way, dont know how useful it will be for you. But it solved my problems. I set a session string for each place like Session["cur"]="0.000" or "0.00" for each login authentication. And where ever currency comes in the system I used .ToString[Session["cur"].ToString()] to the model variables. It did the trick for me . Hope it helps you too .

Categories

Resources