translation 1.28 → 1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -9
  3. data/lib/translation.rb +4 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1f78ea385869d502ec4daeca619a23dc864a895b82aa04b0fa427f46e4583ce
4
- data.tar.gz: 78bbe090c7c48ba0293668133d8bdf47c79086a5e9f8b1c2ab2659c5394ffc7e
3
+ metadata.gz: c0d2f9ee1b57320b568bf17c4587f74a652ffe61c521d3fb1693d43d8ddbc67d
4
+ data.tar.gz: ce0293347ec5ade30b2faf5ee6d3698f7b1191895d4cdb6fb23f6c869d057ff0
5
5
  SHA512:
6
- metadata.gz: 0a01235f81817cf33ffed15a30fff050d5728c4f458b7f1de98083e2070fee8e315a5cfee16018d1f48dc81994fb95a6f11d053467c3c9b4e3d24024e9a4eec6
7
- data.tar.gz: 48c1efc18235c41e058e65f10ea8649953753c27fde5cea66e8618546c6b976b2aef2a16aa29f624e821321b44545b9722315898e2c211df2205f61c8e6e9695
6
+ metadata.gz: a2e07deb5a081fd8a0d8892b1f1c866db455f7194f7e3047141fccc5e76691997cf475d2a60fe20ed9c43c467f0f950fa9692bf8614ecc7fa2a49a960ef5d8fd
7
+ data.tar.gz: d53909fdc6398034776f0bb3e682b4d7b26c7edd32e6003098bda6c866249ac79e4af4be27bab7fdd507484d4d96006e6ca112a59ee4269e4d3d7fdd1f96c40c
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # [Translation.io](https://translation.io) client for Ruby on Rails
2
2
 
3
3
  [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
4
- [![Build Status](https://travis-ci.com/translation/rails.svg?branch=master)](https://travis-ci.com/translation/rails)
4
+ [![Build Status](https://travis-ci.com/translation/rails.svg?branch=master)](https://app.travis-ci.com/github/translation/rails)
5
5
  [![Test Coverage](https://codeclimate.com/github/translation/rails/badges/coverage.svg)](https://codeclimate.com/github/translation/rails/test_coverage)
6
6
  [![Gem Version](https://badgen.net/rubygems/v/translation)](https://rubygems.org/gems/translation)
7
7
  [![Downloads](https://img.shields.io/gem/dt/translation.svg)](https://rubygems.org/gems/translation)
@@ -225,10 +225,16 @@ Examples: `en-microsoft` or `fr-BE-custom`.
225
225
 
226
226
  ### Fallbacks
227
227
 
228
- Using [I18n (YAML)](#i18n-yaml) syntax, fallbacks will work as expected for any regional or custom
229
- language. It means that if the `en-microsoft.example` key is missing,
230
- then it will fallback to `en.example`. So you only need to translate keys that
231
- are different from the main language.
228
+ If a translation is missing for a regional (`fr-BE`) or custom (`fr-microsoft`)
229
+ language, then it will fallback to the main language (`fr`).
230
+
231
+ Locale fallbacks will work as expected with both [I18n (YAML)](#i18n-yaml)
232
+ and [GetText](#gettext) syntaxes.
233
+
234
+ A good way to leverage this feature is to ignore sentences from a regional language
235
+ that would have the same translation as the main language (usually most of them).
236
+ It's way easier to maintain the project over time if only 10% of the regional sentences
237
+ need to be adapted.
232
238
 
233
239
  Note that fallbacks are chained, so `fr-BE-custom` will fallback to `fr-BE` that will
234
240
  fallback to `fr`.
@@ -237,10 +243,6 @@ Just make sure to add `config.i18n.fallbacks = true` to your `config/application
237
243
  You can find more information about this
238
244
  [here](https://guides.rubyonrails.org/configuring.html#configuring-i18n).
239
245
 
240
- Using [GetText](#gettext) syntax, it will only fallback to the source language.
241
- So either you create a fallback mechanism by yourself or you avoid fallbacking
242
- by translating everything in Translation.io for the regional or custom language.
243
-
244
246
  ## Change the current locale
245
247
 
246
248
  ### Globally
data/lib/translation.rb CHANGED
@@ -39,6 +39,10 @@ module TranslationIO
39
39
  GetText::TextDomainManager.cached = false
40
40
  end
41
41
 
42
+ # Set default GetText locale (last fallback) as config.source_locale instead of "en" (default)
43
+ gettext_locale = @config.source_locale.to_s.gsub('-', '_').to_sym
44
+ Locale.set_default(gettext_locale)
45
+
42
46
  # include is private until Ruby 2.1
43
47
  Proxy.send(:include, GetText)
44
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translation
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.28'
4
+ version: '1.29'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hoste
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-01-17 00:00:00.000000000 Z
12
+ date: 2022-02-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gettext