Zmeygo Syncronizer
Zmeygo syncronizer is a convinient tool to interface with zmeygo.com service. Zmeygo service helps you to manage internationalization data of your rails applications.
Install
Add to Gemfile of your rails project
gem 'zmeygo'
After that run
bundle install
This will generate ./script/zmeygo_sync and ./config/zmeygo_sync.yml
Usage
Configuration
Every time you will run zg command it will check for configutation file .zmeygo/config.yml in your home folder. To generate a template for config file run command
zg init
Then go and edit ~/.zmeygo/config.yml. In config file add correct values for
-
api_token - you can see your api_token in your user profile in zmeygo.com
-
default_project - One user will have associated more the one project. Zmeygo client right now can work only with one of them - default project. When you will run zg command to push keys on the server, they will be pushed automatically to default project. Right now there is no other way to specify other project.
-
locale_dir - this is place where zg client will download all pulled locale files from the server
Below is an example of ~/.zmego/config.yml file:
→ cat ~/.zmeygo/config.yml
# Configuration file for zmeygo
#
defaults: &defaults
server: http://zmeygo.com
api_token: 4e02abc123ef7e3528001231
default_project: my_proj
locale_dir: /home/john/rails_projects/my_proj/config/locales
development:
<<: *defaults
production:
<<: *defaults
Check server connection
In order to check server connectivity run command
zg ping
If you don’t have connection to the server, then most probably you are behind proxy (like me in the office). Setup environment variable $http_proxy or/and $https_proxy and smart zg will detect and use it. If that didn’t work like ISP support says **check if you have plugged internet cable** :D
It will display OK if you can connect to server. Now you are ready for real action!
Pull data from server
One of two greatest thing that zmeygo client was designed for is to pull data from server. Command:
zg pull
This command will download locales files of default project (specified in config file) to location locale_dir also specified in configuration file. This command is a shortcut for downloading manually locale files. There will be downloaded one file per locale. Existing locale files will be overriden.
Push data to server
Second of the greatest thing that zmeygo client was designed for is to push data to the server. The command:
zg push
Will push all locally cached i18n key to the server. To list locally cached keys use command:
zg list cache
I18n keys are stored in cached by zmeygo gem included in Rails application. Next section describes this in detail.
Use zmeygo gem from Rails application
To make possible pushing of i18n keys to the zmeygo server, include zmeygo gem into your rails project with gem ‘zmeygo’ in Gemfile. Then in your development environment put
Zmeygo.configure
which will load configurations from ~/.zmeygo/config.yml file. Zmeygo gem adds custom exception handler to I18n gem, thus every missing translation exeption thrown by I18n will insert missing key into zmeygo local cache. This means that you just add as usual I18n.t call to the view, then while you are browsing your application views, missing keys will be collected by zmeygo locally. Here and there, run somewhere in command line:
zg push
This will push all cached key to zmeygo server. And voila, you can translate your keys to whatever locale you choose on the server.
Send all your questions to: [email protected]