translation 1.1.3 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81a04ebcdf1b01843182685b2a8049e957407262
4
- data.tar.gz: 0fd561f17e328a59f29d1327b36520c18ee9506c
3
+ metadata.gz: f401074ed1430b32c5c99538ce08de94f54288f0
4
+ data.tar.gz: 95b51e1d7e1baf634bd38338d14f538e798dab88
5
5
  SHA512:
6
- metadata.gz: 3b93cedff15a6d98cbb61110c8dfd5ebb3c13305a40f650261795d76288da213ec6ee1fcc3b966c53f796605500b15ed8be2a03faab21515608b571dc90ac993
7
- data.tar.gz: 4de981b5049fd0e46aab74de8e42d82555dfcc42bfbbb1405b89c87a6aacb63f88723a217e28851a1fe6e5360c8f8c001a2c8504c044fb4c3de453381eb5d631
6
+ metadata.gz: 34e7fef03073d4a3e7725ee4a762920fb46aee17c86492c15f3c1f216d549ae42dcc8346c05a9ce61dc851bb38585e0708054b61c02e213879eeb0e92ade819d
7
+ data.tar.gz: 2957860ddb4b052a3f6d4c3fe92d536c3f39ed74c8134908903ec414db76eb89bccde8359e9c6916beddf1a16e94a6459d7fdad80371988b6bfeaf19f0f10161
data/README.md CHANGED
@@ -12,13 +12,24 @@ Add the gem to your project's Gemfile :
12
12
 
13
13
  Then :
14
14
 
15
- * Create a translation project from the UI.
15
+ * Create a translation project [from the UI](https://translation.io).
16
16
  * Copy the initializer into your Rails app (`config/initializers/translation.rb`)
17
17
 
18
+ The initializer looks like this :
19
+
20
+ TranslationIO.configure do |config|
21
+ config.api_key = 'some api key which is very long'
22
+ config.source_locale = 'en'
23
+ config.target_locales = ['fr', 'nl', 'de', 'es']
24
+ end
25
+
18
26
  And finish by inititalizing your translation project with :
19
27
 
20
28
  bundle exec rake translation:init
21
29
 
30
+ If you later need to add/remove target languages, please read our
31
+ [dedicated article](https://translation.io/blog/adding-target-languages) about that.
32
+
22
33
  ## Sync
23
34
 
24
35
  To send new translatable keys/strings and get new translations from Translation.io, simply run :
@@ -35,6 +46,69 @@ As the name says, this operation will also perform a sync at the same time.
35
46
 
36
47
  Warning : all keys that are not present in the current branch will be **permanently deleted both on Translation.io and in your app**.
37
48
 
49
+ ## Advanced Configuration Options
50
+
51
+ The `TranslationIO.configure` block in `config/initializers/translation.rb` can take several optional configuration options.
52
+
53
+
54
+
55
+ ### Ignored YAML keys
56
+
57
+ Sometimes you would like to ignore some YAML keys coming from gems or so.
58
+ You can use the `ignored_key_prefixes` for that.
59
+
60
+ For example :
61
+
62
+ TranslationIO.configure do |config|
63
+ ...
64
+
65
+ config.ignored_key_prefixes = [
66
+ 'number.human.',
67
+ 'admin.',
68
+ 'errors.messages.',
69
+ 'activerecord.errors.messages.',
70
+ 'will_paginate.',
71
+ 'helpers.page_entries_info.',
72
+ 'views.pagination.',
73
+ 'enumerize.visibility.'
74
+ ]
75
+ end
76
+
77
+ ### Custom localization key prefixes
78
+
79
+ Rails YAML files contain not only translation strings but also localization values (integers, arrays, booleans)
80
+ in the same place and that's bad. For example : date formats, number separators, default
81
+ currency or measure units, etc.
82
+
83
+ A translator is supposed to translate, not localize. That's not his role to choose how you want your dates or
84
+ numbers to be displayed, right ? Moreover, this special keys often contain special constructions (e.g.,
85
+ with percent signs or spaces) that he might break.
86
+
87
+ We think localization is part of the configuration of the app and it should not reach the translator UI at all.
88
+ That's why these localization keys are detected and separated on a dedicated YAML file with Translation.io.
89
+
90
+ We automatically threat [known localization keys](lib/translation_io/yaml_entry.rb), but if you would like
91
+ to add some more, use the `localization_key_prefixes` option.
92
+
93
+ For example :
94
+
95
+ TranslationIO.configure do |config|
96
+ ...
97
+
98
+ config.localization_key_prefixes = ['my_gem.date.formats']
99
+ end
100
+
101
+ ### Paths where locales are stored (not recommended)
102
+
103
+ You can specify where your GetText and YAML files are on disk :
104
+
105
+ TranslationIO.configure do |config|
106
+ ...
107
+
108
+ config.locales_path = 'some/path' # defaults to config/locales/gettext
109
+ config.yaml_locales_path = 'some/path' # defaults to config/locales
110
+ end
111
+
38
112
  ## Tests
39
113
 
40
114
  To run the specs :
@@ -26,8 +26,8 @@ module I18n
26
26
  class Config
27
27
  def locale=(locale)
28
28
  I18n.enforce_available_locales!(locale) if I18n.respond_to?(:enforce_available_locales!)
29
- @locale = locale.to_sym rescue nil
30
- GetText.locale = locale.to_s.gsub('-', '_').to_sym
29
+ @locale = locale.to_sym rescue nil
30
+ GetText.set_current_locale(locale.to_s.gsub('-', '_').to_sym)
31
31
  end
32
32
  end
33
33
  end
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.1.3
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aurelien Malisart
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-31 00:00:00.000000000 Z
12
+ date: 2015-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gettext