In the initial version of ready_for_i18n(Introduced here), We had an assumption that the locale of your project to be extracted is English, therefore the key in the dictionary file can be just come from the literal word. But there are also so many non-english local projects that need to be internationalized. So we come out an idea to introduce a simple key-text mapping mechanism. Still simply using one command of ready_for_i18n
and follow these steps to get you non-english project ready for i18n.
(Assuming you are in the app/views
directory of your rails project.)
ready_for_i18n . --nokey > cn.txt
to extract all text and label in your views.ready_for_i18n . . --keymap=cn.txt:en.txt > cn.yml
Then all your views will be replaced to an i18ned version and the generated cn.yml dictionary file will use the keys from en.txt and values from cn.txt.That is it. It is a bit more steps than extracting the English project, but still simple enough, right?
Besides, if you do not satisfied with the default simple key mapping for your English local project, you can also using this way to change you key mapping as your will.
The 0.3 version of ready_for_i18n also contain some bug fixes and the following enhancements:
ready_for_i18n
will not replace any of your view files but just generate an dictionary file to STDOUT. You can redirect this out to file as you want.--dot
options in the ready_for_i18n
command.Well, Hope this tool will help you in the coming year! Looking forward to your comments.
Comments