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.
- checksums.yaml +4 -4
- data/README.md +11 -9
- data/lib/translation.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0d2f9ee1b57320b568bf17c4587f74a652ffe61c521d3fb1693d43d8ddbc67d
|
4
|
+
data.tar.gz: ce0293347ec5ade30b2faf5ee6d3698f7b1191895d4cdb6fb23f6c869d057ff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
[](LICENSE)
|
4
|
-
[](https://travis-ci.com/translation/rails)
|
4
|
+
[](https://app.travis-ci.com/github/translation/rails)
|
5
5
|
[](https://codeclimate.com/github/translation/rails/test_coverage)
|
6
6
|
[](https://rubygems.org/gems/translation)
|
7
7
|
[](https://rubygems.org/gems/translation)
|
@@ -225,10 +225,16 @@ Examples: `en-microsoft` or `fr-BE-custom`.
|
|
225
225
|
|
226
226
|
### Fallbacks
|
227
227
|
|
228
|
-
|
229
|
-
language
|
230
|
-
|
231
|
-
|
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.
|
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
|
12
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gettext
|