How can I retrieve random words from the iPhone's dictionary? - iphone

Is there a way to retrieve words randomly from the built in Dictionary through the SDK?
I can provide my own list of words but using the built in Dictionary allows for easy localization.

Unfortunately this is one of the areas of the iPhone that applications have no access to.
However there are a number of free dictionaries available that you could use as an alternative. It's easy enough to convert a text-based file into ansqlite database which then makes it super easy to pick words at random.
And yes, as you point out localization is a problem with this :(

No access is provided to the Spell Checker.

The iPhone checks for spelling in UITextField objects.
Create a UITextField as a user input area.
Declare your interface to conform to the protocol.
Add any other delegates and then utilize UITextChecker
It has stuff like availableLanguages, hasLearnedWord, learnWord, unlearnWord
It also has guessesForWordRange:inString:language that returns a list of words that are possible valid replacements for a misspelled word.
For more information check out the iPhone OS Reference Library on UITextChecker
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITextChecker_Class/Reference/Reference.html
DougPan

Lexicontext (my library) provides such functionality for English words, although not from the built-in dictionary, but from a WordNet instance that is built into it.

Related

Can UITextChecker access Thesaurus instead of Dictionary?

I'm aware that UITextChecker is used to check for misspelled words, but can it be used to access the Thesaurus? For example, how can I check if a string is similar to another string. For example:
Is "Car" similar to "Vehicle".
Does iOS have a native thesaurus that can be used like the dictionary UITextChecker. If so how can it be accessed?
This isn't a post seeking recommendations, but rather asking if a native functionality exists within the iOS SDK, and if so, what can be used to access it (i.e UITextChcker).
The answer to this after no responses and my own research was: no. UITextChecker is just mainly used for spelling mistakes.
I've had to create my own Thesaurus and build my own class to check words against each other.

How to add an unsupported interface language to my iPhone app?

I have an iPhone app with interface languages in Toki Pona and Dothraki, which do not have ISO 639-3 codes. According to the ISO 639-3 standard, you can use the range qaa-qtz to represent languages for local use, which I have done (Toki Pona = qtp, Dothraki = qdt), but still get the warning from XCode "Unrecognized Locale".
It seems like I might be able to extend the main bundle class, but looking over the documentation, nothing seems to relate to adding non-ISO languages. I'm also aware of the text "If necessary, you can use a language or locale code that is not known to the NSBundle class or Core Foundation bundle functions. For example, you could create your own language designators for a language that is not yet listed in the ISO conventions or available as a language in Xcode." at the end of https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html
In any case, I mostly want to get rid of this warning. Any help would be greatly appreciated!
https://forums.swift.org/t/proposal-ns-locale-identifiers-etc-should-have-custom-types/9367/8
have a look at the above link.
Check if the languages are added as Localizations
I believe I have a solution however slightly complicated one. You would need to create a setting option within the app to use those made up languages and to load them manually from a file when a user sets them. For example, let's say your app consists of one label and the user sets the option to the made-up language you would call a method to set the language and the text on that label would update accordingly. I don't know whether this makes sense to you?? Basically, if the user uses the made-up languages that would override any system localization they have. It is doable it would just take time to implement it.

Translate (change) strings in Objective-C (specifically languages)

I have this game, that contains a lot of text as speech. I would like to give the users the option of changing the language of the game to their preferred tongue.. Can anyone point me to a resource or give me a starting point to achieve this? String look-up table perhaps?
Thanks,
Jack
See Localizing String Resources in Internationalization Programming Topics. iOS has a built-in system for this using NSLocalizedString() and related functions.
See also String Resources in the Resource Programming Guide.
NSLocalizedString is of use here. Here is a simple tutorial on localization.

Localization issue in iphone

I need to make an application in which the user can toggle between two languages on triggering a click event on a button.
The problem here is that I have seen examples in which, if we want to load our localized nib file, then we need to change the language from the settings options and we can get the proper nib file loaded according to language selected.
I want to do this within my application, meaning I don't want to go to the settings menu and change the language and then reload the application.
I just want the above effect within my application (that is, through a button click event the app should be able to toggle between two languages).
Is it possible, and does Apple allow it?
Nobody here can tell you whether Apple will allow it, but if your app is well designed and there's a good reason for this departure from the usual way of doing things, you've probably got a good shot.
There's nothing to prevent you from loading a nib file localized for a different region. I'd probably avoid trying to use Apple's automatic mechanism, though. Just name your nib files using some pattern and load the appropriate one.
If you want your life to easy, you will take advantage of the Localization built into the operating system. Otherwise, you will have write your own methods to load localized strings or nib files.
There is no reason for Apple to reject an app that shows localized text based on an in-app setting. I work to help developers localize apps and, although I don't suggest this approach, they have done it and I've never heard of a rejection from Apple.
What you won't be able to do is use Apple's built-in tools, which rely on the system settings to determine a user's language and push the text from a Localizable.strings file. But it honestly won't take you too long to implement a similar system yourself using functions akin to gettext.
You essentially need to implement the same basic logic as any localization system:
1) Surround your in-app texts in a function that will display the proper language based on the user's chosen settings
2) Export your source texts (probably English into file
3) Translate the English strings into each language in a separate file
The function you write can follow the lines of gettext, which has examples in many programming languages. If the settings is "French" grab the equivalent string from the French file. If the setting is English, just print the English.
You won't be able to use Apple's tools, but you CAN do it on your own and Apple won't really care as far as I know. However, if you choose to localize into an Apple-supported language, follow this app localization tutorial for iOS using the standard Localizable.strings method.

Is it possible to force localization to another language?

Can I pass an argument to NSLocalizedString to override the localized string and tell it what language to use so that the user can choose a language from a Settings menu?
How so?
We’ve done something similar, but the answer was to not use NSLocalizedString. Instead, since you know what language the user has selected, you just load the text for that language. You can store it in property lists, using Core Data or SQLite, etc.