Is there a tool that will extract strings from my source code, and replace them with constant names so that I can auto-generate the strings file I need to translate?
Or do I need to search my project for #" and evaluate each string to see if it should be localized, and then move it by hand to a strings.h file?
I have read about two tools to help localization:
ibtool, to deal with xib files
genstrings to generate a strings table
As far as I know, both are included in Mac OSX, but I didn't use any of them.
Related
I am using this Hunsplell iOS Implementation.
And I want to create my custom dictionary and affix file with my choice of words.
I know how to create .dic files but I have no idea how to generate the affix file with .aff extension for that respective .dic file. Is there any tool or technique which I am not getting by googling it?
I am not sure this meets your needs, but in my case as the custom dictionary I was building was in English I just used the standard en_US.aff and renamed it to match my custom dictionary name.
I used this in an app I built and worked fine.
Best explanation I’ve seen around is at Chromium: https://sites.google.com/a/chromium.org/dev/developers/how-tos/editing-the-spell-checking-dictionaries
Looking at other popular dictionaries from OpenOffice will give you a sense of some more sophisticated ways to write .aff rules:
http://extensions.services.openoffice.org/dictionary
Most dictionaries there are under the GNU GPL.
AFAIK, .aff files are written, not necessarily generated so I’m not aware of any tools. The real difficulty is in the sheer volume of words in a given language, possible transformations, and morphological complexity of a language at hand.
Ok the solution which worked for me is in two parts:
Writing .aff file by your own is a pretty lengthy and difficult task. So if you want to create your own custom dictionary(provided it is not very complex and deep in lexical terms) just create an empty file in notepad and save it with .aff extension, it will work fine.
I came through this problem because I wanted to merge two different Hunspell Dictionaries with their .aff and .dic files. And I found a brilliant FREE Hunspell Merge tool which can merge Hunspell Dictionaries (both .aff and .dic files) generating combined .aff and .dic files.
So, in my project I have 10 languages, and 10 Localizable.strings files.
I just created Localizable.strings files, a file for each language. Now they contain "key" = "value" pairs, and both keys and values are in English (default language).
My languages are all translated and stay in Excel files.
The question is, how can I insert all my languages in those files faster than just copying each word manually or writing a script for that?
Maybe there is a existing tool for this already?
Thanks.
I found an easy way to compose localizable.strings files from Excel documents.
In the Excel document, in specific columns I insert " " = " " symbols. It's easy to do for all the words by dragging Excel cell down from the corner, so that it copies stuff from that cell to all the cells you drag it to. (sorry for messy explanation)
Thus the document contains the same symbols and words as localizable.strings does.
Than I just copy everything to the text file, remove tabs, change extension to .strings.
(no comments saved unfortunately).
EDIT:
You can copy the stuff from Excel to Sublime Text, then Find & Replace tabs if any. Copy resulted stuff into proper Xcode .string file.
One application that will really save you a lot of time by automating and streamlining localization procedure is Localization Suite. I do not know if they support importing from excel (to save you time transferring your string pairs) but it's free and seems like a complete solution.
I had an internal script at work for doing that tasks in iOS and Android, and I've just opensourced it as a Gem. You can take a look at it here: http://github.com/mrmans0n/localio
It can open spreadsheets from Google Drive and local Excel files as well, like requested.
You just would have to install the gem
gem install localio
And have a custom DSL file in your project directory, called Locfile, with the info referring to your project and the localization files. An example in your case, where an Excel file is used, could be as simple as:
platform :ios
source :xls, :path => 'YourExcelFileGoesInHere.xls'
output_path 'Resources/Localizables/'
The .xls file should have a certain format, that probably is very similar to what you have right now. You just have to clone the contents of this one and fill it with your translations: https://docs.google.com/spreadsheet/ccc?key=0AmX_w4-5HkOgdFFoZ19iSUlRSERnQTJ4NVZiblo2UXc
Hope this helps.
Here are the steps i followed:
change the extension of .strings to .txt on windows
open excel and go to File > Open
Choose the file to open. This should present an import wizard
Follow the steps and specify the delimiting character as =
You're done
I'm using NSLocalizedString() for all localization stuff. The project is very big. We support many languages. Is there a way that I can easily extract strings that are not in the Localizable.strings but were wrapped with NSLocalizedString.
Example.
Let's say I have somewhere in my code:
NSString *message = NSLocalizedString(#"Sample message");
But developer forgot to put this string in Localizable.strings files, so it won't be translated. Is there a way to extract untranslated strings from the source code?
Also, I don't want to use genstrings tool. I already have a very big NSLocalizable.strings files. genstrings tool generates a new one with all strings wrapped with NSLocalizedString removing all former translations, which I do not want. I just want to extract untranslated strings and NOT ALL the strings marked with NSLocalizedString().
Thanks,
Rafal
Check out the genstrings tool, that does exactly this.
EDIT:
Try merging the genstrings generatet strings file with your existing one using the FileMerge tool in XCode (XCode > Open Developer Tool).
Generate Localizable.strings from XCode project http://xcode.fabriziobernasconi.it/
I would like to do a task that is quite simple on other OS, but it is not so trivial on iOS. Namely, I want to create file and open it in Numbers.
I can preview the file with UIDocumentInteractionController and then offer it to user that he/she opens it.
THis seems to me quite a reasonable solution. However, I need to offer proper file format. I suppose CSV and XLS would be reasonable to implement and it would most probably work, but I would still like to do it in native Numbers format if possible. However, I can't find any info about this file format.
Basically, this task is about exporting data to another app and then working further with them.
I don't know of a library that can create native Numbers files. There are hoewever some libraries that allow creating XLS files. Since Numbers fully supports XLS, this is probably the way to go.
There is a comercial library available that might work on the iPhone (costs $200): http://www.libxl.com/
As for free XLS libraries, I only know xlwt, a Python module. You could set up a webservice that creates an XLS file for your app, using xlwt on the server side.
If you want to pass information to Numbers, you can probably also use CSV files. If you use CSV files, you must be aware of some things. There are two kinds of CSV files: the comma separated version (used in english speaking countries) and the semicolon separated (used in continental europe).
The comma separated CSV files look for example like this:
"ID","First Name","Last Name","Salary"
1,"John","Malkovich",3400.20
2,"Fred","Astaire",2000.60
The second kind of CSV files are semicolon separated and use a comma as decimal mark. They look like this:
"ID";"First Name";"Last Name";"Salary"
1;"John";"Malkovich";3400,20
2;"Fred";"Astaire";2000,60
On the Macintosh, Numbers expects a different format depending on the Region setting. If you have your Region set to the US, it will expect the first kind. If you choose Germany, it will expect the second kind.
I don't know what kind of files Numbers on the iPad expects.
Another alternative would be using copy and paste. Try to copy tab separated text into the clipboard.
I hope this may help you. I've contacted libxl team and they responded with the link to the demo version of their iPhone library: http://www.libxl.com/download/libxl-iphone.zip
I'm working on internationalizing an iPhone application, and I'm using ibtool to extract the string from my xib files so they can be translated by a localization house like so:
ibtool --generate-strings-file BlahBlahView.strings English.lproj/BlahBlahView.xib
The problem with this is that the .strings file I end up with contains all the strings contained in the xib when I really want the subset that I actually care about for i18n. Is there any best best practice for dealing with this? Ideally I'd like to be able to add some kind of annotation in interface builder to say either "This is localizable" or "This is not localizable" and have ibtool only output the localizable strings when I run it.
Thanks!
Edit: OK, let me expand the parameters a bit. The solution doesn't need to use ibtool only. Ibtool + some data in the xib + a shell script is fine. As long as it works!
Ibtool is extremely verbose in its string-files output and generates stirngs by object-id, instead of by unique source string. This type of output is extremely useful when you're trying to re-create interface builder or otherwise need extensive control over the objects in your xib files, but less so when you simply want to localize your software.
Matteo at Digitalwaters.net found a way to convert the output from ibtool to and from the format used by nibtool, its predecessor, which was less powerful, but a lot easier to use for localization. More info here.
I have re-purposed his scripts to streamline the localization of our Mac OS X app, and they work well for me. Good luck :)
I think you can automate this, but it'll take a few steps. You can extract arbitrary properties from your xib using ibtool, so maybe you could set the tag of the non-localizable items to a particular value (-1, for example), then extract the tags and use that to filter the strings file and remove the unwanted entries.
check out the man page for ibtool, in particular the -export option.
ibtool doesn't output entries for empty strings. So, for example, if you leave a UILabel's text empty, it won't be included in the output of ibtool --generate-strings-file. You can then set the text of the elements in the view controller.