localizer_rails 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d15b76bf8d085001ec59ea8a1c406ce3313b6489
4
- data.tar.gz: 7c07323d603aee4f3fb365438b563aa695b11c6f
3
+ metadata.gz: c3644371397c6f5017271befc6444cfc36d0dc8a
4
+ data.tar.gz: ac255a81643018c3f717358f684a8b7d60edd426
5
5
  SHA512:
6
- metadata.gz: bdd8269abba8b4bffe563a0d97ea26042a3ee13b46ef5cfb922622ea2065986c639861c122effbc85736eb3b1543d0ab9de9fa37c191f2ec84e140837534afd0
7
- data.tar.gz: e447afabd5902ec2f3ee1bb8dccfd93c95aa2c7e1208d06b9186d51bfad3f35e443ff473ff49f6a66c51639c8d3f1dfb16808d170acead7d5d4d07676bcb5cf0
6
+ metadata.gz: c3e2fc1803eda158cd2fcc0fe81bce79fc490dfc0acc88e93a4221d9d9fed0eb5406632386e8dd32d81313b1daec3ea6faa92691863d2335deb1f16ddee67b37
7
+ data.tar.gz: 3663a468b152fcc22304d04676a13e0e25402c38542d4345f703b7a67bf13b4a88f37a772180650699bcc16e8c8f0969a5981c0c071b3334936ccee099eb45c2
data/README.md CHANGED
@@ -4,7 +4,7 @@ Just some handy utilities to manage site localization, generator provided
4
4
 
5
5
  1. set/retrieve language if none selected
6
6
  2. build language menu (bootstrap 3+ compatible)
7
- 3. <i>[optional]</i> convenience partials and Kaminari pluralization patch (up to v0.16.3)
7
+ 3. _[optional]_ convenience partials and Kaminari pluralization patch (up to v0.16.3)
8
8
 
9
9
  Requirements
10
10
  ------------
@@ -12,16 +12,18 @@ Rails version: 4+
12
12
 
13
13
  **Gemfile**:
14
14
 
15
- gem 'localizer_rails', '0.1.0'
15
+ gem 'localizer_rails', '0.1.1'
16
16
  **Style**:
17
- <pre> @import 'localizer_rails/localizer_rails';</pre>
18
- &nbsp;&nbsp;&nbsp;&nbsp;OR
19
- <pre> require localizer_rails</pre>
17
+
18
+ @import 'localizer_rails/localizer_rails';
19
+ OR
20
+
21
+ require localizer_rails
20
22
 
21
23
 
22
24
  Description
23
25
  -----------
24
- ### **<i>set_loc</i>** method
26
+ ### **_set_loc_** method
25
27
 
26
28
  finds the best-match for `I18n.locale` through a cascading search:
27
29
 
@@ -34,12 +36,15 @@ finds the best-match for `I18n.locale` through a cascading search:
34
36
 
35
37
  and sets values accordingly (cookies, link_to, ...)
36
38
 
37
- 1. use in __<i>before_action</i>__:
38
- <pre> before_action LocalizerRails::SetLoc</pre>
39
+ 1. use in **_before_action_**:
40
+
41
+ <pre>before_action LocalizerRails::SetLoc</pre>
39
42
 
40
- 2. use in __<i>routes</i>__, too:
41
- <pre> scope ":locale", locale: /#{LocalizerRails.active_locales.join("|")}/ do ...<br/>
42
- ...<br/>
43
+ 2. use in **_routes_**, too:
44
+
45
+ <pre>
46
+ scope ":locale", locale: /#{LocalizerRails.active_locales.join("|")}/ do ...
47
+ ...
43
48
  match '*path', to: redirect { |p, req|
44
49
  Localizer.set_locale(req)
45
50
  if( ! (Localizer.active_locales.any? { |word| req.path.starts_with? ("/#{word}/") }) )
@@ -56,30 +61,30 @@ and sets values accordingly (cookies, link_to, ...)
56
61
  },
57
62
  via: [ :get, :post, :patch, :delete ],
