Description
This gem is a subclass of the default I18n::Backend::Simple backend. It changes the way translations get loaded from files in order to support specifying the language code anywhere along the key path as opposed to the root key. This allows for all languages being defined next to each other, making it easier to translate between them.
i18n-backend-side_by_side alternatives and similar gems
Based on the "Internationalization" category.
Alternatively, view i18n-backend-side_by_side alternatives based on common mentions on social networks and blogs.
-
Globalize
Rails I18n de-facto standard library for ActiveRecord model/data translation. -
i18n-tasks
Manage translation and localization with static analysis, for Ruby i18n -
twitter-cldr-rb
Ruby implementation of the ICU (International Components for Unicode) that uses the Common Locale Data Repository to format dates, plurals, and more. -
Termit
Translations with speech synthesis in your terminal as a ruby gem -
FastGettext
Ruby GetText, but 12x faster + 530x less garbage + simple + clean namespace + threadsafe + extendable + multiple backends -
Locale
Send and retrieve your ruby i18n localizations to the Locale translation service -
Traco
Translatable columns for Ruby on Rails, stored in the model table itself.
Free Global Payroll designed for tech teams
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of i18n-backend-side_by_side or a related project?
README
i18n-backend-side_by_side
Tired of jumping between language files when translating keys? Stop jumping and have all the languages side by side.
This gem is a subclass of the default I18n::Backend::Simple
backend. It
changes the way translations get loaded from files in order to support
specifying the language code anywhere along the key path as opposed to the root
key. This allows for all languages being defined next to each other,
making it easier to translate between them.
How It Works
Let's assume your app supports English, Spanish, and German. You probably have one file per language:
locales/
view.en.yml
view.es.yml
view.de.yml
The files might look something like this (e.g. locales/en.yml
):
en:
view:
title: Welcome
inbox:
zero: You have no messages
one: You have one message
other: 'You have %{count} messages'
Whenever you have to add or modify a key, you have to edit all files. Also, you can't see all translations at once for a specific key. With this gem you can merge all the files and specify the translation for a key at that key:
_:
view:
title:
_en: Welcome
_es: Bienvenido
_de: Willkommen
inbox:
_en:
zero: You have no messages
one: You have one message
other: 'You have %{count} messages'
_es:
zero: No tiene mensajes
one: Tienes un mensaje
other: 'Tienes %{count} messajes'
_de:
zero: Du hast keine Nachrichten
one: Du hast eine Nachricht
other: 'Du hast %{count} Nachrichten'
Two things to note here:
The root key is an underscore. Omitting it results in the file being processed as a regular translation file, without support for side-by-side translations.
The language codes are prefixed with an underscore. This is needed in order to distinguish a language code key from a normal key. This also means that regular keys can't start with an underscore.
When the files get loaded, they're transformed on the fly to the original format by moving the language code to the beginning of the key path:
_.foo.bar._en => en.foo.bar
_.foo.bar._en-UK.abc.xyz => en-UK.foo.bar.abc.xyz
Installation
Add this line to your application's Gemfile:
gem 'i18n-backend-side_by_side'
Set up I18n
to use an instance of this backend:
I18n.backend = I18n::Backend::SideBySide.new
That's it. Continue using I18n
as you're used to. Happy translating!