Use a different region notation than the system's region notation - ios

On iOS, an app can use a different language than the system language if the developer passes the NSLocale to the right instances, or else if the proper values are written to NSUserDefault's AppleLanguages key.
I don't seem to find a way to do this also for the region, the part that takes care of number formatting.
The use case here is that I want a UITextfield's DecimalPad keyboard to show a comma for a decimal no matter what the system's region is set to.
Is this possible?

You can use AppleLocale instead of AppleLanguages.
E.g. -AppleLocale nl_BE will set the locale to Dutch with region Belgium.

Related

iOS voiceOver/accessibility foreign words pronuncation

Some of the texts I assign to accessibilityLabel(s) in my iOS app contain "mixed language".
For example, in German the text would be "Bier und guter Sound". The word "Sound" spoken with German VoiceOver language doesn't make sense (it should say "saund", but sounds like "sund").
Is there a way to give voice over information about a word's language?
Yep, assign an attributed string to the accessibilityLabel (even though it is of type String, it will accept AttributedString), and use UIAccessibilitySpeechAttributeLanguage to set language information for parts of the string that differ from the UI language. E.g. in your case, you would set range (start=15, length=5) to have UIAccessibilitySpeechAttributeLanguage with value "en" (or try "en-US" or "en_US" if that does not work, not sure right now which one it will accept, it should be the BCP 47 language code according to the docs).
If you are using Swift, then its type safety will not allow you to assign an AttributedString to property accessibilityLabel of type String, you can work around this by using label.setValue(attributedString, forKey: "accessibilityLabel"). A bit of a hack (or workaround), but works.

How to tell voice over to read the full name of a state in iOS?

I have a label with the text "Berkeley, CA" and I want its voice over to read "Berkeley, California".
I noticed that when I have labels with zip code as well, such as "San Francisco, CA 94106" the voice over knows to convert CA to California automatically.
I know I can set the accessibilityLabel of the label to some text, but since the state comes as input I wonder if there is some way to tell voice over that this is a state without actually code the conversion from each state or country abbreviation to its full name.
Is there a way to tell voice over that this is an address? or is there a built-in way to convert state/country abbreviation to their full name?
To the best of my knowledge, you cannot control how VoiceOver on iOS pronounces such abbreviations, either through code or user preferences. Given that users have no say in the matter, it's fine to override the accessibilityLabel. You might find the NSLinguisticTagger class useful for recognizing user input requiring expansion. CLGeocoder can code an coordinate or address and provide expanded details, but the full state name is not among them.

Localization by Location or Region?

How can I make the localization independent on the OS settings?
For example, if the device language is en-US,
But I want the user to be able to set the app to work using Hebrew localization.
In my case – I have an app that in emergency cases the user (in Israel) need to call a number (101).
I made localization to hebrew & english for that app, & when the user is switching to english lang' the dial number & pic' is changing to 911,
But what if a user in Israel wants to use english lang' on his iphone? he doesn't need 911, he needs 101.
I thought maybe to create tableview with all the numbers rather than a specific number but the access to the numbers list will not be quick and easy for dialing because of the multiple numbers.
Is it possible to make localization by location or any other way for doing that?
I appreciate the help.
query NSLocale for the NSLocaleCountryCode. The values from [NSLocale currentLocale] do not depend on the language setting, they depend on the region settings.
These are the values for my currentLocale. Language is set to english and region is set to germany.
NSLocaleIdentifier : de_DE
NSLocaleLanguageCode : de
NSLocaleCountryCode : DE
preferredLanguages are:
en,
fr,
de,
ja,
[...]
more fanciness: use geolocation to figure out the actual location of the device. It's possible that your users travel outside of their country ;-)

UITextChecker is what dictionary?

Does anybody know what dictionary UITextChecker pulls from? I use it to verify that a word is in fact a valid word in an app. I have some questions from users about why specific words are available in other games (Boggle/Scrabble) but not in mine.
Examples: ai, qi, qat, xu, ae, tae, ait, ain, lav, aa, shh, za
I checked against /usr/share/dict/words and none of these words are in Websters Second International, so maybe UITextChecker uses this same source? They do show up in other dictionaries online (but this is really besides the point of the post).
Thanks for any insight!
UITextChecker may be using the same dictionary that UIReferenceLibraryViewController uses. In which case, you could use something like [UIReferenceLibraryViewController dictionaryHasDefinitionForTerm: #"term"] and if it returns true the word exists. I'm not sure how complete the built in dictionary is however.
I guess it uses the iPhone dictionary of the user, which depends on the current language/NSLocale the user is using (which is set in the "International" Settings on the iPhone). This is the behavior we observe when typing some text anywhere in the iPhone, words underlined in read (because detected by the internal UITextChecker) depends on the locale used.
If the user have activated multiple keyboards with different languages each (e.g. a French AZERTY keyboard and an US QWERTY keyboard) it depends obviously on the current language, namely the current keyboard active at this moment.
If you refer to the wordfeud dictionary... (that would be the only game I know those words from). They check their words from an online dictionary on their own server. Must be a list parsed from another spelling site or something.
I sometimes doubt the validity of some words though....

.NET Currency exponent ISO_4217

I'm developing something for international use. Wondering if anyone can shed any light on whether the CultureInfo class has support for finding currency exponents for particular countries, or whether I need to feed this data in at the database level.
I can't see any property that represents this at the minute, so if anyone knows definitively if it exists, before I look for it / buy it from ISO.
Currency Exponent is the minor units of the currency.
http://en.wikipedia.org/wiki/ISO_4217 - e.g. UK is "2"
Take a look at this blog post on getting CultureInfo for a region. Basically, Window and .NET know about the user's region but not their currency. A region implies a currency, but a country can have more than currency. For example, a person in Cambodia would more than likely want to enter and use USD than Riel. If possible, when capturing any currency amount in a multi-currency system you should capture the currency ISO code.
If you just want to make a quick guess, you can create a CultureInfo object and use it's NumberDecimalDigits property. The also creates a problem when countries switch currencies. For example, if Belarus joins the EU, then it's currency would change from BYR to EUR. It's currency symbol and exponent will be out of date.
I looked at this question and provided a solution which may or may not meet your needs here: http://www.codeproject.com/KB/recipes/MoneyTypeForCLR.aspx#CurrencyType
The short of it: I implemented the ISO spec as a custom type using the spec itself to generate the values. Obviously this would need to be regularly updated in production...

Resources