58
63
  status: '301'
64
+ </pre>
59
65
 
60
-
61
- ### **<i>active_locales_map</i>** method
66
+ ### **_active_locales_map_** method
62
67
 
63
68
  builds an hash of locale key/value pairs useful to build a `locale_menu`
64
69
 
65
- <i>[optional]</i> override and edit `config/LocalizerRails/lang_countries.yml`
70
+ _[optional]_ override and edit `config/LocalizerRails/lang_countries.yml`
66
71
 
67
72
  <pre>
68
- :da:
69
- :lang_default: 'Danish'
70
- :lang_local: 'Dansk'
71
- :country_default: 'Denmark'
72
- :country_local: 'Danmark'
73
- :country_code: 'DK'
74
- :fo-FO:
75
- :lang_default: 'Faroese'
76
- :lang_local: 'Føroyskt'
77
- :country_default: 'Faroe Islands'
78
- :country_local: 'Føroyar'
79
- :country_code: 'FO'
73
+ :da:
74
+ :lang_default: 'Danish'
75
+ :lang_local: 'Dansk'
76
+ :country_default: 'Denmark'
77
+ :country_local: 'Danmark'
78
+ :country_code: 'DK'
79
+ :fo-FO:
80
+ :lang_default: 'Faroese'
81
+ :lang_local: 'Føroyskt'
82
+ :country_default: 'Faroe Islands'
83
+ :country_local: 'Føroyar'
84
+ :country_code: 'FO'
80
85
  </pre>
81
86
 
82
- <i>where</i>
87
+ _where_
83
88
 
84
89
  * __:lang_default__: language name in default language (ex.: english)
85
90
  * __:lang_local__: language name in local language/alphabet
@@ -90,69 +95,70 @@ xtra country specs, use if `locale_menu` lists countries instead of languages:
90
95
  * __:country_local__: country name in local language/alphabet
91
96
  * __:country_code__: country ISO code
92
97
 
93
- __<i>NOTE</i>__: languages will be listed ONLY if included in `i18n.available_locales`
98
+ **_NOTE_**: languages will be listed ONLY if included in `i18n.available_locales`
94
99
 
95
- <i>[optional]</i> edit __<i>LI structure</i>__ and attributes in
96
- `app/views/LocalizerRails/_item[.bootstrap].html.erb`
100
+ _[optional]_ edit **_LI structure_** and attributes in
101
+ <pre>app/views/LocalizerRails/_item[.bootstrap].html.erb</pre>
97
102
 
98
- <i>[optional]</i> edit __<i>LI elements</i>__ and their display order in
99
- `app/views/LocalizerRails/_elements.html.erb`
103
+ _[optional]_ edit **_LI elements_** and their display order in
104
+ <pre>app/views/LocalizerRails/_elements.html.erb</pre>
100
105
 
101
106
  __CONFIGURATION__
102
107
 
103
- <i>[optional]</i> override and edit `config/initializers/LocalizerRails/LocalizerRails_prefs.rb`
108
+ _[optional]_ override and edit `config/initializers/LocalizerRails/LocalizerRails_prefs.rb`
104
109
 
105
110
  <pre>
106
111
  LocalizerRails::Conf.configure do |conf|
107
112
  conf.variable_name = value
108
- ...</pre>
113
+ ...
114
+ </pre>
109
115
 
110
116
  __OPTIONS:__
111
117
 
112
- * __conf.merge_lang_countries_tables__ = (boolean)<br/>
118
+ * __conf.merge_lang_countries_tables__ (boolean)<br/>
113
119
  if a copy of the `lang_countries.yml` file is found in your application you can force the engine to use ONLY your file or the MERGED hash
114
120
  - the engine's file will be used if no override `lang_countries` file is found in your application
115
- - defaults to __<i>true</i>__ (= merge files if override file is found)
121
+ - defaults to **_true_** (= merge files if override file is found)
116
122
 
117
123
  * __conf.all_available_locales__ (boolean)<br/>
