Is it possible to add localization to pre-compiled framework? - ios

I'm using a binary framework in my iOS project. This project is only available in english, but I would like to localize it. Assuming the original author used NSLocalizedString everywhere, is it possible to localize this framework "from the outside"?

It should be possible putting the translations in the Localizable.strings file. It should be easy to try...
If it does not work, sometimes libraries include a localizable strings file in a bundle. Then you should put your translations there.

Related

Do I need to enable Base Internationalization if I do all layouts programmatically?

I'm coding an iPhone/iPad App in Obj-C. From the beginning, I've coded all my layouts (I use Auto Layout) programmatically.
So, now I'm coming to where I want to Internationalize my App and I keep seeing that I need to turn on Base Internationalization.
But, when I read about Base Internationalization does, I read that Base Internationalization separates user-facing code from .storyboard and .xib files.
I have no .storyboard or .xib files. All my user-facing strings make use of NSLocalizedString.
My tentative conclusion is that I don't need to enable Base Internationalization but I want to put this out here as a question in case I'm missing something.
You do not need base internationalization if all your strings are already in your code.
You have basically already done the work that base internationalization would have done for you. It would have extracted text from the .xib and .storyboard files and created .strings files to then add the text back via NSLocalizedString.
You can avoid the Xcode warning by checking base internationalization, as there will be no resources to extract strings from. It simply creates a new language folder named Base.lproj from which any language is then derived.

Exporting xliff file on Xcode acting strangely

So I have a project that has been already localized in the past. But we created some new keys and we want to get them translated seperately.
Also in some languages some keys are missing, so I wanted to find those too. So what I did was to export the xliff files for translation using Xcode's export tool. I've using NSLocalizedString everywhere in my project, so theoretically that should have me covered.
But when I open an exported xliff file (let's say for Italian) I have the following problems:
The section in the xliff file for the localizable file is listed twice. The first time it's like this:
Translations for projectName/Localizable.strings
In this part of the xliff file ALL the translations are missing, even though the localizable file contains translated values for most of the keys.
Then the same localizable file is listed twice as:
Translations for projectName/en.lproj/Localizable.strings
In this case the keys all have their translated values, but if a key is missing from the English localizable file then it's also missing from here.
This is making it a huge pain for me because I'm just looking for the keys that are missing translations, and yet this way it means I have to go through the English list again to make sure no keys are missing.
This doesn't seem normal or practical to me. Anyone have any idea what I might be doing wrong?
The translated keys all work fine on the app itself by the way, tried it both on devices and the simulator.
Thank you for your help.
I do not use xliff exported files to manage my translations so I cannot give you an answer using this.
However, you may be able to solve your problem of finding missing localizations using Localization.strings files.
What you can do is use the genstrings command to generate a Localizable.strings file which will contain all the NSLocalizedString from your code.
To do this, you must pass all for your source files to genstrings.
For example, if you have a swift only project, you can just run this command at the root of your project:
find . -name "*.swift" | xargs genstrings
This will generate a Localizable.strings file you can then compare to your existing Localizable.strings file with a file compare tool like FileMerge. To make this effective, you may need to sort the keys in all the Localizable.strings files, I know a lot of editors can do this (SublimeText is one).
As you can see, the above solution is manual and will prove error prone if you need to do this more than once. In the past, I've automated this using a python script which did the following given the generated Localizable.strings and a localized strings file:
parse the Localizable.strings to get all the reference keys
parse a given localized strings file to get the localized keys
output the unused keys and the ones not translated
Hope this helps!

0 localized files seen in xcode for native development language

I'm working on a project where I need to add localize file of another language in xcode.
But when I try to add new language, it does not show me list of the base storyboards. Like given below
Also I'm seeing that 0 files localized for english - development language.
Anyone having any idea about it ?
you should localize files you need, then those files will be present in list of localizable resources

Localization in Xcode 5

I have around 1000 strings from storyboards and .m files which are converted for French Language. I need to add more strings to the same project. How do I update the strings file for my project?
Thanks
Usually people put all localization is in Localizable.strings file. If you want to add more string simply add "KEY" = "TRANSLATION"; to that file and use NSLocalizedString(key, comment) in your project where it is needed.
If you want to localize storyboard and/or nib files then you have to enable Base Internationalization in project settings.

Xcode 6 localization of plurals & genders with XLIFF

In Xcode 6 the XLIFF file format is now used for localization of strings. However, I need localise plurals and genders. How can I do this in Xcode 6?
As far as I understand, the XLIFF file now replaces the Localizable.strings file. In iOS 7/ OS X 10.9 we could localise plurals & genders by adding Localizable.stringsdict but this requires a Localizable.strings to exist. But since now there is no Localisable.strings file, how can I get the Localizable.stringsdict file to work?
As of Xcode 6, Apple uses XLIFF as the file format for exporting your project for localization. However, nothing has changed inside the project itself. You should continue using Localisable.strings and Localizable.stringsdict files to handle plurals per Apple's documentation on Handling Noun Plurals and Units of Measurement.
You can refer to this Objective-C project or this Swift project as examples of using strings dictionary files for plurals with Xcode 6.
A little more background on XLIFF and Xcode 6:
XLIFF (XML Localisation Interchange File Format) is an XML-based format created to standardize the way localizable data are passed between tools during a localization process. XLIFF was standardized by OASIS in 2002.
When you click on Editor -> Export for Localization in Xcode, it packages up all of your localizable assets into an XLIFF file that can be handled off to translators for localizing your application's strings. Since XLIFF is a standardized file format, this means translators and translation tools do not need to understand Apple's internal strings format.
Here's an example of the resulting XLIFF document produced by exporting the above referenced Swift project for localization. Now translators can use a translation platform or tool to translate your application's content and return to you a localized XLIFF file. You, as a developer, can then use Xcode's "Import Localizations" feature to import the translated XLIFF file into your project. This will cause Xcode to generate the necessary locale specific strings files from the imported XLIFF.
In short, nothing has changed in how you develop your project. What's been added in Xcode 6 is a new feature to simplify the localization process.
There's one caveat that I should mention though about plurals and exporting for localization. As of Xcode 6.1, Apple's export for localization feature still lacks a way to properly export plurals. This is most likely due to the current XLIFF spec having no standardized way of managing plural representations of a string. There's an open bug with Apple to address this issue.
XLIFF export has full support for plurals starting from Xcode 9
Xcode 9.0 Release Notes:
Added support to XLIFF for exporting and importing stringsdict files, including support for using the correct per-language plural variants. (16785521)

Resources