Over the holidays, I pondered on how I could make these scripts for slurping up localizable strings in RubyMotion projects easier for myself or other developers.
I then came up with the idea to make this a ruby gem! Introducing LocaMotion.
It currently has two commands: ‘slurp’ and ‘generate’
Let’s start with the one you might already be familiar with: calling ‘locamotion generate’ from the command line will run the script from last post. That is, it looks at the strings in the English localizable file and copies them into those of the other languages, should these not already contain said string.
The second command is called ‘locamotion slurp’. What this does is it looks into the app folder of a RubyMotion project and extracts every localized string in the SugarCube format. That is, for example:
Once locamotion finishes gathering up the localizable strings, it looks in the ‘resources/en.lproj/Localizable.strings’ file, and adds each string if it doesn’t exist yet in the localizable file. The script is as follows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
These two commands make setting myself up for localizing the strings in my RubyMotion apps a lot faster.
Creating the LocaMotion gem was also quite the learning experience! But that’s for another blog post. ‘Til then!