compare two .strings file for finding missing keywords - ios

I have two .strings files in my application for supporting both persian and english language in my app.
For example I below files
en.strings:
"HELLO"="heloo";
"THANKS" = "thanks";
and another one
fa.strings:
"HELLO"="سلام";
Is there any tools in xcode that let me know that fa file do not contain THANKS keyword?

If you actually export and import localisation files, xCode will set them for you, as well as deleting the unused ones. No need for any tool.

Related

Xcode localization - how to create localized strings for development language

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

How to check which localization strings are really used in iOS Application?

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.

Listing missing language files

I have this project localized in several languages. Xcode shows the following list of files:
You can see that some languages have more files than others. Is there a way to list what files are missing on each language?
Yes, I know that I can use the parameter -NSShowNonLocalizedStrings YES as an argument passed on launch. I did that but that is not showing anything.
This is an indirect answer to your question; If you have that many .strings files you might want to organise them more structurally.
You could put all translatable strings in either a database or a spreadsheet and generate your source files from there. This may sound like more work but I think in the end it saves time.
See this other question about consolidating strings files. Or see my example spreadsheet to manage your localisations and spot missing texts more easily.

Xcode 6 - Base internationalization -exporting and importing en.xliff file

My app only supports english. I am using base internationalization (English- Development Language)
Steps I followed:
1. Separate out user-facing text using NSLocalizedString();
2. Using Genstrings command i have added Localizable.strings in base.lproj.
3. In Editor >> Export for Localization
4. Save en.xliff and provide to translator team for updating English content
5. While importing updated en.xliff file, i got below error.
Might be i doing in wrong way to export/import for English. Please suggest me the best approach for handling English content. (development language).
It is not obvious to me what you want to achieve: do you want to have your strings translated into some language other than English, or do you want to run your strings through an English linguistic review? For the first case the error message is pretty clear: check if the file element in your translated XLIFF file has a target-language attribute and add it if not. Details about this attribute can be found in the XLIFF spec here.
If adding this attribute is not enough you may also want to look at the answer to this previously asked question.
For the second case XLIFF is not really a good format.

Verifying what strings inside all localizable.strings files are obsolete

I have project that has several years. Over the time, the app has been modified, some classes added, some removed, etc. This app is localized in 5 languages.
Is there a way to scan all localizable.strings files and detect which strings inside these files are not used anymore in the project?
thanks.
Yes there is a way! Basically, you have to dump the .strings using commands and then compare them to acceptable versions. For more details, see here: iphone - cleaning the Localizable.strings

Resources