translation 1.19 → 1.20
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 +19 -12
- data/lib/translation_io/yaml_entry.rb +2 -2
- 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: 39f833e4f98c4424feca4172a7f70c3b9639f24df3aaaa8e873632a54a5bb290
|
4
|
+
data.tar.gz: c76f080ced71805a079f47f6475412f1a1f4b24574e6470e77aa0d924ffd4211
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40fb09a74db12309e1dc787cc9ced44874cbc96250d6eb62cafe6b8f63962557756560f70c64f33e0e520a12a87bff14809b04b8a86c593fe4c1f48363977272
|
7
|
+
data.tar.gz: 834e92a56f1d11c178905db2326e346f9108f3237bf83645a59605680344878f15a9c79d5d22295fa05804fc3374942b7999852848affb82dfa55c1f5057b5dc
|
data/README.md
CHANGED
@@ -204,20 +204,23 @@ Since you created a new project, the translation history and tags will unfortuna
|
|
204
204
|
|
205
205
|
### Custom Languages
|
206
206
|
|
207
|
-
|
208
|
-
|
209
|
-
|
207
|
+
A custom language is always derived from an existing language. It's useful if you want
|
208
|
+
to adapt some translations to another instance of your application, or to a specific
|
209
|
+
customer.
|
210
210
|
|
211
|
-
The structure of a custom language is
|
211
|
+
The structure of a custom language is: `existing language code` + `-` + `custom text`, where
|
212
|
+
`custom text` can only contain alphanumeric characters and `-`.
|
212
213
|
|
213
214
|
Examples: `en-microsoft` or `fr-BE-custom`.
|
214
215
|
|
215
|
-
Custom languages can be added like any other language
|
216
|
-
It means that if the `en-microsoft.some_key` is missing, then it will fallback to
|
217
|
-
`en.some_key`. So you only need to translate keys that should be customized.
|
216
|
+
Custom languages can be added and used like any other language.
|
218
217
|
|
219
|
-
|
220
|
-
|
218
|
+
Fallbacks work as expected. It means that if the `en-microsoft.some_key` is missing,
|
219
|
+
then it will fallback to `en.some_key`. So you only need to translate keys that
|
220
|
+
should be customized.
|
221
|
+
|
222
|
+
Note that fallback are chained, so `fr-BE-custom` will fallback to `fr-BE` that will
|
223
|
+
fallback to `fr`.
|
221
224
|
|
222
225
|
Using GetText syntax, it will only fallback to the source language. So either you
|
223
226
|
create a fallback mechanism by yourself or you avoid fallbacking
|
@@ -237,9 +240,12 @@ class ApplicationController < ActionController::Base
|
|
237
240
|
end
|
238
241
|
```
|
239
242
|
|
240
|
-
|
243
|
+
First time the user will connect, it will automatically set the locale extracted
|
244
|
+
from the user's browser `HTTP_ACCEPT_LANGUAGE` value, and keep it in the session between
|
245
|
+
requests.
|
241
246
|
|
242
|
-
Update the current locale by redirecting the user to https://yourdomain.com?locale=fr
|
247
|
+
Update the current locale by redirecting the user to https://yourdomain.com?locale=fr
|
248
|
+
or even https://yourdomain.com/fr if you scoped your routes like this:
|
243
249
|
|
244
250
|
```ruby
|
245
251
|
scope "/:locale", :constraints => { locale: /[a-z]{2}/ } do
|
@@ -247,7 +253,8 @@ scope "/:locale", :constraints => { locale: /[a-z]{2}/ } do
|
|
247
253
|
end
|
248
254
|
```
|
249
255
|
|
250
|
-
The `set_locale` code is [here](https://github.com/translation/rails/blob/master/lib/translation_io/controller.rb#L3),
|
256
|
+
The `set_locale` code is [here](https://github.com/translation/rails/blob/master/lib/translation_io/controller.rb#L3),
|
257
|
+
feel free to override it with your own locale management.
|
251
258
|
|
252
259
|
Don't forget to define your available locales with [I18n.available_locales](http://guides.rubyonrails.org/i18n.html#setup-the-rails-application-for-internationalization).
|
253
260
|
|
@@ -31,7 +31,7 @@ module TranslationIO
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def ignored?(key)
|
34
|
-
key.present? && ignored_key_prefixes.any? { |
|
34
|
+
key.present? && ignored_key_prefixes.any? { |prefix| key_without_locale(key).match(/^#{Regexp.escape(prefix)}\b/) != nil }
|
35
35
|
end
|
36
36
|
|
37
37
|
def localization?(key, value)
|
@@ -40,7 +40,7 @@ module TranslationIO
|
|
40
40
|
|
41
41
|
def localization_prefix?(key)
|
42
42
|
localization_key_prefixes.any? do |prefix|
|
43
|
-
key_without_locale(key).match(/^#{prefix}\b/) != nil
|
43
|
+
key_without_locale(key).match(/^#{Regexp.escape(prefix)}\b/) != nil
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
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.20'
|
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: 2019-
|
12
|
+
date: 2019-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gettext
|