Generate a localized random NSString - ios

Apologies if this has already been asked, but some google search could not find it.
Does anyone please know of any method to generate a random string in iOS which respects the current language of the device?
The idea is that a quick 'unlock code' can be generated using the function; the trouble is that for languages other than English entering the code using the keypad will not be quick or intuitive, particularly if the user does not have the English keyboard enabled.

One easy option would be to generate your string using just the digits 0-9. Then present the standard number pad.
However, you should verify that the standard number pad actually shows the digits 0-9 for all locales. Good ones to verify would be Arabic, Chinese, and Japanese locales, I don't recall for sure what shows in those cases.

Related

Phonetic translation from Latin (English, German) to Arabic

I read a few papers about machine translation but did not understand them well.
The language models (in Google translate) use phonetics and machine learning as best as I can tell.
My question then becomes is it possible to convert an Arabic word that is phonetically spelled in English to translate the users intended Arabic word?
For instance the word 'Hadith' is an English phonetic of the Arabic word 'حديث'. Can I programmatically go from 'Hadith' to Arabic?
Thanks the Wiki article, there's an entire field of work in the area of Transliteration. There was a Google API for this that was deprecated in 2011 and moved to the Google Input Tools service.
The simplest answer is Buck Walter Transliteration but at first glace a 1:1 mapping doesn't seem like a good enough idea.
I am going to try to see if there's a way to hack the Google Input tools and call it even at CLI level because their online demo works very well

Android localization/translation

I have a keyboard app designed for Serbian language. My keys have labels based in Serbian cyrillic alphabet. My xml strings that are used for those labels are enclosed in <xliff:g></xliff:g> tags, but a certain provider on a certain type of a phone still translates these into a different language. Just in case, I also have my strings in language specific folders, but it still happens. Does anyone know if there is a way I could disable translating of all my strings any other way?
There are providers who can handle technical files translations,i.e. know what to translate in technical files. Also, some are available for you to manage the translations. OneSky is one of these platform and we also provide translation service.
See GIF of how placeholder validation works in OneSky
Disclaimer: I work in OneSky

Detect when to use a vs an

I have a service that allows user's (admins) to change the terminology the site uses. My designer wants me to use the format "A Group". The problem is, for some terminology, it should be "An" not "A".
Is there any way to reliably detect which to use? What about localization?
I can brute force it and get 90% of the way by checking the first letter for consonant vs vowel. That won't work for all words though. And that doesn't cover any language except English.
In my opinion you've got only 2 ways:
1- You need to check the first letter and process all the sentence by checking its letters to see if there is any non-English letters.
2- Provide a dictionary of English nouns then you can easily check your word to find if it needs an "a" or "an".
Although the "a versus an" issue is very specific, what you're describing here is a natural language processing issue. Essentially you are being asked to write code that generates a grammatically correct piece of text.
I think you should try to to explain the implications to the designer, especially if you end up localizing in other languages. Your time is probably better spent working on your app's business logic than on language processing.

How do you find the country code from NSLocale preferredLanguages?

I am in the process of developing an iOS application that needs to tell the server it communicates with the current language being used on the iPhone/iPad. I am currently using:
[[NSLocale preferredLanguages] objectAtIndex:0]
However because the App is a word based game in the case of English being used (en) this is not enough to go on, I need to be able to distinguish between en_GB and en_US (and potentially other languages in the future).
Currently I have two ways of doing this:
1) Use the currentLocale setting to get the current country code of the device and combine that with the preferredLanguage, however this is rather hacky.
2) Roll my own page to allow the user to change the language in App.
I am leaning towards option 2 but it will involve a fair chunk of work.
My question is, is there a better way of achieving this?
iOS does include British English (en_GB), as opposed to US English (en), so in this particular example you could rely on the user's iOS language setting alone. If the user has selected British English and your application includes it in its list of localizations, then you should see en_GB using your line of code.
But of course, if you wish to support a language that iOS doesn't itself expose, you're stuck with having to provide your own picker.

why can't I use secureTextEntry with a UTF-8 keyboard?

All,
I ran into this problem where for a UITextField that has secureTextEntry=YES, I cannot get any UTF-8 keyboards(Japanese, Arabic, etc.) to show, only non UTF-8 ones do(English, French, etc..). I did alot of searching on Google, on this site, and on Apple dev forums and see others with the same problem, but short of implementing my own UITextField, nobody seems to have a reasonable solution or an answer as to whether this is a bug or intended behavior.
And if this is intended behavior, why? Is there a standard, a white paper, SOMETHING someplace that I can look at and then point to when I go to my Product Manager and say we cannot support UTF-8 passwords?
THanks,
I was unable to find anything in Apple's documentation to explain why this should be the case, but after creating a test project it does indeed appear to be so. At a guess, I imagine secure text entry is disallowed for any language using composite characters because it would make character input difficult.
For instance, for Japanese input, should each kana character be hidden after it is typed? Or just kanji characters? If the latter, the length of time characters remain onscreen is long enough make secure input almost moot. Similarly for other languages using composite input methods.
This post includes code for manually implementing your own secure input behaviour.

Resources