I created a View-Based project in Xcode, but I find no Localizeable.strings file for doing my localization. Must I run genstrings first to create this? Or did I do something wrong?
You need to declare all your localizable text with NSLocalizedString before running genstrings will produce anything useful.
I would recommend declaring all your text definitions with NSLocalizedString instead of inside Interface Builder XIBs as it is easier to get a text file translated than a XIB file.
Just make sure to allow 50% more space than you need for your English strings, as English is generally more concise.
Yes, genstrings creates the Localizeable.strings file. You can run it from the command line like this:
genstrings Classes/*.m
I found this tutorial to be helpful.
Indeed, you must run generate strings,
ibtool --generate-strings-file Example.strings en.lpoj/Example.xib
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.
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/
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.
I've gone trough my source files and updated all my strings using the NSLocalizedString() macro. Now because I have a lot of strings that come up across multiple source files , I decided to place a large amount of the strings in a header file called "LocalizedStringDefinitions.h" using the #define directive. So for example each line looks like this,
#define kLocalizedSTRINGNAME NSLocalizedString(#"STRINGNAME", #"Comment")
I just ran the genstrings command in terminal and the Localizable.strings file that was created contained only the localized strings that were directly placed in my code and none of the #defined ones. I have around 100 lines of #defined strings which I do not want to place back in my code especially because they appear across multiple files. How can I localize the strings?
I just realized how simple this is. If you look a the Terminal command genstrings *.m the .m part is clearly specifying to look through the implementation files. The file with the #define's is a header file (.h) so by using the command genstrings *.h I was able to generate the .strings file, or I could just change the name of the file with the definitions to "LocalizableStringDefinitions.m"
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.