Skip to content

Instantly share code, notes, and snippets.

@Polo2
Last active July 4, 2018 15:18
Show Gist options
  • Save Polo2/8b23e0d2c9902141c18d1e78551c17b7 to your computer and use it in GitHub Desktop.
Save Polo2/8b23e0d2c9902141c18d1e78551c17b7 to your computer and use it in GitHub Desktop.
Synchronization between localeapp.com and local project

Global process

After installation and configuration of the Ruby Gem Locale project on the rails, Locale allows to synchronize the project's translations in Localeapp.com, and the files from config/locales/ in your local project ... and vice versa!

It's very important to notice that trust source is translation stored on Localeapp.com

There are two main ways to manage synchronizations:

  • from terminal, using command lines of the gem localeapp
  • by refreshing browser where localhost's project is displayed (specific to Ruby on Rails projects)

From terminal

Using terminal, 5 commands are very useful to update your translations: add,rm, push, pull and update.

They each have different consequences on the localeapp.com project or locally, summarized in the diagram below by gray arrows.

  1. localeapp add create a translation (key and value) and sends it directly to localeapp.com, but it don't modify the local project.

  2. localeapp rm removes the translation's key (and associated content) on localeapp.com, but does not remove it from the local project either.

  3. localeapp push pushes a translation file or directory from local project to localeapp.com

  • It creates key if it doesn't exist on localeapp.com, and import corresponding value,
  • It update value of existing key on localeapp.com if it has been updated on local project,
  • It doesn't delete keys and corresponding values on localeapp.com if they have been deleted on your project (localeapp.com is the trust source)
  1. localeapp pull pulls all translations from localeapp.com.
  • It imports exactly every key and every value from localeapp.com, and create new yml files fro every locale. Consequently, every change stored only in the RoR project will be overwritten (localeapp.com is the trust source)
  1. localeapp update
  • It scans on localeapp.com if there are any changes to the translations (keys and values), and if so, imports only these keys and values.
  • Consequently, if value has been updated only on local project, this scan won't detect any change on localeapp.com, and not any value modification will be imported on your project.
  • Best way to save RoR modifications is to proceed first to localeapp push (indeed, localeapp.com is the trust source)

By refreshing browser (specific to Ruby on Rails / RoR projects !)

Localeapp allows two specific behaviors by refreshing browser, summarized in the diagram below with red arrows, who can be redefined with some "config.attributes":

  1. Modifications on localeapp.com:

By default, when a development environment page is refreshed, any validated translations will be sent to RoR project . This behavior can be modified in file config/initializers/localeapp.rb, with:

config.polling_environments = []
  1. Modifications on local RoR project:

By default, when a development environment page is refreshed, every new translation key will be sent to localeapp.com. Indeed, gem locale catch every Translation Missing Key, and send it to localeapp.com This behavior can be modified in file config/initializers/localeapp.rb, with:

config.sending_environments = []

These behaviors are specifics to Ruby on Rails project because gem localeapp use error "Translation Key Missing", raised by Ruby on Rails.

Display the source blob
Display the rendered blob
Raw
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment