I used to work a lot in Archipel to make it fully localizable. I start from Nick's CPBundle+Localization work to be able to use CPLocalizedString().
Then I made a script based on some code I saw over the web to be able to incrementally localize the xib files (i.e. you don't loose your translation work when you re-exctact or re-inject the strings file in the XIB. This is so stupid from Apple btw..).
The translation works almost like basic Cocoa localization system.
In your code you use [myTextField setStringValue:CPLocalizedString(@"Hello World", @"hello")].
In your Resources folder, you put the xibs in Resources/en.lproj Resources/fr.lproj etc.
You define the current language in Info.plist using the CPBundleLocale key (in Archipel user can also decide to change the locale, but it needs a reload)
Then you can run this script I made, "localize", that should do all the work for you
https://github.com/primalmotion/Archipel/blob/master/ArchipelClient/localize
You basically go to the root folder project (or in a CPBundle root) and run
./localize (or ./localize --routine CustomLocalizableFunction)
It will:
- Look for each locale you support by parsing all your Resources/*.lproj then for each one:
- extract a string file in Localizable.strings.tmp according to your usage of your localization routine (CPLocalizedString by default)
- merge eventual already existing Localizable.strings with Localizable.strings.tmp
- look for xibs files
- extract the texts in nameOfTheXib.strings.tmp
- merge eventual already existing nameOfTheXib.strings with nameOfTheXib.strings.tmp
- reinject the new merged .strings file in xib
- generate the associated .xstrings files
This basically allows to "synchronize" the localization in both ways with a single command.
The resulting workflow is:
create a xib, add some labels etc -> localize -> edit the strings file -> localize -> add eventual new labels in xib -> localize -> etc.
or :
There is a typo in your text, edit the strings files -> localize.
This tool working in addition with XcodeCapp works just great. I use it now for months without any problem, I've never loose any translations.
I think with some small adaptations, it could be included in Cappuccino, making it officially support localized app.
What do you think?
--
Antoine Mercadal
--
Antoine Mercadal
> --
> You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J Development List" group.
> To post to this group, send email to objecti...@googlegroups.com.
> To unsubscribe from this group, send email to objectivej-de...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/objectivej-dev?hl=en.
>
Sounds great, I agree it should be rewritten in objj and made part of capp. Do you have a sample project I could test it with?
Regards,
Aparajita
www.aparajitaworld.com
"If you dare to fail, you are bound to succeed."
- Sri Chinmoy | www.srichinmoy.org
If you want to change the locale, just change it in Info.plist
If you want to reset it, remove everything in Resources/**.lproj that are not the xib files, then run localize.
It will recreate the strings file, then edit them, and rerun localize.
Also, I forgot to add, but using this tool, you *always* only work on the en.lproj. Other language are computed according to english.
http://dl.dropbox.com/u/7451919/LocalizationSample.zip
Cheers
--
Antoine Mercadal