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

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.

Related

Localization in Visual Basic 6

Is there a best way to localize the language settings? Say the situation is that you have already a working application in, say, French, and wanted to completely localize it in English.
So is there any way to easily localize the application while minimizing the impact on the application's code, I mean there mustn't be any major changes to the code itself but adding some would suffice. I've heard of using resource files in VB6 but it seems to have an issue with its fonts specially in Japanese characters, it throws out a garbage chars specially on labels. Now, what's the best way to change the charset of a application without applying too much changes in the applications code.
This application has a legacy code to I have to deal with it.
I use resource files, and replaced (almost) every string in the codebase and UI with an ID.
Whenever I display a string, I then call a single function that takes a string like {#1234} and loads string ID 1234 (using LoadString() and returns it.
For the UI, I enumerate every control on the form and pass the visible strings to the same function.
This meant a single call to Localise Me in the Load event of each form and a TranslateString("{#1234}", "name", Name) whenever I set/display something dynamically.
For the fonts, see this example from the Visual Basic Programmer's Guide. I call this on every control as part of the Localise method.
Don't forget that different fonts and languages take differing amounts of vertical space for the same text. The form layout also needs to be adjusted to take this into account, or reflow dynamically (align controls to longest label, shift down to allow for longer full width text, etc.)
Regarding the "while minimizing the impact on the application's code" part of the question, I would suggest encapsulating the resource-lookup-related features into a class of its own, exposing methods to fetch a string (by passing a culture specifier argument).
Then the bulk of the work is to convert your code from perhaps hard-coded strings to method calls to retrieve the appropriate strings. Implementing a variant of this answer: Implementing String.Format() in VB6, could greatly simplify your life if you also encapsulate the notion of 'culture' and introduce some cultureInfo argument to this StringFormat method's signature (perhaps call it StringFormatLocal).
The point being, if the current app isn't localized, it's probably not concerned about localization; localizing it means introducing a new concern so in order to affect legacy code as little as possible, you'll need to seek & destroy "magic strings" and "magic formats" all over the code base (and if your UI has hard-coded design-time captions and images, remove those as well), replacing them with calls to your localization API - keeping the localization concern separated.
I'd like to see another answer here with more details about storing, loading and especially using non-ANSI string resources...

adding languages for localization to iPhone - is that possible?

Compared to Android iPhone does not support many languages, even though the MAC seems to do so ( simply because I learned that the possibility of adding these languages in xCode is for MAC Apps and not for iOS).
Now I added the Localizable.strings file for languages that are not available in the language list of the iPhone settings for languages.
Is there a way using the standard approach like:
[onOffSC setTitle:NSLocalizedString(#"On","Off") forSegmentAtIndex:0];
if I just put a selection menu in my app ?
Otherwise I would have to add a special logic - lets say MYNSLocalizedString, checking first if the user wants to select a non supported language, getting this some other way (probably putting these translations into a NSDictionary) and otherwise calling the standard NSLocalizedString.
I guess I would have to put a language selection menu in the app anyways - but can the calls to NSLocalizedString be used or do I have to add a meta-method MYNSLocalizedString like mentioned?
Or is there any other good solution for this ?
Many thanks!
I think better would be to use the language which is set in Settings, instead of user selecting from menu. Refer to this tutorial might help you understand How Localization is done.
http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial
For localization of your iPhone app:
Use the approach described here...
http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial

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.

Setting language on iPhone application

I am working on an application which I am planning to release both in English and Spanish languages. With this I mean, I would like it to have two separate apps in the App Store, one being displayed with English title, and the other one with Spanish title (and each with contents in their respective language).
This means that the language in the app would be static, that is, that actually the app would not be internationalized, in the sense that the app would not display the language according to the user's locale settings, but according to either English or Spanish depending on the app bought.
I initially thought of using a constants file with constants strings of all the labels, button titles, etc. and having an identical separate project for each language, and changing this constants file on each project, but of course, this involves some hassle regarding maintenance.
The other approach I am thinking of, is actually performing the whole internationalization process (NSLocale, localization files, etc), and somewhat at the app startup skip the user's locale, and set either language programmatically (here, I would only need to know is how to skip such default i18n process to set a specific language. In this case, I would see the advantage of having only one local project, and the possibilty of setting the language on each build, for a different language app.
Could you please provide advice regarding which approach or best practice to follow?? Does this make sense, or is there another approach that I should follow instead in order to have the two separate, fixed language apps?
Thank you very much in advance!
Best regards
Duplicate: Best way to make an iPhone application multi-lingual
Short version: include a language file for each language. Apple'll take care of the rest - when the user changes their iPhone's language, your app will switch too (assuming a translation is available).
if you really want to have two separate apps in the App Store, you could do something like
Making multiple versions of an iPhone application
to have them both be built from a single Xcode project and make maintenance as easy as possible.
why not just have a single app version that includes both languages and automatically chooses the user's preferred language? if your goal is that bilingual people should pay you separately for two copies, then you'll need two separate apps like you suggest, I guess.
Localize your application for English and Spanish and put the following lines of code in main.m before the call to UIApplicationMain:
NSArray *languages = [NSArray arrayWithObject:#"es"];
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:#"AppleLanguages"];
[languages release];
where the language code is either "es" or en".
This will put the preferred language (es or en in your case) in the application's preferences (in the property list file ../your app's UUID/Library/Preferences/yourcompany's Internetadress.your app's name.plist) and override the language set in Settings.
This makes the app use the localized strings and use the localized XIBs. However, for some reason it does not work for localizing the app's icon and bundle display name. Adding a line for setting the locale (the key seems to be "AppleLocale") does not help. The current locale remains the one set in Settings, not the one set programmatically.
The line
[languages release];
shouldn't be there.
Localizing the strings and the XIBs suffices. Duplicate the target following http://www.iphonedevsdk.com/forum/iphone-sdk-development/8036-lite-game-duplicate-xcode-project.html and set Icon file and Bundle display name in the copy's plist file.