I am generating an iOS app via some tools. No need to concern about them, I have to do things that way.
Localization
The app is generated just fine, however I need to have the app be available for a certain set of languages. My app is actually a cross-platform app, and i am handling translation at JavaScript level. So my app actually picks the proper strings.
I just need to have my app be recognized in the Store as supporting those languages
Manual approach
I used to handle this by automatically generating language folders in Resources. So my automation scripts, would basically take the list of supported languages (say it, en and fr) and generate the following folders and files in my project:
MyApp
|
+-MyApp-Info.plist
+-Resources
|
+-en_US
|
+-Localizable.strings
+-it_IT
|
+-Localizable.strings
+-fr_FR
|
+-Localizable.strings
And Localizable.strings is just a placeholder file with a C-style comment in it.
Not working anymore
This did the trick so far, but now it is not really working anymore. The store recognizes my app to be only an English app, it does not list French and Italian anymore.
I am targeting iOS 8.0+ and developing on latest version of XCode.
How can I fix this?
Try renaming the localization folders so they have the ".lproj" suffix. Use the naming scheme as defined in the Apple Internationalization and Localization Guide under Managing Strings Files Yourself.
I would also add at least one string resource in the Localizable.strings file for at least one of the languages. At least one localized string resource may be needed to flip the bits and mark the app as supporting the additional languages.
Related
I'm developing an iOS app with localizations for different languages. For example lt.lproj, et.lproj, lv.lproj directories. And now I need to create translation files for specific region so created directories lt-RU.lproj, et-RU.lproj and lv-RU.lproj (Xcode named automatically). Everything working as expected, but when trying to upload an update I get an email warning
Unrecognized Locale -
The directory located at ( 'Payload/.../lt-RU.lproj' ) has an
unrecognized locale name. Refer to the Language and Locale Designations
guide for more information on naming your language-specific
directories.
After you’ve corrected the issues, you can use Xcode or Application
Loader to upload a new binary to iTunes Connect.
I have read apple Internationalization and Localization Guide and don't understand whats wrong in my language-specific directory names. May be use underscore separator?
My question was little bit wrong, because I need to change language not region for different countries. My project contains 3 targets for different counties so to add Russian translations I decided to create 3 directories containing ru.lproj and target needed app.
Using Xcode 7's localization export workflow, I can export to Xliff, which can be provided to translators, who will give back a translated version, which we import again.
However, how do I generate one for the original development language?
I want to do this so that I don't have to maintain my development language strings files manually by hand.
Here is the scenario:
I start with no strings file in my project, just Swift code which uses the NSLocalizedString
static let something = NSLocalizedString("something.hello", tableName: "MyStuff", value: "Hello world!", comment: "some comment")
From the project settings, I choose Editor -> Export for Localization. Because I have no existing strings files, when I export, there are no options. Just a "save as" prompt.
This will perform an Xliff export from the original source code. (Same as when you choose "Include: Development Language only" from the prompt when other localizations already present). The Xliff looks like this, with only <source> tags, and no <target> tags.
<trans-unit id="something.hello">
<source>"Hello world!</source>
<note>some comment</note>
</trans-unit>
The Xliff file is modified by translators, and translated to simplified chinese
The translated Xliff file is re-imported into project via Xcode
This creates the MyStuff.strings file for simplified chinese
Problem - when I run the app, the app will use the chinese strings file, even when language is english, because an english file doesn't exist. It doesn't seem to use the default value anymore. This means I need an english strings file too.
How can I generate an english (the development language) version of the strings files through the import/export process? Xcode doesn't let me "export" in the original development language. So I can't re-import it to create the strings files.
Note on genstrings
In the documentation for Separating User-Facing Text from Your Code, it says "Alternatively, you can generate the development language strings files from NSLocalizedString macros directly, as described in Creating Strings Files for User-Facing Text in Your Code." , which tells you to use genstrings
However that genstrings no longer works for Swift when you specify the tableName.
It's my understanding from what I've seen on SO that multiple radars have been filed, but it seems Apple is no longer supporting it.
I've worked out the problem.
It's doesn't seem necessary to generate strings files in the development language. This must be why the capability doesn't exist in Xcode.
My problem was that the app didn't think that my development language (english) was supported, so it did further fallback, and ended up picking a language that my app was localized for (in this case, chinese).
By adding a file localized for english, and ensuring there is an en.lproj folder in the bundle, it infers my app is localized for english, and will correctly use the default values specified in the NSLocalizedString calls.
This means I don't need a seperate copy of the english strings files. Which is great, because I won't need to keep that up to date as the app changes. The source of truth is the Swift source code only.
This link was helpful:
How does iOS determine the language for my app
We have a legacy application for iOS translated to two languages. After checking the localization files we realized, that there are a lot of strings that are not really used in the application, though, we cannot be sure which ones.
Is there some way (maybe some utility) that can check objective-c project and localization files and check which strings re really in use and which are not so we can delete the from the localization files?
Thanks
You could use genstrings to generate a new strings file from your project and then use one of the string-files comparison/merge tools to find the differences.
I recently uploaded an app to the app store. During earlier stage it required to be supporting 5 Languages and I added the strings file for it. But retracted later with language support in current version need to be supported in English only. After successfully pushing the app, the iTunes is showing supported languages as English + 4 additional languages. Can I edit the settings to show support language only as English? Do I need to delete localizable strings for other languages and submit again?
Yes, it will pick localization support from project settings. As many languages one adds to that setting, that many strings files will be generated. I would suggest to use English in project settings and remove the other languages locations files.
Refer below image: in the Localizations section, there should be only those languages which app is going to support.
I'm developing an Iphone app that has to support different languages.
I saw that the language has to be set within my app and not within iphone settings. So, do I have to force the language instead to take the current one? I didn't find examples over the internet. All examples need the current language of the application. I would like that the user choose his language when the application starts, then I will set a cookie and (in a way that iI don't know) the app refers automatically to my .lproj folders with different languages.
This is not possible using the default localization mechanisms in iOS. By default, the system chooses the .lproj folder according to the user's system language and does the localization automatically if you have localized NIBs and use NSLocalizedString() etc..
If you really want to change that behavior and "override" the system language, you have to implement your own version of NSLocalizedString that manually accesses the strings file in the .lproj folder you want. Be aware though that NIBs don't use your custom NSLocalizedString function. So either don't use NIBs at all or do the localizing of the NIBs in code instead of using different NIBs.
Your question isn't really very clear. There is nothing saying that "the language has to be set within my app and not within iphone settings" — it is in fact quite the opposite!
Cocoa has a pretty neat localization system that is quite easy to use (grumbles something about rotten localization workflows). Here's the full skinny on it — basically, have files in lproj folders, then use the NSBundle resource APIs to locate them (NIB loading and other subsystems use it automatically, so you don't even have to do work there!).
IIRC, you want NSLocalizedStringFromTable.
You create a .strings file for each language: eg "EN.strings", "JP.strings", etc...
These files will be loadable from the default bundle with the table parameter to NSLocalizedStringFromTable.
When the user picks a language, you switch which table (.strings file) to load the strings from.
One problem tho is that iOS strings will still be localized to the user's settings, or to whatever you have your app localized to in the Info.plist. So you might end up with a mix of languages.
[[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:#"it",#"en", nil] forKey:#"AppleLanguages"];
then if the iPhone language is set to english, my iPhone app will works always with "it". the first of the array.