0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Translate for the locales configuration file
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

yaml-translator

yaml-translator is a gem that translates yaml format translation files into each language.
The translation method supports google translate api in built-in.

Gem Version Build Status Coverage Status Code Climate

Basic usage

The method of translating the language file is as follows.

dir = File.dirname(__FILE__)

translator = ::YamlTranslator.create(
  :google_translate,
  api_key: ENV['GOOGLE_TRANSLATE_API_KEY']
)

english_locale = translator.file("#{dir}/en.yml")
japanese_locale = english_locale.to(:ja)

p japanese_locale.to_s # convert to japanese locale yaml format
p japanese_locale.save_to(dir) # Write a ja.yml

german_locale = english_locale.to(:de)

p german_locale.to_s # convert to german locale yaml format
p german_locale.save_to(dir) # Write a de.yml

Translation of difference

The method of translating the difference is as follows.

dir = File.dirname(__FILE__)

translator = ::YamlTranslator.create(
  :google_translate,
  api_key: ENV['GOOGLE_TRANSLATE_API_KEY']
)

diff_locale = translator.file("/path/to/before/en.yml").diff("/path/to/after/en.yml")
diff_locale.to(:ja).save

translate into multiple languages

diff_locale = translator.file("/path/to/before/en.yml").diff("/path/to/after/en.yml")
diff_locale.all(%w(ja en)).each { |r| r.save }

Run the test

bundle install
rake spec