localizer_rails 0.1.0
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +191 -0
- data/Rakefile +34 -0
- data/app/assets/images/flags/ad.png +0 -0
- data/app/assets/images/flags/ae.png +0 -0
- data/app/assets/images/flags/af.png +0 -0
- data/app/assets/images/flags/ag.png +0 -0
- data/app/assets/images/flags/ai.png +0 -0
- data/app/assets/images/flags/al.png +0 -0
- data/app/assets/images/flags/am.png +0 -0
- data/app/assets/images/flags/an.png +0 -0
- data/app/assets/images/flags/ao.png +0 -0
- data/app/assets/images/flags/ar.png +0 -0
- data/app/assets/images/flags/as.png +0 -0
- data/app/assets/images/flags/at.png +0 -0
- data/app/assets/images/flags/au.png +0 -0
- data/app/assets/images/flags/aw.png +0 -0
- data/app/assets/images/flags/ax.png +0 -0
- data/app/assets/images/flags/az.png +0 -0
- data/app/assets/images/flags/ba.png +0 -0
- data/app/assets/images/flags/bb.png +0 -0
- data/app/assets/images/flags/bd.png +0 -0
- data/app/assets/images/flags/be.png +0 -0
- data/app/assets/images/flags/bf.png +0 -0
- data/app/assets/images/flags/bg.png +0 -0
- data/app/assets/images/flags/bh.png +0 -0
- data/app/assets/images/flags/bi.png +0 -0
- data/app/assets/images/flags/bj.png +0 -0
- data/app/assets/images/flags/bm.png +0 -0
- data/app/assets/images/flags/bn.png +0 -0
- data/app/assets/images/flags/bo.png +0 -0
- data/app/assets/images/flags/br.png +0 -0
- data/app/assets/images/flags/bs.png +0 -0
- data/app/assets/images/flags/bt.png +0 -0
- data/app/assets/images/flags/bv.png +0 -0
- data/app/assets/images/flags/bw.png +0 -0
- data/app/assets/images/flags/by.png +0 -0
- data/app/assets/images/flags/bz.png +0 -0
- data/app/assets/images/flags/ca.png +0 -0
- data/app/assets/images/flags/cc.png +0 -0
- data/app/assets/images/flags/cd.png +0 -0
- data/app/assets/images/flags/cf.png +0 -0
- data/app/assets/images/flags/cg.png +0 -0
- data/app/assets/images/flags/ch.png +0 -0
- data/app/assets/images/flags/ci.png +0 -0
- data/app/assets/images/flags/ck.png +0 -0
- data/app/assets/images/flags/cl.png +0 -0
- data/app/assets/images/flags/cm.png +0 -0
- data/app/assets/images/flags/cn.png +0 -0
- data/app/assets/images/flags/co.png +0 -0
- data/app/assets/images/flags/cr.png +0 -0
- data/app/assets/images/flags/cs.png +0 -0
- data/app/assets/images/flags/cu.png +0 -0
- data/app/assets/images/flags/cv.png +0 -0
- data/app/assets/images/flags/cx.png +0 -0
- data/app/assets/images/flags/cy.png +0 -0
- data/app/assets/images/flags/cz.png +0 -0
- data/app/assets/images/flags/de.png +0 -0
- data/app/assets/images/flags/dj.png +0 -0
- data/app/assets/images/flags/dk.png +0 -0
- data/app/assets/images/flags/dm.png +0 -0
- data/app/assets/images/flags/do.png +0 -0
- data/app/assets/images/flags/dz.png +0 -0
- data/app/assets/images/flags/ec.png +0 -0
- data/app/assets/images/flags/ee.png +0 -0
- data/app/assets/images/flags/eg.png +0 -0
- data/app/assets/images/flags/eh.png +0 -0
- data/app/assets/images/flags/en.png +0 -0
- data/app/assets/images/flags/er.png +0 -0
- data/app/assets/images/flags/es.png +0 -0
- data/app/assets/images/flags/et.png +0 -0
- data/app/assets/images/flags/fam.png +0 -0
- data/app/assets/images/flags/fi.png +0 -0
- data/app/assets/images/flags/fj.png +0 -0
- data/app/assets/images/flags/fk.png +0 -0
- data/app/assets/images/flags/fm.png +0 -0
- data/app/assets/images/flags/fo.png +0 -0
- data/app/assets/images/flags/fr.png +0 -0
- data/app/assets/images/flags/ga.png +0 -0
- data/app/assets/images/flags/gb.png +0 -0
- data/app/assets/images/flags/gd.png +0 -0
- data/app/assets/images/flags/ge.png +0 -0
- data/app/assets/images/flags/gh.png +0 -0
- data/app/assets/images/flags/gi.png +0 -0
- data/app/assets/images/flags/gl.png +0 -0
- data/app/assets/images/flags/gm.png +0 -0
- data/app/assets/images/flags/gn.png +0 -0
- data/app/assets/images/flags/gp.png +0 -0
- data/app/assets/images/flags/gq.png +0 -0
- data/app/assets/images/flags/gr.png +0 -0
- data/app/assets/images/flags/gs.png +0 -0
- data/app/assets/images/flags/gt.png +0 -0
- data/app/assets/images/flags/gu.png +0 -0
- data/app/assets/images/flags/gw.png +0 -0
- data/app/assets/images/flags/gy.png +0 -0
- data/app/assets/images/flags/hk.png +0 -0
- data/app/assets/images/flags/hn.png +0 -0
- data/app/assets/images/flags/hr.png +0 -0
- data/app/assets/images/flags/ht.png +0 -0
- data/app/assets/images/flags/hu.png +0 -0
- data/app/assets/images/flags/id.png +0 -0
- data/app/assets/images/flags/ie.png +0 -0
- data/app/assets/images/flags/il.png +0 -0
- data/app/assets/images/flags/in.png +0 -0
- data/app/assets/images/flags/io.png +0 -0
- data/app/assets/images/flags/iq.png +0 -0
- data/app/assets/images/flags/ir.png +0 -0
- data/app/assets/images/flags/is.png +0 -0
- data/app/assets/images/flags/it.png +0 -0
- data/app/assets/images/flags/jm.png +0 -0
- data/app/assets/images/flags/jo.png +0 -0
- data/app/assets/images/flags/jp.png +0 -0
- data/app/assets/images/flags/ke.png +0 -0
- data/app/assets/images/flags/kg.png +0 -0
- data/app/assets/images/flags/kh.png +0 -0
- data/app/assets/images/flags/ki.png +0 -0
- data/app/assets/images/flags/km.png +0 -0
- data/app/assets/images/flags/kn.png +0 -0
- data/app/assets/images/flags/kp.png +0 -0
- data/app/assets/images/flags/kr.png +0 -0
- data/app/assets/images/flags/kw.png +0 -0
- data/app/assets/images/flags/ky.png +0 -0
- data/app/assets/images/flags/kz.png +0 -0
- data/app/assets/images/flags/la.png +0 -0
- data/app/assets/images/flags/lb.png +0 -0
- data/app/assets/images/flags/lc.png +0 -0
- data/app/assets/images/flags/li.png +0 -0
- data/app/assets/images/flags/lk.png +0 -0
- data/app/assets/images/flags/lr.png +0 -0
- data/app/assets/images/flags/ls.png +0 -0
- data/app/assets/images/flags/lt.png +0 -0
- data/app/assets/images/flags/lu.png +0 -0
- data/app/assets/images/flags/lv.png +0 -0
- data/app/assets/images/flags/ly.png +0 -0
- data/app/assets/images/flags/ma.png +0 -0
- data/app/assets/images/flags/mc.png +0 -0
- data/app/assets/images/flags/md.png +0 -0
- data/app/assets/images/flags/mg.png +0 -0
- data/app/assets/images/flags/mh.png +0 -0
- data/app/assets/images/flags/mk.png +0 -0
- data/app/assets/images/flags/ml.png +0 -0
- data/app/assets/images/flags/mm.png +0 -0
- data/app/assets/images/flags/mn.png +0 -0
- data/app/assets/images/flags/mo.png +0 -0
- data/app/assets/images/flags/mp.png +0 -0
- data/app/assets/images/flags/mq.png +0 -0
- data/app/assets/images/flags/mr.png +0 -0
- data/app/assets/images/flags/ms.png +0 -0
- data/app/assets/images/flags/mt.png +0 -0
- data/app/assets/images/flags/mu.png +0 -0
- data/app/assets/images/flags/mv.png +0 -0
- data/app/assets/images/flags/mw.png +0 -0
- data/app/assets/images/flags/mx.png +0 -0
- data/app/assets/images/flags/my.png +0 -0
- data/app/assets/images/flags/mz.png +0 -0
- data/app/assets/images/flags/na.png +0 -0
- data/app/assets/images/flags/nc.png +0 -0
- data/app/assets/images/flags/ne.png +0 -0
- data/app/assets/images/flags/nf.png +0 -0
- data/app/assets/images/flags/ng.png +0 -0
- data/app/assets/images/flags/ni.png +0 -0
- data/app/assets/images/flags/nl.png +0 -0
- data/app/assets/images/flags/no.png +0 -0
- data/app/assets/images/flags/np.png +0 -0
- data/app/assets/images/flags/nr.png +0 -0
- data/app/assets/images/flags/nu.png +0 -0
- data/app/assets/images/flags/nz.png +0 -0
- data/app/assets/images/flags/om.png +0 -0
- data/app/assets/images/flags/pa.png +0 -0
- data/app/assets/images/flags/pe.png +0 -0
- data/app/assets/images/flags/pf.png +0 -0
- data/app/assets/images/flags/pg.png +0 -0
- data/app/assets/images/flags/ph.png +0 -0
- data/app/assets/images/flags/pk.png +0 -0
- data/app/assets/images/flags/pl.png +0 -0
- data/app/assets/images/flags/pm.png +0 -0
- data/app/assets/images/flags/pn.png +0 -0
- data/app/assets/images/flags/pr.png +0 -0
- data/app/assets/images/flags/ps.png +0 -0
- data/app/assets/images/flags/pt.png +0 -0
- data/app/assets/images/flags/pw.png +0 -0
- data/app/assets/images/flags/py.png +0 -0
- data/app/assets/images/flags/qa.png +0 -0
- data/app/assets/images/flags/ro.png +0 -0
- data/app/assets/images/flags/ru.png +0 -0
- data/app/assets/images/flags/rw.png +0 -0
- data/app/assets/images/flags/sa.png +0 -0
- data/app/assets/images/flags/sb.png +0 -0
- data/app/assets/images/flags/sc.png +0 -0
- data/app/assets/images/flags/sd.png +0 -0
- data/app/assets/images/flags/se.png +0 -0
- data/app/assets/images/flags/sg.png +0 -0
- data/app/assets/images/flags/sh.png +0 -0
- data/app/assets/images/flags/si.png +0 -0
- data/app/assets/images/flags/sk.png +0 -0
- data/app/assets/images/flags/sl.png +0 -0
- data/app/assets/images/flags/sm.png +0 -0
- data/app/assets/images/flags/sn.png +0 -0
- data/app/assets/images/flags/so.png +0 -0
- data/app/assets/images/flags/sr.png +0 -0
- data/app/assets/images/flags/st.png +0 -0
- data/app/assets/images/flags/sv.png +0 -0
- data/app/assets/images/flags/sy.png +0 -0
- data/app/assets/images/flags/sz.png +0 -0
- data/app/assets/images/flags/tc.png +0 -0
- data/app/assets/images/flags/td.png +0 -0
- data/app/assets/images/flags/tf.png +0 -0
- data/app/assets/images/flags/tg.png +0 -0
- data/app/assets/images/flags/th.png +0 -0
- data/app/assets/images/flags/tj.png +0 -0
- data/app/assets/images/flags/tk.png +0 -0
- data/app/assets/images/flags/tl.png +0 -0
- data/app/assets/images/flags/tm.png +0 -0
- data/app/assets/images/flags/tn.png +0 -0
- data/app/assets/images/flags/to.png +0 -0
- data/app/assets/images/flags/tr.png +0 -0
- data/app/assets/images/flags/tt.png +0 -0
- data/app/assets/images/flags/tv.png +0 -0
- data/app/assets/images/flags/tw.png +0 -0
- data/app/assets/images/flags/tz.png +0 -0
- data/app/assets/images/flags/ua.png +0 -0
- data/app/assets/images/flags/ug.png +0 -0
- data/app/assets/images/flags/um.png +0 -0
- data/app/assets/images/flags/us.png +0 -0
- data/app/assets/images/flags/uy.png +0 -0
- data/app/assets/images/flags/uz.png +0 -0
- data/app/assets/images/flags/va.png +0 -0
- data/app/assets/images/flags/vc.png +0 -0
- data/app/assets/images/flags/ve.png +0 -0
- data/app/assets/images/flags/vg.png +0 -0
- data/app/assets/images/flags/vi.png +0 -0
- data/app/assets/images/flags/vn.png +0 -0
- data/app/assets/images/flags/vu.png +0 -0
- data/app/assets/images/flags/wales.png +0 -0
- data/app/assets/images/flags/wf.png +0 -0
- data/app/assets/images/flags/ws.png +0 -0
- data/app/assets/images/flags/ye.png +0 -0
- data/app/assets/images/flags/yt.png +0 -0
- data/app/assets/images/flags/za.png +0 -0
- data/app/assets/images/flags/zm.png +0 -0
- data/app/assets/images/flags/zw.png +0 -0
- data/app/assets/stylesheets/localizer_rails/localizer_rails.css.scss +74 -0
- data/app/assets/stylesheets/localizer_rails.css +8 -0
- data/app/helpers/localizer_rails/localizer_rails_helper.rb +29 -0
- data/app/views/localizer_rails/_elements.html.erb +4 -0
- data/app/views/localizer_rails/_item.bootstrap.html.erb +18 -0
- data/app/views/localizer_rails/_item.html.erb +18 -0
- data/app/views/localizer_rails/_language_menu.html.erb +8 -0
- data/config/localizer_rails/lang_countries.yml +1018 -0
- data/lib/generators/localizer_rails/localizer_rails_generator.rb +119 -0
- data/lib/generators/localizer_rails/templates/_header.html.erb +33 -0
- data/lib/generators/localizer_rails/templates/kaminari_action_view_extension.rb +30 -0
- data/lib/generators/localizer_rails/templates/localizer_rails_prefs.rb +22 -0
- data/lib/localizer_rails/engine.rb +15 -0
- data/lib/localizer_rails/set_locale.rb +9 -0
- data/lib/localizer_rails/version.rb +3 -0
- data/lib/localizer_rails.rb +126 -0
- data/lib/tasks/localizer_tasks.rake +4 -0
- metadata +331 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d15b76bf8d085001ec59ea8a1c406ce3313b6489
|
|
4
|
+
data.tar.gz: 7c07323d603aee4f3fb365438b563aa695b11c6f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: bdd8269abba8b4bffe563a0d97ea26042a3ee13b46ef5cfb922622ea2065986c639861c122effbc85736eb3b1543d0ab9de9fa37c191f2ec84e140837534afd0
|
|
7
|
+
data.tar.gz: e447afabd5902ec2f3ee1bb8dccfd93c95aa2c7e1208d06b9186d51bfad3f35e443ff473ff49f6a66c51639c8d3f1dfb16808d170acead7d5d4d07676bcb5cf0
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2015 Gianni Bellono
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
LocalizerRails
|
|
2
|
+
=========
|
|
3
|
+
Just some handy utilities to manage site localization, generator provided
|
|
4
|
+
|
|
5
|
+
1. set/retrieve language if none selected
|
|
6
|
+
2. build language menu (bootstrap 3+ compatible)
|
|
7
|
+
3. <i>[optional]</i> convenience partials and Kaminari pluralization patch (up to v0.16.3)
|
|
8
|
+
|
|
9
|
+
Requirements
|
|
10
|
+
------------
|
|
11
|
+
Rails version: 4+
|
|
12
|
+
|
|
13
|
+
**Gemfile**:
|
|
14
|
+
|
|
15
|
+
gem 'localizer_rails', '0.1.0'
|
|
16
|
+
**Style**:
|
|
17
|
+
<pre> @import 'localizer_rails/localizer_rails';</pre>
|
|
18
|
+
OR
|
|
19
|
+
<pre> require localizer_rails</pre>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Description
|
|
23
|
+
-----------
|
|
24
|
+
### **<i>set_loc</i>** method
|
|
25
|
+
|
|
26
|
+
finds the best-match for `I18n.locale` through a cascading search:
|
|
27
|
+
|
|
28
|
+
1. params[:locale]
|
|
29
|
+
2. cookies['locale']
|
|
30
|
+
3. current_user.locale (if defined)
|
|
31
|
+
4. session[:locale]
|
|
32
|
+
5. accepted_locales (scans browser's HTTP_ACCEPT_LANGUAGE)
|
|
33
|
+
6. I18n.default_locale (if everything else fails)
|
|
34
|
+
|
|
35
|
+
and sets values accordingly (cookies, link_to, ...)
|
|
36
|
+
|
|
37
|
+
1. use in __<i>before_action</i>__:
|
|
38
|
+
<pre> before_action LocalizerRails::SetLoc</pre>
|
|
39
|
+
|
|
40
|
+
2. use in __<i>routes</i>__, too:
|
|
41
|
+
<pre> scope ":locale", locale: /#{LocalizerRails.active_locales.join("|")}/ do ...<br/>
|
|
42
|
+
...<br/>
|
|
43
|
+
match '*path', to: redirect { |p, req|
|
|
44
|
+
Localizer.set_locale(req)
|
|
45
|
+
if( ! (Localizer.active_locales.any? { |word| req.path.starts_with? ("/#{word}/") }) )
|
|
46
|
+
"/#{I18n.locale}#{req.path}"
|
|
47
|
+
else
|
|
48
|
+
if( Rails.env.production? || !Rails.application.config.consider_all_requests_local )
|
|
49
|
+
## SHOW custom 404
|
|
50
|
+
Rails.application.routes.url_helpers.error_404_path(:locale => I18n.locale)
|
|
51
|
+
else
|
|
52
|
+
## let Rails handle this with default 404
|
|
53
|
+
raise ActionController::RoutingError.new('Not Found')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
},
|
|
57
|
+
via: [ :get, :post, :patch, :delete ],
|
|
58
|
+
status: '301'
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### **<i>active_locales_map</i>** method
|
|
62
|
+
|
|
63
|
+
builds an hash of locale key/value pairs useful to build a `locale_menu`
|
|
64
|
+
|
|
65
|
+
<i>[optional]</i> override and edit `config/LocalizerRails/lang_countries.yml`
|
|
66
|
+
|
|
67
|
+
<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'
|
|
80
|
+
</pre>
|
|
81
|
+
|
|
82
|
+
<i>where</i>
|
|
83
|
+
|
|
84
|
+
* __:lang_default__: language name in default language (ex.: english)
|
|
85
|
+
* __:lang_local__: language name in local language/alphabet
|
|
86
|
+
|
|
87
|
+
xtra country specs, use if `locale_menu` lists countries instead of languages:
|
|
88
|
+
|
|
89
|
+
* __:country_default__: country name in default language (english)
|
|
90
|
+
* __:country_local__: country name in local language/alphabet
|
|
91
|
+
* __:country_code__: country ISO code
|
|
92
|
+
|
|
93
|
+
__<i>NOTE</i>__: languages will be listed ONLY if included in `i18n.available_locales`
|
|
94
|
+
|
|
95
|
+
<i>[optional]</i> edit __<i>LI structure</i>__ and attributes in
|
|
96
|
+
`app/views/LocalizerRails/_item[.bootstrap].html.erb`
|
|
97
|
+
|
|
98
|
+
<i>[optional]</i> edit __<i>LI elements</i>__ and their display order in
|
|
99
|
+
`app/views/LocalizerRails/_elements.html.erb`
|
|
100
|
+
|
|
101
|
+
__CONFIGURATION__
|
|
102
|
+
|
|
103
|
+
<i>[optional]</i> override and edit `config/initializers/LocalizerRails/LocalizerRails_prefs.rb`
|
|
104
|
+
|
|
105
|
+
<pre>
|
|
106
|
+
LocalizerRails::Conf.configure do |conf|
|
|
107
|
+
conf.variable_name = value
|
|
108
|
+
...</pre>
|
|
109
|
+
|
|
110
|
+
__OPTIONS:__
|
|
111
|
+
|
|
112
|
+
* __conf.merge_lang_countries_tables__ = (boolean)<br/>
|
|
113
|
+
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
|
+
- 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)
|
|
116
|
+
|
|
117
|
+
* __conf.all_available_locales__ (boolean)<br/>
|
|
118
|
+
- set to <i>true</i> if
|
|
119
|
+
- you want to load all locales in `I18n.available_locales`
|
|
120
|
+
- 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>__
|
|
123
|
+
|
|
124
|
+
__<i>Hint:</i>__ install [rails-i18n] (https://github.com/svenfuchs/rails-i18n) to add pluralization rules and a bunch of translated language files.
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
* __conf.active_locales__ (:sym)<br/>
|
|
128
|
+
define which locales your application will use
|
|
129
|
+
- locales not included in `I18n.available_locales` will be ignored
|
|
130
|
+
- defaults to __<i>[I18n.default_locale]</i>__
|
|
131
|
+
|
|
132
|
+
* __conf.country_downcase__ = (boolean)<br/>
|
|
133
|
+
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>__
|
|
137
|
+
|
|
138
|
+
* __conf.display_local_language__ = (boolean)<br/>
|
|
139
|
+
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>__
|
|
143
|
+
|
|
144
|
+
* __conf.use_bootstrap__ = (boolean)<br/>
|
|
145
|
+
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)
|
|
147
|
+
|
|
148
|
+
* __conf.cookie_expires__ = (Date | nil)<br/>
|
|
149
|
+
set a custom expiration date for the `:cookies[:locale]`
|
|
150
|
+
- Date can be in the format 20.year.from_now.utc (same as cookies.permanent)
|
|
151
|
+
- defaults to __<i>nil</i>__ (session length)
|
|
152
|
+
|
|
153
|
+
* __conf.store_in_session__ = (boolean)<br/>
|
|
154
|
+
store `I18n.locale` also in session?
|
|
155
|
+
- defaults to __<i>false</i>__
|
|
156
|
+
|
|
157
|
+
## Extras (optional)
|
|
158
|
+
|
|
159
|
+
### **Kaminari override**
|
|
160
|
+
|
|
161
|
+
[Kaminari] (https://github.com/amatsuda/kaminari) (up to current v0.16.3) handles pluralization through <i>pluralize</i>.<br/>
|
|
162
|
+
In case of localization with foreign languages (eventually with multiple plural forms, such as cyrillic) this method often outputs incorrect results.<br/>
|
|
163
|
+
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.
|
|
166
|
+
|
|
167
|
+
### **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.
|
|
170
|
+
|
|
171
|
+
### **dummy app**
|
|
172
|
+
Type the following lines in your Terminal application to see a working example:
|
|
173
|
+
|
|
174
|
+
$ cd path-to-your-dir
|
|
175
|
+
$ git clone https://github.com/gbellono/localizer_rails.git
|
|
176
|
+
$ cd path-to-your-dir/localizer_rails
|
|
177
|
+
$ bundle install
|
|
178
|
+
$ 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`.
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
## Credits
|
|
184
|
+
|
|
185
|
+
Thanks to [Linuus](https://github.com/Linuus) for suggesting a viable way to patch Kaminari's handling of pluralization issues.
|
|
186
|
+
|
|
187
|
+
## Copyright
|
|
188
|
+
|
|
189
|
+
Copyright (c) 2015 by [Giovanni Bellono](mailto://giovanni.bellono@gmail.com)<br>
|
|
190
|
+
See [LICENSE](https://github.com/gbellono/localizer_rails/blob/master/MIT-LICENSE) for details.
|
|
191
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'LocalizerRails'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Bundler::GemHelper.install_tasks
|
|
23
|
+
|
|
24
|
+
require 'rake/testtask'
|
|
25
|
+
|
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
|
27
|
+
t.libs << 'lib'
|
|
28
|
+
t.libs << 'test'
|
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
|
30
|
+
t.verbose = false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
task default: :test
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|