i18n-js 2.1.2 → 3.0.11
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/.editorconfig +24 -0
- data/.gitignore +5 -4
- data/.npmignore +27 -0
- data/.travis.yml +37 -0
- data/Appraisals +20 -0
- data/CHANGELOG.md +354 -0
- data/Gemfile +1 -1
- data/README.md +872 -0
- data/Rakefile +19 -7
- data/app/assets/javascripts/i18n/filtered.js.erb +23 -0
- data/app/assets/javascripts/i18n/shims.js +208 -0
- data/app/assets/javascripts/i18n/translations.js +3 -0
- data/app/assets/javascripts/i18n.js +1077 -0
- data/gemfiles/i18n_0_6.gemfile +7 -0
- data/gemfiles/i18n_0_7.gemfile +7 -0
- data/gemfiles/i18n_0_8.gemfile +7 -0
- data/gemfiles/i18n_0_9.gemfile +7 -0
- data/gemfiles/i18n_1_0.gemfile +7 -0
- data/i18n-js.gemspec +11 -9
- data/lib/i18n/js/dependencies.rb +59 -0
- data/lib/i18n/js/engine.rb +87 -0
- data/lib/i18n/js/fallback_locales.rb +70 -0
- data/lib/{i18n-js → i18n/js}/middleware.rb +32 -9
- data/lib/i18n/js/private/hash_with_symbol_keys.rb +36 -0
- data/lib/i18n/js/segment.rb +88 -0
- data/lib/i18n/js/utils.rb +52 -0
- data/lib/i18n/js/version.rb +7 -0
- data/lib/i18n/js.rb +242 -0
- data/lib/i18n-js.rb +1 -177
- data/lib/rails/generators/i18n/js/config/config_generator.rb +19 -0
- data/{config → lib/rails/generators/i18n/js/config/templates}/i18n-js.yml +11 -6
- data/lib/tasks/export.rake +8 -0
- data/package.json +25 -0
- data/spec/fixtures/custom_path.yml +5 -0
- data/spec/fixtures/default.yml +5 -0
- data/spec/fixtures/erb.yml +5 -0
- data/spec/fixtures/except_condition.yml +7 -0
- data/spec/fixtures/js_export_dir_custom.yml +7 -0
- data/spec/fixtures/js_export_dir_none.yml +6 -0
- data/spec/fixtures/js_extend_parent.yml +6 -0
- data/spec/fixtures/js_extend_segment.yml +6 -0
- data/spec/fixtures/js_file_per_locale.yml +7 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_default_locale_symbol.yml +4 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_hash.yml +6 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale.yml +4 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_as_locale_without_fallback_translations.yml +4 -0
- data/spec/fixtures/js_file_per_locale_with_fallbacks_enabled.yml +4 -0
- data/spec/fixtures/js_file_per_locale_without_fallbacks.yml +4 -0
- data/spec/fixtures/js_file_with_namespace_and_pretty_print.yml +7 -0
- data/spec/fixtures/js_sort_translation_keys_false.yml +6 -0
- data/spec/fixtures/js_sort_translation_keys_true.yml +6 -0
- data/spec/{resources → fixtures}/locales.yml +13 -1
- data/spec/fixtures/multiple_conditions.yml +7 -0
- data/spec/fixtures/multiple_conditions_per_locale.yml +7 -0
- data/spec/fixtures/multiple_files.yml +7 -0
- data/spec/{resources → fixtures}/no_config.yml +0 -0
- data/spec/fixtures/no_scope.yml +4 -0
- data/spec/fixtures/simple_scope.yml +5 -0
- data/spec/js/currency.spec.js +62 -0
- data/spec/js/current_locale.spec.js +19 -0
- data/spec/js/dates.spec.js +265 -0
- data/spec/js/defaults.spec.js +31 -0
- data/spec/js/extend.spec.js +110 -0
- data/spec/js/interpolation.spec.js +124 -0
- data/spec/js/jasmine/MIT.LICENSE +20 -0
- data/spec/js/jasmine/jasmine-html.js +190 -0
- data/spec/js/jasmine/jasmine.css +166 -0
- data/spec/js/jasmine/jasmine.js +2476 -0
- data/spec/js/jasmine/jasmine_favicon.png +0 -0
- data/spec/js/locales.spec.js +31 -0
- data/spec/js/localization.spec.js +48 -0
- data/spec/js/numbers.spec.js +170 -0
- data/spec/js/placeholder.spec.js +24 -0
- data/spec/js/pluralization.spec.js +211 -0
- data/spec/js/prepare_options.spec.js +41 -0
- data/spec/js/require.js +2083 -0
- data/spec/js/specs.html +49 -0
- data/spec/js/specs_requirejs.html +72 -0
- data/spec/js/translate.spec.js +277 -0
- data/spec/js/translations.js +164 -0
- data/spec/js/utility_functions.spec.js +20 -0
- data/spec/ruby/i18n/js/fallback_locales_spec.rb +84 -0
- data/spec/ruby/i18n/js/segment_spec.rb +157 -0
- data/spec/ruby/i18n/js/utils_spec.rb +106 -0
- data/spec/ruby/i18n/js_spec.rb +627 -0
- data/spec/spec_helper.rb +55 -14
- data/yarn.lock +131 -0
- metadata +188 -96
- data/.rspec +0 -1
- data/Gemfile.lock +0 -51
- data/README.rdoc +0 -305
- data/lib/i18n-js/engine.rb +0 -62
- data/lib/i18n-js/railtie.rb +0 -13
- data/lib/i18n-js/rake.rb +0 -16
- data/lib/i18n-js/version.rb +0 -10
- data/spec/i18n_spec.js +0 -768
- data/spec/i18n_spec.rb +0 -205
- data/spec/resources/custom_path.yml +0 -4
- data/spec/resources/default.yml +0 -4
- data/spec/resources/js_file_per_locale.yml +0 -3
- data/spec/resources/multiple_conditions.yml +0 -6
- data/spec/resources/multiple_files.yml +0 -6
- data/spec/resources/no_scope.yml +0 -3
- data/spec/resources/simple_scope.yml +0 -4
- data/vendor/assets/javascripts/i18n/translations.js.erb +0 -7
- data/vendor/assets/javascripts/i18n.js +0 -450
data/README.rdoc
DELETED
@@ -1,305 +0,0 @@
|
|
1
|
-
= I18n for JavaScript
|
2
|
-
|
3
|
-
It's a small library to provide the Rails I18n translations on the Javascript.
|
4
|
-
|
5
|
-
== Usage
|
6
|
-
|
7
|
-
=== Installation
|
8
|
-
|
9
|
-
gem install i18n-js
|
10
|
-
|
11
|
-
=== Setting up
|
12
|
-
|
13
|
-
You <b>don't</b> need to set up a thing. The default settings will work just okay. But if you want to split translations into several files or specify specific contexts, you can follow the rest of this setting up section.
|
14
|
-
|
15
|
-
==== Rails <= 3.0
|
16
|
-
|
17
|
-
Run <tt>rake i18n:js:setup</tt> to copy <tt>i18n.js</tt> to your javascript directory and <tt>i18n-js.yml</tt> to your config folder (if not already present). Then you're ready to go!
|
18
|
-
|
19
|
-
==== Rails >= 3.1
|
20
|
-
|
21
|
-
Add the following lines to your application.js to make the javascripts and translations available to your app:
|
22
|
-
|
23
|
-
//= require i18n
|
24
|
-
//= require i18n/translations
|
25
|
-
|
26
|
-
If asset pipeline has been disabled for your Rails application, then you will need to run <tt>rake i18n:js:setup</tt> to copy <tt>i18n-js.yml</tt> to your config folder (if not already present).
|
27
|
-
|
28
|
-
==== Exporting translations
|
29
|
-
|
30
|
-
You can export the translations file by running <tt>rake i18n:js:export</tt>.
|
31
|
-
Translations will be automatically exported in development mode.
|
32
|
-
|
33
|
-
==== Configuration
|
34
|
-
|
35
|
-
Translation files can be customized. You can even get more files generated to different folders and with different translations to best suit your needs.
|
36
|
-
|
37
|
-
Examples:
|
38
|
-
|
39
|
-
translations:
|
40
|
-
- file: 'public/javascripts/path-to-your-messages-file.js'
|
41
|
-
only: '*.date.formats'
|
42
|
-
- file: 'public/javascripts/path-to-your-second-file.js'
|
43
|
-
only: ['*.activerecord', '*.admin.*.title']
|
44
|
-
|
45
|
-
If <tt>only</tt> is omitted all the translations will be saved. Also, make sure you add that initial <tt>*</tt>; it specifies that all languages will be exported. If you want to export only one language, you can do something like this:
|
46
|
-
|
47
|
-
translations:
|
48
|
-
- file: 'public/javascripts/en.js'
|
49
|
-
only: 'en.*'
|
50
|
-
- file: 'public/javascripts/pt-BR.js'
|
51
|
-
only: 'pt-BR.*'
|
52
|
-
|
53
|
-
Optionaly, you can auto generate a translation file per available locale if you specify the <tt>%{locale}</tt> placeholder.
|
54
|
-
|
55
|
-
translations:
|
56
|
-
- file: "public/javascripts/i18n/%{locale}.js"
|
57
|
-
only: '*'
|
58
|
-
- file: "public/javascripts/frontend/i18n/%{locale}.js"
|
59
|
-
only: ['frontend', 'users']
|
60
|
-
|
61
|
-
To find more examples on how to use the configuration file please refer to the tests.
|
62
|
-
|
63
|
-
=== On the Javascript
|
64
|
-
|
65
|
-
Set your locale is easy as
|
66
|
-
|
67
|
-
I18n.defaultLocale = "pt-BR";
|
68
|
-
I18n.locale = "pt-BR";
|
69
|
-
I18n.currentLocale();
|
70
|
-
// pt-BR
|
71
|
-
|
72
|
-
In practice, you'll have something like the following in your <tt>application.html.erb</tt>:
|
73
|
-
|
74
|
-
<script type="text/javascript">
|
75
|
-
I18n.defaultLocale = "<%= I18n.default_locale %>";
|
76
|
-
I18n.locale = "<%= I18n.locale %>";
|
77
|
-
</script>
|
78
|
-
|
79
|
-
You can use translate your messages:
|
80
|
-
|
81
|
-
I18n.t("some.scoped.translation");
|
82
|
-
// or translate with explicite setting of locale
|
83
|
-
I18n.t("some.scoped.translation", {locale: "fr"});
|
84
|
-
|
85
|
-
You can also interpolate values:
|
86
|
-
|
87
|
-
I18n.t("hello", {name: "John Doe"});
|
88
|
-
|
89
|
-
The sample above will assume that you have the following translations in your
|
90
|
-
<tt>config/locales/*.yml</tt>:
|
91
|
-
|
92
|
-
en:
|
93
|
-
hello: "Hello {{name}}!"
|
94
|
-
|
95
|
-
You can set default values for missing scopes:
|
96
|
-
|
97
|
-
// simple translation
|
98
|
-
I18n.t("some.missing.scope", {defaultValue: "A default message"});
|
99
|
-
|
100
|
-
// with interpolation
|
101
|
-
I18n.t("noun", {defaultValue: "I'm a {{noun}}", noun: "Mac"});
|
102
|
-
|
103
|
-
Translation fallback can be handled by taking from I18n.defaultLocale.
|
104
|
-
To allow this in your application.html.erb specify:
|
105
|
-
|
106
|
-
<script type="text/javascript">
|
107
|
-
I18n.fallbacks = true;
|
108
|
-
</script>
|
109
|
-
|
110
|
-
Then missing translation will be taken from your I18n.defaultLocale.
|
111
|
-
Example:
|
112
|
-
// if I18n.defaultLocale = "en" and translation doesn't exist for I18n.locale = "de"
|
113
|
-
I18n.t("some.missing.scope");
|
114
|
-
// this key will be taken from "en" locale scope
|
115
|
-
|
116
|
-
Pluralization is possible as well:
|
117
|
-
|
118
|
-
I18n.t("inbox.counting", {count: 10}); // You have 10 messages
|
119
|
-
|
120
|
-
The sample above expects the following translation:
|
121
|
-
|
122
|
-
en:
|
123
|
-
inbox:
|
124
|
-
counting:
|
125
|
-
one: You have 1 new message
|
126
|
-
other: You have {{count}} new messages
|
127
|
-
zero: You have no messages
|
128
|
-
|
129
|
-
<b>NOTE:</b> Rais I18n recognizes the +zero+ option.
|
130
|
-
|
131
|
-
If you're using the same scope over and over again, you may use the +scope+ option.
|
132
|
-
|
133
|
-
var options = {scope: "activerecord.attributes.user"};
|
134
|
-
|
135
|
-
I18n.t("name", options);
|
136
|
-
I18n.t("email", options);
|
137
|
-
I18n.t("username", options);
|
138
|
-
|
139
|
-
You also provide an array as scope.
|
140
|
-
|
141
|
-
// use the greetings.hello scope
|
142
|
-
I18n.t(["greetings", "hello"]);
|
143
|
-
|
144
|
-
==== Number formatting
|
145
|
-
|
146
|
-
Similar to Rails helpers, you have localized number and currency formatting.
|
147
|
-
|
148
|
-
I18n.l("currency", 1990.99);
|
149
|
-
// $1,990.99
|
150
|
-
|
151
|
-
I18n.l("number", 1990.99);
|
152
|
-
// 1,990.99
|
153
|
-
|
154
|
-
I18n.l("percentage", 123.45);
|
155
|
-
// 123.450%
|
156
|
-
|
157
|
-
To have more control over number formatting, you can use the <tt>I18n.toNumber</tt>, <tt>I18n.toPercentage</tt>, <tt>I18n.toCurrency</tt> and <tt>I18n.toHumanSize</tt> functions.
|
158
|
-
|
159
|
-
I18n.toNumber(1000); // 1,000.000
|
160
|
-
I18n.toCurrency(1000); // $1,000.00
|
161
|
-
I18n.toPercentage(100); // 100.000%
|
162
|
-
|
163
|
-
The +toNumber+ and +toPercentage+ functions accept the following options:
|
164
|
-
|
165
|
-
* +precision+: defaults to 3
|
166
|
-
* +separator+: defaults to <tt>.</tt>
|
167
|
-
* +delimiter+: defaults to <tt>,</tt>
|
168
|
-
* +strip_insignificant_zeros+: defaults to <tt>false</tt>
|
169
|
-
|
170
|
-
See some number formatting examples:
|
171
|
-
|
172
|
-
I18n.toNumber(1000, {precision: 0}); // 1,000
|
173
|
-
I18n.toNumber(1000, {delimiter: ".", separator: ","}); // 1.000,000
|
174
|
-
I18n.toNumber(1000, {delimiter: ".", precision: 0}); // 1.000
|
175
|
-
|
176
|
-
The +toCurrency+ function accepts the following options:
|
177
|
-
|
178
|
-
* +precision+: sets the level of precision
|
179
|
-
* +separator+: sets the separator between the units
|
180
|
-
* +delimiter+: sets the thousands delimiter
|
181
|
-
* +format+: sets the format of the output string
|
182
|
-
* +unit+: sets the denomination of the currency
|
183
|
-
* +strip_insignificant_zeros+: defaults to <tt>false</tt>
|
184
|
-
|
185
|
-
You can provide only the options you want to override:
|
186
|
-
|
187
|
-
I18n.toCurrency(1000, {precision: 0}); // $1,000
|
188
|
-
|
189
|
-
The +toHumanSize+ function accepts the following options:
|
190
|
-
|
191
|
-
* +precision+: defaults to 1
|
192
|
-
* +separator+: defaults to <tt>.</tt>
|
193
|
-
* +delimiter+: defaults to <tt>""</tt>
|
194
|
-
* +strip_insignificant_zeros+: defaults to <tt>false</tt>
|
195
|
-
* +format+: defaults to <tt>%n%u</tt>
|
196
|
-
|
197
|
-
I18n.toHumanSize(1234); // 1KB
|
198
|
-
I18n.toHumanSize(1234 * 1024); // 1MB
|
199
|
-
|
200
|
-
==== Date formatting
|
201
|
-
|
202
|
-
// accepted formats
|
203
|
-
I18n.l("date.formats.short", "2009-09-18"); // yyyy-mm-dd
|
204
|
-
I18n.l("time.formats.short", "2009-09-18 23:12:43"); // yyyy-mm-dd hh:mm:ss
|
205
|
-
I18n.l("time.formats.short", "2009-11-09T18:10:34"); // JSON format with local Timezone (part of ISO-8601)
|
206
|
-
I18n.l("time.formats.short", "2009-11-09T18:10:34Z"); // JSON format in UTC (part of ISO-8601)
|
207
|
-
I18n.l("date.formats.short", 1251862029000); // Epoch time
|
208
|
-
I18n.l("date.formats.short", "09/18/2009"); // mm/dd/yyyy
|
209
|
-
I18n.l("date.formats.short", (new Date())); // Date object
|
210
|
-
|
211
|
-
If you prefer, you can use the <tt>I18n.strftime</tt> function to format dates.
|
212
|
-
|
213
|
-
var date = new Date();
|
214
|
-
I18n.strftime(date, "%d/%m/%Y");
|
215
|
-
|
216
|
-
The accepted formats are:
|
217
|
-
|
218
|
-
%a - The abbreviated weekday name (Sun)
|
219
|
-
%A - The full weekday name (Sunday)
|
220
|
-
%b - The abbreviated month name (Jan)
|
221
|
-
%B - The full month name (January)
|
222
|
-
%c - The preferred local date and time representation
|
223
|
-
%d - Day of the month (01..31)
|
224
|
-
%-d - Day of the month (1..31)
|
225
|
-
%H - Hour of the day, 24-hour clock (00..23)
|
226
|
-
%-H - Hour of the day, 24-hour clock (0..23)
|
227
|
-
%I - Hour of the day, 12-hour clock (01..12)
|
228
|
-
%-I - Hour of the day, 12-hour clock (1..12)
|
229
|
-
%m - Month of the year (01..12)
|
230
|
-
%-m - Month of the year (1..12)
|
231
|
-
%M - Minute of the hour (00..59)
|
232
|
-
%-M - Minute of the hour (0..59)
|
233
|
-
%p - Meridian indicator (AM or PM)
|
234
|
-
%S - Second of the minute (00..60)
|
235
|
-
%-S - Second of the minute (0..60)
|
236
|
-
%w - Day of the week (Sunday is 0, 0..6)
|
237
|
-
%y - Year without a century (00..99)
|
238
|
-
%-y - Year without a century (0..99)
|
239
|
-
%Y - Year with century
|
240
|
-
%z - Timezone offset (+0545)
|
241
|
-
|
242
|
-
Check out <tt>vendor/plugins/i18n-js/spec/i18n_spec.js</tt> for more examples!
|
243
|
-
|
244
|
-
== Using I18nJS with other languages (Python, PHP, ...)
|
245
|
-
|
246
|
-
The JavaScript library is language agnostic; so you can use it with PHP, Python, [you favorite language here].
|
247
|
-
The only requirement is that you need to set the +translations+ attribute like following:
|
248
|
-
|
249
|
-
I18n.translations = {};
|
250
|
-
|
251
|
-
I18n.translations["en"] = {
|
252
|
-
message: "Some special message for you"
|
253
|
-
}
|
254
|
-
|
255
|
-
I18n.translations["pt-BR"] = {
|
256
|
-
message: "Uma mensagem especial para você"
|
257
|
-
}
|
258
|
-
|
259
|
-
== Maintainer
|
260
|
-
|
261
|
-
* Nando Vieira - http://simplesideias.com.br
|
262
|
-
* Sébastien Grosjean - http://github.com/ZenCocoon
|
263
|
-
|
264
|
-
== Contributing
|
265
|
-
|
266
|
-
Once you've made your great commits:
|
267
|
-
|
268
|
-
1. Fork[http://help.github.com/forking/] I18n-JS
|
269
|
-
2. Create a topic branch - <tt>git checkout -b my_branch</tt>
|
270
|
-
3. Push to your branch - <tt>git push origin my_branch</tt>
|
271
|
-
4. Create an Issue[http://github.com/fnando/i18n-js/issues] with a link to your branch
|
272
|
-
5. That's it!
|
273
|
-
|
274
|
-
Please respect the indentation rules. And use 2 spaces, not tabs.
|
275
|
-
|
276
|
-
=== Running tests
|
277
|
-
|
278
|
-
First, install all dependencies.
|
279
|
-
|
280
|
-
bundle install
|
281
|
-
|
282
|
-
Then just run <tt>rake spec</tt>.
|
283
|
-
|
284
|
-
== License
|
285
|
-
|
286
|
-
(The MIT License)
|
287
|
-
|
288
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
289
|
-
a copy of this software and associated documentation files (the
|
290
|
-
'Software'), to deal in the Software without restriction, including
|
291
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
292
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
293
|
-
permit persons to whom the Software is furnished to do so, subject to
|
294
|
-
the following conditions:
|
295
|
-
|
296
|
-
The above copyright notice and this permission notice shall be
|
297
|
-
included in all copies or substantial portions of the Software.
|
298
|
-
|
299
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
300
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
301
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
302
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
303
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
304
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
305
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/i18n-js/engine.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
module SimplesIdeias
|
2
|
-
module I18n
|
3
|
-
class Engine < ::Rails::Engine
|
4
|
-
I18N_TRANSLATIONS_ASSET = "i18n/translations"
|
5
|
-
|
6
|
-
initializer "i18n-js.asset_dependencies", :after => "sprockets.environment" do
|
7
|
-
next unless SimplesIdeias::I18n.has_asset_pipeline?
|
8
|
-
|
9
|
-
config = Rails.root.join("config", "i18n-js.yml")
|
10
|
-
cache_file = I18n::Engine.load_path_hash_cache
|
11
|
-
|
12
|
-
Rails.application.assets.register_preprocessor "application/javascript", :"i18n-js_dependencies" do |context, data|
|
13
|
-
if context.logical_path == I18N_TRANSLATIONS_ASSET
|
14
|
-
context.depend_on(config)
|
15
|
-
# also set up dependencies on every locale file
|
16
|
-
::I18n.load_path.each {|path| context.depend_on(path)}
|
17
|
-
|
18
|
-
# Set up a dependency on the contents of the load path
|
19
|
-
# itself. In some situations it is possible to get here
|
20
|
-
# before the path hash cache file has been written; in
|
21
|
-
# this situation, write it now.
|
22
|
-
I18n::Engine.write_hash! unless File.exists?(cache_file)
|
23
|
-
context.depend_on(cache_file)
|
24
|
-
end
|
25
|
-
|
26
|
-
data
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# rewrite path cache hash at startup and before each request in development
|
31
|
-
config.to_prepare do
|
32
|
-
next unless SimplesIdeias::I18n.has_asset_pipeline?
|
33
|
-
SimplesIdeias::I18n::Engine.write_hash_if_changed unless Rails.env.production?
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.load_path_hash_cache
|
37
|
-
@load_path_hash_cache ||= Rails.root.join("tmp/i18n-js.cache")
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.write_hash_if_changed
|
41
|
-
load_path_hash = ::I18n.load_path.hash
|
42
|
-
|
43
|
-
if load_path_hash != cached_load_path_hash
|
44
|
-
self.cached_load_path_hash = load_path_hash
|
45
|
-
write_hash!
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.write_hash!
|
50
|
-
FileUtils.mkdir_p Rails.root.join("tmp")
|
51
|
-
|
52
|
-
File.open(load_path_hash_cache, "w+") do |f|
|
53
|
-
f.write(cached_load_path_hash)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class << self
|
58
|
-
attr_accessor :cached_load_path_hash
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/lib/i18n-js/railtie.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module SimplesIdeias
|
2
|
-
module I18n
|
3
|
-
class Railtie < Rails::Railtie
|
4
|
-
rake_tasks do
|
5
|
-
require "i18n-js/rake"
|
6
|
-
end
|
7
|
-
|
8
|
-
initializer "i18n-js.initialize" do |app|
|
9
|
-
app.config.middleware.use(Middleware) if Rails.env.development? && !SimplesIdeias::I18n.has_asset_pipeline?
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/lib/i18n-js/rake.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
namespace "i18n:js" do
|
2
|
-
desc "Copy i18n.js and configuration file"
|
3
|
-
task :setup => :environment do
|
4
|
-
SimplesIdeias::I18n.setup!
|
5
|
-
end
|
6
|
-
|
7
|
-
desc "Export the messages files"
|
8
|
-
task :export => :environment do
|
9
|
-
SimplesIdeias::I18n.export!
|
10
|
-
end
|
11
|
-
|
12
|
-
desc "Update the JavaScript library"
|
13
|
-
task :update => :environment do
|
14
|
-
SimplesIdeias::I18n.update!
|
15
|
-
end
|
16
|
-
end
|