Can i find the states codes somewhere that have to be used for the Paypal address format ?
Which states codes have to be used for Srilanka?
When you mean the two-character country codes, that would be
lk
Reference: https://www.paypal.com/lk/webapps/mpp/home
They are using the two-digit "alpha 2" country codes as defined in ISO 3166.
Related
I am using NumberFormat.compactCurrency() with HI locale as I want to compact the number in the Indian currency way - into lakhs, crores..etc.
But, if I use HI as the locale in it, it seems to add the lakh/crore string in Hindi. I want to compact the currency in the Indian way but show the lakh/crore in English. Do I need to use a different locale string for that? any other ideas?
The most simple way to get closest to your requirements would be to use en_IN:
NumberFormat.compactCurrency(locale: 'en_IN').format(price)
Output :
I have my app translated to different languages (https://pub.dev/packages/flutter_translate) and I also provide the option to select a specific currency (https://pub.dev/packages/country_currency_pickers):
first 2 options
When I select the currency I get this:
Now that everything is selected I need to update my currency and for that I can do:
NumberFormat.simpleCurrency(
locale: "en_GB",
).format(money);
Notice that I have en_GB which is what I'd need here to display pounds. For this example I get es from the language and GB from the currency but es_GB gets euros instead of pounds, which is what I'd need.
How can I get the country code from any of the previous parameters?
Can I pass something else to get the symbol like currencyCode for example?
You should use provide name in the constructor. https://api.flutter.dev/flutter/intl/NumberFormat/NumberFormat.simpleCurrency.html
If name is specified, the currency with that ISO 4217 name will be used. Otherwise we will use the default currency name for the current locale.
NumberFormat.simpleCurrency(
name: "GBP", //currencyCode
).format(money)
This is not a question but rather a note for other developers who might be using CTCarrier.
I have been developing an app which requires reading the iso of the SIM card to determine the country the app is being used in (at least the SIM country). The doc mentions the following about the isoCountryCode property:
This property uses the ISO 3166-1 country code representation.
From my tests and deployment however it appears that the returned iso is not the standard ISO 3166-1 for several countries (not sure if this is Apple's mistake of the carrier who stored the info in the SIM)! So i had to do a translational phase to resolve the incorrect ISO's. The following is the list i have got to so far (will keep updating it once i get new incorrect iso's):
Country: ISO I get Expected ISO
---------- ---------- -------------
UK uk gb
Japan ja jp
Cheers
AF
UK was reserved by the the United Kingdom (and is an an appendix to the standard) so that's a grey area ;)
JA should be Jamacia - why do you expect this to be Japan?
Info from here : http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
i am getting product price in multiple currency. here is a sample data
CurrencyName CurrencySymbol Pirce
"USD", "$" 1234.5
"EUR", "€" 12340.5
"GBP", "£" 123.4
"CHF", "CHF" 12345.0
so i want to format available currency based on type not based iPad/iPhone local format.
for example
$1234.50
1.234,50€
and also i want to display all at a same time.
thanks.
That means you want to show it in different localizations. Like the Euros in French or German (with decimal comma) and the CHF in Swiss (with decimal point and probably and apostrophe for separating the thousands).
I would map the currency to a specific localization and the feed it to the nsnumberformatter.
I am localizing my app for Denmark. I have the Localizable.Strings and the XIBs translated into Danish.
On iPhone a user can
Set the 'Region Format' to 'Denmark'
but keep the language 'English'
Set the 'Region Format' to any English-speaking country but keep
the language 'Dansk'
Set the 'Region Format' to 'Denmark' and language 'Dansk'
My question is: for any of the above settings should the app show the 'Danish' version (which for my App will mean all text in UI and the database to be in Danish.) or should the 'Danish' version only come when user sets the language to 'Dansk'?
This is a great question.
The real issue it comes down to is, in Apple's opinion, as they did it, does NSLocalizedString tend to favour the 'Region Format' or the 'language' setting?
I have never been able to find a clear answer on this, I just let NSLocalizedString decide.
(Purely FWIW, I think follow the "language" setting.)
It's possible the following code snippets could help you.
// to ("usually") get the preferred language FROM THE SET WHICH we supplied in bundle
// [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]
// to ("often") get the preferred language REGARDLESS OF what we supplied
// [ [NSBundle preferredLocalizationsFromArray:[NSLocale ISOCountryCodes]] objectAtIndex:0]
// to ("fairly reliably") get the user's chosen language setting...
// [ [NSLocale preferredLanguages] objectAtIndex:0]
It may not help, but I hope it helps.
Languages and locales are treated differently by Cocoa, because they are independent concepts. NSLocalizedString() will obey the current language setting of the OS, where things like dates, times, and numbers are affected by the locale setting.
Why locales are handled separately from languages can be found in the Locales Programming Guide:
When you display data to a user it
should be formatted according to the
conventions of the user’s native
country, region, or culture.
Conversely, when users enter data,
they may do so according to their own
customs or preferences. Locale objects
are used to provide information
required to localize the presentation
or interpretation of data. This
information can include decimal
separators, date formats, and units of
measurement, as well as language and
region information.
For example, by convention in the
United States “7/4/76” represents the
Bicentennial of the Declaration of
Independence. However, in Great
Britain, it represents the “7th of
April, 1976”; in Thailand using the
Thai Traditional Calendar it might
represent “April 7th, 2519”; and in
France it represents “7 avril 1976”.
To take a more subtle example, in the
United States“12.125” represents the
decimal number twelve and one eighth,
whereas in Germany it represents
twelve thousand one hundred and
twenty-five.
In the example given there, you might have a user who prefers to use English as their primary language, yet who lives in Germany and is used to a comma as a decimal separator, not a period.
The Internationalization Programming Topics guide has a lengthy discussion of all the issues involved and how to deal with them.