118
- - set to <i>true</i> if
124
+ - set to `true` if
119
125
  - you want to load all locales in `I18n.available_locales`
120
126
  - you have already selected a limited bunch of locale files to be loaded in `your config.i18n.available_locales = [:en,'es-CO', :de]`
121
- - set to <i>false</i> if you want to specify the locale files in the custom list below (`conf.active_locales`)
122
- - defaults to __<i>true</i>__
127
+ - set to `false` if you want to specify the locale files in the custom list below (`conf.active_locales`)
128
+ - defaults to **_true_**
123
129
 
124
- __<i>Hint:</i>__ install [rails-i18n] (https://github.com/svenfuchs/rails-i18n) to add pluralization rules and a bunch of translated language files.
130
+ **_Hint:_** install [rails-i18n] (https://github.com/svenfuchs/rails-i18n) to add pluralization rules and a bunch of translated language files.
125
131
 
126
132
 
127
133
  * __conf.active_locales__ (:sym)<br/>
128
134
  define which locales your application will use
129
135
  - locales not included in `I18n.available_locales` will be ignored
130
- - defaults to __<i>[I18n.default_locale]</i>__
136
+ - defaults to **_[I18n.default_locale]_**
131
137
 
132
- * __conf.country_downcase__ = (boolean)<br/>
138
+ * __conf.country_downcase__ (boolean)<br/>
133
139
  load locale files depending on your setup:
134
- - true = use browser's HTTP_ACCEPT_LANGUAGE format (en-us)
135
- - false = use ISO rules in your `[localefile].yml` (en-US) as in `rails-i18n` locale files
136
- - defaults to __<i>false</i>__
140
+ - `true` = use browser's HTTP_ACCEPT_LANGUAGE format (en-us)
141
+ - `false` = use ISO rules in your `[localefile].yml` (en-US) as in `rails-i18n` locale files
142
+ - defaults to **_false_**
137
143
 
138
- * __conf.display_local_language__ = (boolean)<br/>
144
+ * __conf.display_local_language__ (boolean)<br/>
139
145
  display menu language names in their own idiom and alphabet or always in the default site language:
140
- - true = 'Italiano', 'Español', 'Deutsch', ...
141
- - false = 'Italian', 'Spanish', 'German', ... (or whatever language your `config.i18n.default_locale` defaults to)
142
- - defaults to __<i>false</i>__
146
+ - `true` = 'Italiano', 'Español', 'Deutsch', ...
147
+ - `false` = 'Italian', 'Spanish', 'German', ... (or whatever language your `config.i18n.default_locale` defaults to)
148
+ - defaults to **_false_**
143
149
 
144
- * __conf.use_bootstrap__ = (boolean)<br/>
150
+ * __conf.use_bootstrap__ (boolean)<br/>
145
151
  use bootstrap-style in `locale_menu` (you need to include bootstrap-sass (or similar) in your gemfile and import it in your stylesheet), as opposed to this engine's provided style
146
- - defaults to __<i>false</i>__ (= use engine's style)
152
+ - defaults to **_false_** (= use engine's style)
147
153
 
148
- * __conf.cookie_expires__ = (Date | nil)<br/>
154
+ * __conf.cookie_expires__ (Date | nil)<br/>
149
155
  set a custom expiration date for the `:cookies[:locale]`
150
156
  - Date can be in the format 20.year.from_now.utc (same as cookies.permanent)
151
- - defaults to __<i>nil</i>__ (session length)
157
+ - defaults to **_nil_** (session length)
152
158
 
153
- * __conf.store_in_session__ = (boolean)<br/>
159
+ * __conf.store_in_session__ (boolean)<br/>
154
160
  store `I18n.locale` also in session?
155
- - defaults to __<i>false</i>__
161
+ - defaults to **_false_**
156
162
 
157
163
  ## Extras (optional)
158
164
 
@@ -161,12 +167,14 @@ store `I18n.locale` also in session?
161
167
  [Kaminari] (https://github.com/amatsuda/kaminari) (up to current v0.16.3) handles pluralization through <i>pluralize</i>.<br/>
162
168
  In case of localization with foreign languages (eventually with multiple plural forms, such as cyrillic) this method often outputs incorrect results.<br/>
163
169
  The generator installs an override for Kaminari's `ActionViewExtension#page_entries_info`, following a bright hint by <a href="https://github.com/Linuus" target="_blank">Linuus</a> found on <a href="https://github.com/amatsuda/kaminari/pull/309" target="_blank">GitHub</a> (see 'Credits' below).<br/>
164
- The patch uses model_name and AR's count.<br/>
165
- __<i>Note:</i>__ You need to install the [kaminari ~> 0.16] (https://github.com/amatsuda/kaminari) and [kaminari-i18n] (https://github.com/tigrish/kaminari-i18n) gems.
170
+ The patch uses model_name and AR's count.
171
+
172
+ **_Note:_** You need to install the [kaminari ~> 0.16] (https://github.com/amatsuda/kaminari) and [kaminari-i18n] (https://github.com/tigrish/kaminari-i18n) gems.
166
173
 
167
174
  ### **Bootstrap 3+ NAVBAR raw partial**
168
- The generator installs a raw partial with the code for a Bootstrap 3+ NAVBAR featuring the language menu, modify it to suit your needs.<br/>
169
- __<i>Note:</i>__ You need to install [bootstrap-sass] (https://github.com/twbs/bootstrap-sass) or a similar gem.
175
+ The generator installs a raw partial with the code for a Bootstrap 3+ NAVBAR featuring the language menu, modify it to suit your needs.
176
+
177
+ **_Note:_** You need to install [bootstrap-sass] (https://github.com/twbs/bootstrap-sass) or a similar gem.
170
178
 
171
179
  ### **dummy app**
172
180
  Type the following lines in your Terminal application to see a working example:
@@ -176,8 +184,9 @@ Type the following lines in your Terminal application to see a working example:
176
184
  $ cd path-to-your-dir/localizer_rails
177
185
  $ bundle install
178
186
  $ rails s
179
- Check out comments included in the code.<br/>
180
- __<i>Note:</i>__ to simulate the 'production' error handling remember to set `config.consider_all_requests_local` in `config/environments/development.rb` to `false`.
187
+ Check out comments included in the code.
188
+
189
+ **_Note:_** to simulate the 'production' error handling remember to set `config.consider_all_requests_local` in `config/environments/development.rb` to `false`.
181
190
 
182
191
 
183
192
  ## Credits
@@ -186,6 +195,7 @@ Thanks to [Linuus](https://github.com/Linuus) for suggesting a viable way to pat
186
195
 
187
196
  ## Copyright
188
197
 
189
- Copyright (c) 2015 by [Giovanni Bellono](mailto://giovanni.bellono@gmail.com)<br>
198
+ Copyright (c) 2015 by [Giovanni Bellono](mailto://giovanni.bellono@gmail.com)
199
+
190
200
  See [LICENSE](https://github.com/gbellono/localizer_rails/blob/master/MIT-LICENSE) for details.
191
201
 
@@ -1,3 +1,3 @@
1
1
  module LocalizerRails
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localizer_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - giovanni bellono
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-26 00:00:00.000000000 Z
11
+ date: 2015-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.7'
41
- description: before_action method to set cascading best-match I18n.locale and method
42
- to build the locale_menu
41
+ description: Rails engine - sets I18n.locale through a best-match cascading search
42
+ and builds locale_menu (Bootstrap 3+ supported).
43
43
  email:
44
44
  - giovanni.bellono@gmail.com
45
45
  executables: []
@@ -327,5 +327,6 @@ rubyforge_project:
327
327
  rubygems_version: 2.4.5
328
328
  signing_key:
329
329
  specification_version: 4
330
- summary: Rails engine - set best-match I18n.locale and build locale_menu
330
+ summary: Rails engine - sets best-match I18n.locale and builds locale_menu (Bootstrap
331
+ 3+ supported).
331
332
  test_files: []