Lock my iPhone app to a specific language (Localization) - iphone

I have an Xcode4 project where I have support for several languages (localization files) .. My text and xib files change correct when I change languange on my iPhone ..
My Question is;
Can I make a release to a specific languange, even if I have several localization files?
Force my app to use only one localization?
My idea would be to set a flag in the info.plist file like;
Localization = English (Lock my app to the enligsh language)

You can do this by deleting localized strings and nib files. I don't think you can lock your app to a particular language (If localization support is there for other language).

If the localized.lproj folders are in the bundle, iOS will use them. The easiest way would be to remove your localized resources folders from the bundle and build the app.
You could probably programmatically set code a workaround in your main.m class file, by stating only to use en.lproj but I can't imagine this will be either pretty or useful.
Side note: You can set your default project localisation in the Target > Info pane. Look for key: Localization native development region

Related

iOS App doesn't work in other language

My iOS-App was first German and English. As it was just a fault, I removed the English localization. Somehow if I change the language in the iOS Simulator to english not it loads the old storyboard that doesn't even exist anymore. I cleaned the folder and there is now only a base storyboard. Although I cleaned the Project the App is still crashing after start (because it's loading an old storyboard of prior App version (I removed english localization in 1.1, and now in 1.2 it still loads the 1.0 storyboard).
This is really weird, how can I achieve that the App ALWAYS uses the same storyboard, no matter which language? I already removed the english localization!
Thanks very much!
From my understanding based on a previous experience, if you are localizing an application you need to keep the English one. Because it will default to English if the device is not set in the language that you are supporting.
(Have you notice in the setting app how english is always the second choice and that you can't change the order like on the desktop to default to something else before english)
So if you are planning on supporting only 1 language remove all localization into your application. Because other wise it would default to a non-existing asset and crash.
That would be my best guest for a try.
Have you delete the application on your device after all those change and a clean up may be necessary. I've notice that file, (especially not code file) that get deleted have a tendency to lay around the executable.
And if you get file (1) b.xml and (2) fr.lproj/b.xml even if the device if in french the french one (2) won't get used. The system will see (1) first and think there is no localization for that file.
As for "losing" your German Xib. If you take a copy out of your de.lproj (and put that copy up a directory in the file system it should work)

Separate xcodeproj file for iPhone and iPad sharing resources

I am working on an iPhone application, latter to which i need to convert it into iPad application (Not universal)
I have seen somewhere a project that contains two separate xcodeproj file say
AppName_iphone.xcodeproj
AppName_ipad.xcodeproj
in single folder that are sharing common files, but opens as separate application when i double clicks *.xcodeproj files.
I goggled for doing same but i can't find good resources that shows how to do that.
Please suggest good way of doing same.
Thanks.
or try this i think that could help you http://developer.apple.com/library/ios/#featuredarticles/XcodeConcepts/Concept-Workspace.html

Adding localizable files to project on Xcode 4

I'm developing an App that needs Localization.
I've followed these steps:
I've created the es.lproj, it.lproj, en.lproj folders in the root of the project with finder.
I've created the Localizable.strings file in each folder with the key pair values corresponding to the target language.
I've imported with Add Files To option from Xcode.
When I test the App in the iphone simulator all works fine. I configure the iphone to any localizaed language and the app is translated properly.
But when I run the App in the device, only shows the strings in english.
I've made a test following these steps.
From Xcode 4 right button over Supporting Files Folder, New File.
Create Localizable.strings file
In file inspector, section Localization. I've added the rest of languages. Creating the file like a folder with all Localizable files in the tree.
In the root folder of the project, the xcode created a folder for each language.
After editing every file, I've executed in simulator and all works fine. I've tested in 3 different devices and the only language is English.
In the Project -> Info -> localization I've added every language.
In the Build Phases I've observed that only is referenced the Localizable.string file in the en.lproj folder. I've tried to add the rest of files, but only accepts one more Localizable file. I've tested in device with the "extra" added language but doesn't works.
Can someone help me please?
Thanks in advance.
Try this: Remove the app from the device, clean project, make sure that the files appear in Build Phases>Copy Bundle Resources and run again.
Are you sure you are testing properly on your device ? I just tried making a simple localization test, just a Hello world in different languages, and when i
I used Xcode 4 and followed the same steps as you. Changed my device language, reloaded the app, and there it was.
You might need to do a clean install in order for this to work. Do the clean install after you changed your device language to "something you haven't seen yet" ;]
Maybe this tutorial can help you : Localization Tutorial with XCode
Have you tried to delete the app from the device and then reinstalling?
EDIT: I have checked in a project of mine and the names I see are: English.lproj, French.lproj, etc.
Don't know if this could make a difference, but you could try it. Also, you can go to the app binary for the iPhone with the Finder and select Show package content to inspect its content and make sure the localization files are there This could help to pin down the problem...
If it can be run in the simulator ok, but the device has a problem with the localization, then the link provided here by Nils Munch has the answer. In troubleshooting it says "Unlike the iPhone simulator, the iPhone only recognizes strings files that are formatted UTF-16. Always test your localizations on the device, as the simulator and the device do not always behave the same way."
I think the problem here might be the file is UTF-8. The simulator can handle that but the device can't.

Whats the best way to create an iPhone and an iPad application simultaneously?

I have an iPhone app that I would like to port over to the iPad, but I would like to have as little duplication as possible.
How do people usually go about doing this?
In xcode can you have different targets for iPhone and iPad and perhaps do some pre-processor checks? Or is it best to simply have two separate projects altogether?
Note, Im NOT talking about running the iPhone app on the iPad, I mean creating a native 3.2 app...
EDIT
So it looks like creating a universal application is the way to go:
http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/StartingYourProject/StartingYourProject.html#//apple_ref/doc/uid/TP40009370-CH9-SW8
But what I still dont understand is how to select different NIB files based on your current deployment???
Thanks a lot
For minimal duplication, you can use one project, with 2 sets of .nib files, but one set of source code files which include run-time checks for the UIUserInterfaceIdiom differences.
If you want two (or more) apps instead of a Universal app, just create two targets containing only the appropriate .nib files, and #ifdef the run-time check results using a Preprocessor Macro define in each target's Build Settings to force iPhone or iPad idiom only.
The latest (3.2.3) Xcode auto-generates a Universal project which is a great starting point to see how to target iPad and iPhone in one Xcode project.
File > New Project > Window-based Application > Product : Universal

Is it possible to localize the app icon and Default.png?

Is it possible to localize the app icon and Default.png files? Do I just drop them in the respective language folders or must I do something else?
As per my comment, there's an answer elsewhere, but you can read more in the Internationalizing Your Application section of the iPhone Application Programming Guide. There's an example of how to structure your language files in your app bundle, for example.
The correct answer is that it is not possible to localize the app icon.
An iOS application should be internationalized and have a
language.lproj folder for each language it supports. In addition to
providing localized versions of your application’s custom resources,
you can also localize your application icons and launch images by
placing files with the same name in your language-specific project
directories. Even if you provide localized versions, however, you
should always include a default version of these files at the
top-level of your application bundle. The default version is used in
situations where a specific localization is not available. For more
information about localized resources, see “Localized Resources in
Bundles.”
https://developer.apple.com/library/ios/#documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html
Apple docs update/change frequently. This is the correct link at this point in time. Also, I haven't actually tried localizing the app icon/default images, but Apple says it works so why not :-)
This same question appears numerous times on stackoverflow.