i have an app that i have to localize. I am already localizing the nibs and some texts, i just have a doubt.
I need to pull a plist from the bundle which contains some texts, for the other languages i would have other plists. How can i accomplish the loading of them in a nice simple way.
My initial though is to have a text.plist , text-sp.plist , text-fr.plist and retrieving the current language then if language == english grab the text.plist, if language == spanish grab text-sp.plist and so on.
Is there a better way to do this?
I'd rather somehow make the .plist localizable and do something similar to what i do with texts using NSLocalizedString, but i am not sure how to use it in this case.
Sorry, just found the solution.
Just right click the .plist file and add new localizations like any other file. Then the OS handles which one to load according to the current locale settings.
I had to clean my targets in order for the changes to take effect, thats why i initially thought this was not working.
Related
I have localized my app and set up the Localization.string file.
Now that I want to add new strings, how do I make it so the corresponding files get the new strings automatically? Or do I have to manually add them?
Just not sure how I should organize my translators to be able to see that there are new strings to translate without having to just keep track of it manually.
I don't think there is an automatic way to manage them.
What we do is add a "//New" or "//Changed" to the end the english resource string, and our translators remove it when they add the other umpteen versions.
We actually put a \ tag with the date the item was added in order to let the translators know what is new and when it was added.
Another thing that we do is leverage a tool which auto translates our English localizable.strings files into target languages using Google's api service. While Google's translations aren't perfect, they are a great start for our translators. This really jumpstarted our translation process. Link to Apple Store app.
I can write at design time a setting bundle, but I need to make its content appear according to certain condition
can I do that , if yes any sample code, and where to put this code
Best regards
You can't dynamically create a Settings.bundle and write it out while your application is running on the iPhone. It needs to be included in the code signed application package.
What you can do, though, is customize your already created bundle's content & UI based on those certain conditions. E.G. different preferences load different strings or graphics.
I am new to iPhone App development (I am using XCode 4.2) and I was wondering if there is a way to translate all the strings , caption etc ... internally without having to translate them one by one .
an idea I have in mind is to use NSUserDefaults to save the language as a global variable and translate everything accordingly
another option is to make a look up table (is it even possible in Objective-C ?)
Thanks
You can use NSLocalizedString(#"<#key#>", #"<#comment#>") and one file (named Localizable.strings( per language. If you use the above function you can use the App Linguan (available on the Mac App Store) to generate the Localizable.strings files.
There is also a command line tool called genstrings that will create the file for you, but believe me that Linguan app will pay for itself in minutes.
You should always add a comment to allow a better translation and to provide context about the key.
You can read a step-by-step tutorial of the process here:
iPhone Localization Tutorial
Here's a high-level overview of the basics (the above tutorial has details):
1) Change all your coded strings to call: NSLocalizedString(#"My text", #"Context for the translator")
2) Export all your strings using the genstrings Terminal command.
3) This creates a text file called Localizable.strings with all your English (source) strings. It looks like this:
/* Context for the translator */
"My text" = "My text";
You send that file to the translators. They'll translate the right side like this: "My text" = "Mi texto";
4) You place each translated Localizable.strings file in its proper language folder: en.lproj, fr.lproj, es.lproj, etc.
When your app loads on the iPhone it will check the user's language settings. If the user has chosen French as the system language, the Localizable.strings inside your fr.lproj folder file will load. If there are any untranslated strings, it just defaults to English (or whatever your source language is) for those.
It's worth following the whole tutorial and note that the file/folder names have to be exact!
Look up the documentation for NSLocalizedString. And how to localize your .xib files (you make localized copies in English.lproj, de.lproj, fr.lproj, etc.).
All you will have to create are the files with the key-value pairs for each language you want to translate and name them accordingly i.e. _en, _fr and so on.
Then all you have to do is send a message to this method:
NSLocalizedString(#"myKey", nil)
And this will return the localized String, in whatever language the current iPhone configuration is.
I want to create a multi language application...I want user to select language at Runtime..not from settings.
How can I create It????
I know how to Localize the application based on language settings from I phone.
But I want it at runtime.
Please help me out.....
Thanks in advance...
You'll have to build your custom solution. For example for a simple .plist file you could have multiple .plist with different languages and depending on the language you set through your app. load a different .plist file.
It is quite some work to do for all the files, xibs and strings. I think you should reconsider doing that, why would people choose to change the language of just your app?
For example, the website URL and other stuff that wants to be linked at runtime with the app? I find that info.plist is a good place for that. But maybe it is not allowed or causes trouble...?
I think it is fine, but the common practice is to create an extra plist for these custom stuff.