Giter VIP home page Giter VIP logo

i18n-docs's Introduction

i18n-docs

i18n-docs is a ruby gem that helps you to keep translations stored in Google Docs. This makes it easier for translators and project members to coordinate changes and updates. In addition, the standard features of Google Docs are super handy for this process: revision tracking, authorization, publishing, etc.

Although we use it with Google Docs, it could be used with any CSV file.

this gem is currently in use and tested with Rails 3.1. It probably works with other 3.x versions, but probably not 2.x at the moment.

Features:

  • download translations from multiple Google spreadsheets and store to YAML files
  • import/export YAML files with a Google Spreadsheet
  • check YAML files for missing translations (rake i18n:find_missing_keys)

Usage

Configuration

Add the GEM to your Rails project:

gem 'i18n-docs'

Create a configuration file in config/translations.yml:

files:
  navigation.yml: "https://docs.google.com/spreadsheet/pub?key=ab43...34f3&single=true&gid=0&output=csv"
  forms.yml: "https://docs.google.com/spreadsheet/pub?key=0Ap...XveWc&single=true&gid=0&output=csv"
  ... etc ...

Add Google OAuth credentials to your `config/translations.yml file:

google_drive_credentials:
  oauth:
    client_id: "YOUR_ID_GOES_HERE"
    client_secret: "YOUR_SECRET_GOES_HERE"

Let Rails know what locales you will be using. Add this to config/application.rb:

module Web
  class Application < Rails::Application
    # add yml path
    config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*', '*.yml').to_s]
    # locals to support:
    config.i18n.available_locales = [:en,:de,:it,:fr]
  end
end

This defines which languages and translation files to import from a Google Spreadsheet. The content of the Spreadsheet URL is stored to a file called e.g. example1.yml within folders config/locales/en and all other detected locales.

Rake Tasks

Following Rake tasks are added by the GEM to your Rails project:

  • rake i18n:export_translations Export all language files to CSV files (ENV 'locale' have to set for non-'en' locales else only files contained in 'en' folder are considered)
  • rake i18n:import_translations Download translations from Google Spreadsheet and save them to YAML files.
  • rake i18n:missing_keys Find and list translation keys that do not exist in all locales

Setup at Google Docs

FIXME THIS IS OUTDATED

  • At Google Docs, create a new spreadsheet for your translations. The first column is the translation key, the other columns are the languages: screenshot
  • use option File -> Publish To the Web screenshot
  • use get a link to generate a unique url that points to the CSV spreadsheet screenshot
  • From now on you should only update translations in Google Docs and run rake i18n:import_translations in the application to get changes. You can also export your

CHANGELOG

0.0.7-2

Use translations.yml configuration file for Google OAuth credentials.

0.0.7-1

Upgrade to OAuth before Google deprecation deadline.

0.0.4

Update docs, license. Push to Rubygems.org.

0.0.3

  • Open sourced: changed name and description.

0.0.2

  • removed loading of awesome_print from the rake task. It was breaking download

Credits/License

This gem is sponsored by local.ch. It is licensed under the MIT license. If you're a ruby developer and want to work with us in Switzerland, please check out our jobs page.

i18n-docs's People

Contributors

aaronchi avatar abcdea avatar antoineinsa avatar batiste avatar eduardschaeli avatar geku avatar gonzalocal avatar hiphapis avatar huerlisi avatar ivanjovanovic avatar kitop avatar lwe avatar somebox avatar tarix avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.