i18n-js 3.0.0.rc11 → 3.0.0.rc12

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: 9a4b7236b1fa082ab83114e4015b4a4ba230c1f5
4
- data.tar.gz: 8e55ab185ee081ea88b5452d1caedfc0f4feb44b
3
+ metadata.gz: 38feae5eaf2de86fcedd5ebaa0eaf008a1a33f8d
4
+ data.tar.gz: fe63577ccdbce4f49d6f998f68fad0d58791eaf4
5
5
  SHA512:
6
- metadata.gz: 0127486af42b8210f21513c91eadaf1481f639be02cb4197335619e11609d877c9ab7ce8f372818127c9dc04744e9251e2aef21a5d38ac82276b5dfb87684631
7
- data.tar.gz: 9b3bd3240f25b722eb8e00332cbafc72b01f872c5ffb2e5f2236736ec4ff32026e5f317ef5dff20c30cafd8bd17f4b4a21a0e4577a7eba9cf95804e4e23c524a
6
+ metadata.gz: 00405a7c557557f13effc0088a9f13c56fe1fd9105d2cfd87951e8b9df1f55089f4610206a39dce7fed0b2d1780da36b1819f0fa4aed8c24d21875e538044cd2
7
+ data.tar.gz: 76240818ad36435dd3dfdf99324bb336c9832de408bd0c02104e5255e399d241f941a7d65bf903f2e505b1b311b39611fb34504884ebf0eeb14ba0caf35609d9
data/Appraisals CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  appraise "i18n_0_6" do
3
- gem 'i18n', '0.6.11'
3
+ gem "i18n", "~> 0.6.0", ">= 0.6.6"
4
4
  end
5
5
 
6
6
  appraise "i18n_0_7" do
7
- gem 'i18n', '0.7.0'
7
+ gem "i18n", "~> 0.7.0"
8
8
  end
data/CHANGELOG.md CHANGED
@@ -1,12 +1,39 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
1
4
 
2
- ## Unreleased
5
+ ## [Unreleased]
3
6
 
4
- ### breaking changes
7
+ ### Added
5
8
 
6
- ### enhancements
9
+ - Nothing
7
10
 
8
- ### bug fixes
11
+ ### Changed
12
+
13
+ - Nothing
14
+
15
+ ### Fixed
16
+
17
+ - Nothing
18
+
19
+
20
+ ## [3.0.0.rc12] - 2015-12-30
9
21
 
22
+ ### Added
23
+
24
+ - [JS] Allow extending of translation files ([#354](https://github.com/fnando/i18n-js/pull/354))
25
+ - [JS] Allow missingPlaceholder to receive extra data for debugging ([#380](https://github.com/fnando/i18n-js/pull/380))
26
+
27
+ ### Changed
28
+
29
+ - Nothing
30
+
31
+ ### Fixed
32
+
33
+ - [Ruby] Fix of missing initializer at sprockets. ([#371](https://github.com/fnando/i18n-js/pull/371))
34
+ - [Ruby] Use proper method to register preprocessor documented by sprockets-rails. ([#376](https://github.com/fnando/i18n-js/pull/376))
35
+ - [JS] Correctly round unprecise floating point numbers.
36
+ - [JS] Ensure objects are recognized when passed in from an iframe. ([#375](https://github.com/fnando/i18n-js/pull/375))
10
37
 
11
38
 
12
39
  ## 3.0.0.rc11
@@ -128,3 +155,8 @@
128
155
  ## Before 3.0.0.rc5
129
156
 
130
157
  - Things happened.
158
+
159
+
160
+
161
+ [Unreleased]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc12...HEAD
162
+ [3.0.0.rc12]: https://github.com/fnando/i18n-js/compare/v3.0.0.rc11...v3.0.0.rc12
data/README.md CHANGED
@@ -22,12 +22,13 @@ Features:
22
22
  #### Rails app
23
23
 
24
24
  Add the gem to your Gemfile.
25
-
26
- source "https://rubygems.org"
27
- gem "rails", "your_rails_version"
28
- # You only need this RC version constraint during the development of `3.0.0`, once stable version is released you can remove `rc8` suffix
29
- # `3.0.0.rc8` is the latest version of released RC version when this entry is changed, you might want to change it later
30
- gem "i18n-js", ">= 3.0.0.rc8"
25
+ ```ruby
26
+ source "https://rubygems.org"
27
+ gem "rails", "your_rails_version"
28
+ # You only need this RC version constraint during the development of `3.0.0`, once stable version is released you can remove `rc11` suffix
29
+ # `3.0.0.rc11` is the latest version of released RC version when this entry is changed, you might want to change it later
30
+ gem "i18n-js", ">= 3.0.0.rc11"
31
+ ```
31
32
 
32
33
  #### Rails app with [Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html)
33
34
 
@@ -62,13 +63,12 @@ Then get the JS files following the instructions below.
62
63
 
63
64
  1. This `translations.js` file can be automatically generated by the `I18n::JS::Middleware`.
64
65
  Just add `config.middleware.use I18n::JS::Middleware` to your `config/application.rb` file.
65
- Notice: Don't add this middleware if you are using [asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html)!
66
66
  2. If you can't or prefer not to generate this file,
67
67
  you can move the middleware line to your `config/environments/development.rb` file
68
68
  and run `rake i18n:js:export` before deploying.
69
- This will export all translation files, including the custom scopes
69
+ This will export all translation files, including the custom scopes
70
70
  you may have defined on `config/i18n-js.yml`.
71
- If `I18n.available_locales` is set (e.g. in your Rails `config/application.rb` file)
71
+ If `I18n.available_locales` is set (e.g. in your Rails `config/application.rb` file)
72
72
  then only the specified locales will be exported.
73
73
  Current version of `i18n.js` will also be exported to avoid version mismatching by downloading.
74
74
 
@@ -151,7 +151,7 @@ translations:
151
151
  - You may also set `export_i18n_js` and `sort_translation_keys` in your config file, e.g.:
152
152
 
153
153
  ```yaml
154
- export_i18n_js_: false
154
+ export_i18n_js: false
155
155
  # OR
156
156
  export_i18n_js: "my/path"
157
157
 
@@ -296,65 +296,79 @@ I18n.currentLocale();
296
296
 
297
297
  In practice, you'll have something like the following in your `application.html.erb`:
298
298
 
299
- <script type="text/javascript">
300
- I18n.defaultLocale = "<%= I18n.default_locale %>";
301
- I18n.locale = "<%= I18n.locale %>";
302
- </script>
299
+ ```erb
300
+ <script type="text/javascript">
301
+ I18n.defaultLocale = "<%= I18n.default_locale %>";
302
+ I18n.locale = "<%= I18n.locale %>";
303
+ </script>
304
+ ```
303
305
 
304
306
  You can use translate your messages:
305
307
 
306
- I18n.t("some.scoped.translation");
307
- // or translate with explicit setting of locale
308
- I18n.t("some.scoped.translation", {locale: "fr"});
308
+ ```javascript
309
+ I18n.t("some.scoped.translation");
310
+ // or translate with explicit setting of locale
311
+ I18n.t("some.scoped.translation", {locale: "fr"});
312
+ ```
309
313
 
310
314
  You can also interpolate values:
311
315
 
312
- I18n.t("hello", {name: "John Doe"});
313
-
316
+ ```javascript
317
+ I18n.t("hello", {name: "John Doe"});
318
+ ```
314
319
  You can set default values for missing scopes:
320
+ ```javascript
321
+ // simple translation
322
+ I18n.t("some.missing.scope", {defaultValue: "A default message"});
315
323
 
316
- // simple translation
317
- I18n.t("some.missing.scope", {defaultValue: "A default message"});
318
-
319
- // with interpolation
320
- I18n.t("noun", {defaultValue: "I'm a {{noun}}", noun: "Mac"});
324
+ // with interpolation
325
+ I18n.t("noun", {defaultValue: "I'm a {{noun}}", noun: "Mac"});
326
+ ```
321
327
 
322
328
  You can also provide a list of default fallbacks for missing scopes:
323
329
 
324
- // As a scope
325
- I18n.t("some.missing.scope", {defaults: [{scope: "some.existing.scope"}]});
330
+ ```javascript
331
+ // As a scope
332
+ I18n.t("some.missing.scope", {defaults: [{scope: "some.existing.scope"}]});
326
333
 
327
- // As a simple translation
328
- I18n.t("some.missing.scope", {defaults: [{message: "Some message"}]});
334
+ // As a simple translation
335
+ I18n.t("some.missing.scope", {defaults: [{message: "Some message"}]});
336
+ ```
329
337
 
330
- Default values must be provided as an array of hashs where the key is the
331
- type of translation desired, a `scope` or a `message`. The translation returned
332
- will be either the first scope recognized, or the first message defined.
338
+ Default values must be provided as an array of hashs where the key is the
339
+ type of translation desired, a `scope` or a `message`. The translation returned
340
+ will be either the first scope recognized, or the first message defined.
333
341
 
334
- The translation will fallback to the `defaultValue` translation if no scope
335
- in `defaults` matches and if no default of type `message` is found.
342
+ The translation will fallback to the `defaultValue` translation if no scope
343
+ in `defaults` matches and if no default of type `message` is found.
336
344
 
337
345
  Translation fallback can be enabled by enabling the `I18n.fallbacks` option:
338
346
 
339
- <script type="text/javascript">
340
- I18n.fallbacks = true;
341
- </script>
347
+ ```erb
348
+ <script type="text/javascript">
349
+ I18n.fallbacks = true;
350
+ </script>
351
+ ```
342
352
 
343
353
  By default missing translations will first be looked for in less
344
354
  specific versions of the requested locale and if that fails by taking
345
355
  them from your `I18n.defaultLocale`.
346
356
 
347
- // if I18n.defaultLocale = "en" and translation doesn't exist
348
- // for I18n.locale = "de-DE" this key will be taken from "de" locale scope
349
- // or, if that also doesn't exist, from "en" locale scope
350
- I18n.t("some.missing.scope");
357
+ ```javascript
358
+ // if I18n.defaultLocale = "en" and translation doesn't exist
359
+ // for I18n.locale = "de-DE" this key will be taken from "de" locale scope
360
+ // or, if that also doesn't exist, from "en" locale scope
361
+ I18n.t("some.missing.scope");
362
+ ```
351
363
 
352
364
  Custom fallback rules can also be specified for a particular language. There
353
365
  are three different ways of doing it so:
354
366
 
355
- I18n.locales.no = ["nb", "en"];
356
- I18n.locales.no = "nb";
357
- I18n.locales.no = function(locale){ return ["nb"]; };
367
+ ```javascript
368
+ I18n.locales.no = ["nb", "en"];
369
+ I18n.locales.no = "nb";
370
+ I18n.locales.no = function(locale){ return ["nb"]; };
371
+ ```
358
372
 
359
373
  By default a missing translation will be displayed as
360
374
 
@@ -363,7 +377,9 @@ By default a missing translation will be displayed as
363
377
  While you are developing or if you do not want to provide a translation
364
378
  in the default language you can set
365
379
 
366
- I18n.missingBehaviour='guess';
380
+ ```javascript
381
+ I18n.missingBehaviour='guess';
382
+ ```
367
383
 
368
384
  this will take the last section of your scope and guess the intended value.
369
385
  Camel case becomes lower cased text and underscores are replaced with space
@@ -392,61 +408,75 @@ I18n.missingTranslation = function () { return undefined; };
392
408
 
393
409
  Pluralization is possible as well and by default provides English rules:
394
410
 
395
- I18n.t("inbox.counting", {count: 10}); // You have 10 messages
411
+ ```javascript
412
+ I18n.t("inbox.counting", {count: 10}); // You have 10 messages
413
+ ```
396
414
 
397
415
  The sample above expects the following translation:
398
416
 
399
- en:
400
- inbox:
401
- counting:
402
- one: You have 1 new message
403
- other: You have {{count}} new messages
404
- zero: You have no messages
417
+ ```yaml
418
+ en:
419
+ inbox:
420
+ counting:
421
+ one: You have 1 new message
422
+ other: You have {{count}} new messages
423
+ zero: You have no messages
424
+ ```
405
425
 
406
426
  **NOTE:** Rails I18n recognizes the `zero` option.
407
427
 
408
428
  If you need special rules just define them for your language, for example Russian, just add a new pluralizer:
409
429
 
410
- I18n.pluralization["ru"] = function (count) {
411
- var key = count % 10 == 1 && count % 100 != 11 ? "one" : [2, 3, 4].indexOf(count % 10) >= 0 && [12, 13, 14].indexOf(count % 100) < 0 ? "few" : count % 10 == 0 || [5, 6, 7, 8, 9].indexOf(count % 10) >= 0 || [11, 12, 13, 14].indexOf(count % 100) >= 0 ? "many" : "other";
412
- return [key];
413
- };
430
+ ```javascript
431
+ I18n.pluralization["ru"] = function (count) {
432
+ var key = count % 10 == 1 && count % 100 != 11 ? "one" : [2, 3, 4].indexOf(count % 10) >= 0 && [12, 13, 14].indexOf(count % 100) < 0 ? "few" : count % 10 == 0 || [5, 6, 7, 8, 9].indexOf(count % 10) >= 0 || [11, 12, 13, 14].indexOf(count % 100) >= 0 ? "many" : "other";
433
+ return [key];
434
+ };
435
+ ```
414
436
 
415
437
  You can find all rules on <http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html>.
416
438
 
417
439
  If you're using the same scope over and over again, you may use the `scope` option.
418
440
 
419
- var options = {scope: "activerecord.attributes.user"};
441
+ ```javascript
442
+ var options = {scope: "activerecord.attributes.user"};
420
443
 
421
- I18n.t("name", options);
422
- I18n.t("email", options);
423
- I18n.t("username", options);
444
+ I18n.t("name", options);
445
+ I18n.t("email", options);
446
+ I18n.t("username", options);
447
+ ```
424
448
 
425
449
  You can also provide an array as scope.
426
450
 
427
- // use the greetings.hello scope
428
- I18n.t(["greetings", "hello"]);
451
+ ```javascript
452
+ // use the greetings.hello scope
453
+ I18n.t(["greetings", "hello"]);
454
+ ```
429
455
 
430
456
  #### Number formatting
431
457
 
432
458
  Similar to Rails helpers, you have localized number and currency formatting.
433
459
 
434
- I18n.l("currency", 1990.99);
435
- // $1,990.99
460
+ ```javascript
461
+ I18n.l("currency", 1990.99);
462
+ // $1,990.99
436
463
 
437
- I18n.l("number", 1990.99);
438
- // 1,990.99
464
+ I18n.l("number", 1990.99);
465
+ // 1,990.99
439
466
 
440
- I18n.l("percentage", 123.45);
441
- // 123.450%
467
+ I18n.l("percentage", 123.45);
468
+ // 123.450%
469
+ ```
442
470
 
443
471
  To have more control over number formatting, you can use the
444
472
  `I18n.toNumber`, `I18n.toPercentage`, `I18n.toCurrency` and `I18n.toHumanSize`
445
473
  functions.
446
474
 
447
- I18n.toNumber(1000); // 1,000.000
448
- I18n.toCurrency(1000); // $1,000.00
449
- I18n.toPercentage(100); // 100.000%
475
+ ```javascript
476
+ I18n.toNumber(1000); // 1,000.000
477
+ I18n.toCurrency(1000); // $1,000.00
478
+ I18n.toPercentage(100); // 100.000%
479
+ ```
450
480
 
451
481
  The `toNumber` and `toPercentage` functions accept the following options:
452
482
 
@@ -457,9 +487,11 @@ The `toNumber` and `toPercentage` functions accept the following options:
457
487
 
458
488
  See some number formatting examples:
459
489
 
460
- I18n.toNumber(1000, {precision: 0}); // 1,000
461
- I18n.toNumber(1000, {delimiter: ".", separator: ","}); // 1.000,000
462
- I18n.toNumber(1000, {delimiter: ".", precision: 0}); // 1.000
490
+ ```javascript
491
+ I18n.toNumber(1000, {precision: 0}); // 1,000
492
+ I18n.toNumber(1000, {delimiter: ".", separator: ","}); // 1.000,000
493
+ I18n.toNumber(1000, {delimiter: ".", precision: 0}); // 1.000
494
+ ```
463
495
 
464
496
  The `toCurrency` function accepts the following options:
465
497
 
@@ -473,7 +505,9 @@ The `toCurrency` function accepts the following options:
473
505
 
474
506
  You can provide only the options you want to override:
475
507
 
476
- I18n.toCurrency(1000, {precision: 0}); // $1,000
508
+ ```javascript
509
+ I18n.toCurrency(1000, {precision: 0}); // $1,000
510
+ ```
477
511
 
478
512
  The `toHumanSize` function accepts the following options:
479
513
 
@@ -485,35 +519,44 @@ The `toHumanSize` function accepts the following options:
485
519
 
486
520
  <!---->
487
521
 
488
- I18n.toHumanSize(1234); // 1KB
489
- I18n.toHumanSize(1234 * 1024); // 1MB
522
+ ```javascript
523
+ I18n.toHumanSize(1234); // 1KB
524
+ I18n.toHumanSize(1234 * 1024); // 1MB
525
+ ```
526
+
490
527
 
491
528
  #### Date formatting
492
529
 
493
- // accepted formats
494
- I18n.l("date.formats.short", "2009-09-18"); // yyyy-mm-dd
495
- I18n.l("time.formats.short", "2009-09-18 23:12:43"); // yyyy-mm-dd hh:mm:ss
496
- I18n.l("time.formats.short", "2009-11-09T18:10:34"); // JSON format with local Timezone (part of ISO-8601)
497
- I18n.l("time.formats.short", "2009-11-09T18:10:34Z"); // JSON format in UTC (part of ISO-8601)
498
- I18n.l("date.formats.short", 1251862029000); // Epoch time
499
- I18n.l("date.formats.short", "09/18/2009"); // mm/dd/yyyy
500
- I18n.l("date.formats.short", (new Date())); // Date object
530
+ ```javascript
531
+ // accepted formats
532
+ I18n.l("date.formats.short", "2009-09-18"); // yyyy-mm-dd
533
+ I18n.l("time.formats.short", "2009-09-18 23:12:43"); // yyyy-mm-dd hh:mm:ss
534
+ I18n.l("time.formats.short", "2009-11-09T18:10:34"); // JSON format with local Timezone (part of ISO-8601)
535
+ I18n.l("time.formats.short", "2009-11-09T18:10:34Z"); // JSON format in UTC (part of ISO-8601)
536
+ I18n.l("date.formats.short", 1251862029000); // Epoch time
537
+ I18n.l("date.formats.short", "09/18/2009"); // mm/dd/yyyy
538
+ I18n.l("date.formats.short", (new Date())); // Date object
539
+ ```
501
540
 
502
541
  You can also add placeholders to the date format:
503
542
 
504
- I18n.translations["en"] = {
505
- date: {
506
- formats: {
507
- ordinal_day: "%B %{day}"
508
- }
509
- }
543
+ ```javascript
544
+ I18n.translations["en"] = {
545
+ date: {
546
+ formats: {
547
+ ordinal_day: "%B %{day}"
510
548
  }
511
- I18n.l("date.formats.ordinal_day", "2009-09-18", { day: '18th' }); // Sep 18th
549
+ }
550
+ }
551
+ I18n.l("date.formats.ordinal_day", "2009-09-18", { day: '18th' }); // Sep 18th
552
+ ```
512
553
 
513
554
  If you prefer, you can use the `I18n.strftime` function to format dates.
514
555
 
515
- var date = new Date();
516
- I18n.strftime(date, "%d/%m/%Y");
556
+ ```javascript
557
+ var date = new Date();
558
+ I18n.strftime(date, "%d/%m/%Y");
559
+ ```
517
560
 
518
561
  The accepted formats are:
519
562
 
@@ -542,46 +585,176 @@ The accepted formats are:
542
585
 
543
586
  Check out `spec/*.spec.js` files for more examples!
544
587
 
588
+ ## Using multiple exported translation files on a page.
589
+ This method is useful for very large apps where a single contained translations.js file is not desirable. Examples would be a global translations file and a more specific route translation file.
590
+
591
+ ### Rails without asset pipeline
592
+ 1. Setup your `config/i18n-js.yml` to have multiple files and try to minimize any overlap.
593
+
594
+ ```yaml
595
+ sort_translation_keys: true
596
+ fallbacks: false
597
+
598
+ translations:
599
+ + file: "app/assets/javascript/nls/welcome.js"
600
+ only:
601
+ + '*.welcome.*'
602
+
603
+ + file: "app/assets/javascript/nls/albums.js"
604
+ only:
605
+ + '*.albums.*'
606
+
607
+ + file: "app/assets/javascript/nls/global.js"
608
+ only:
609
+ + '*'
610
+ # Exempt any routes specific translations from being
611
+ # included in the global translation file
612
+ except:
613
+ + '*.welcome.*'
614
+ + '*.albums.*'
615
+ ```
616
+ When `rake i18n:js:export` is executed it will create 3 translations files that can be loaded via the `javascript_include_tag`
617
+
618
+ 2. Add the `javascript_include_tag` to your layout and to any route specific files that will require it.
619
+ ```ruby
620
+ # views/layouts/application.html.erb
621
+ <%= javascript_include_tag(
622
+ "i18n"
623
+ "nls/global"
624
+ ) %>
625
+ ```
626
+ and in the route specific
627
+
628
+ ```ruby
629
+ # views/welcome/index.html.erb
630
+ <%= javascript_include_tag(
631
+ "nls/welcome"
632
+ ) %>
633
+ ```
634
+
635
+ 3. Make sure that you add these files to your `config/application.rb`
636
+
637
+ ```ruby
638
+ config.assets.precompile += %w(
639
+ i18n
640
+ nls/*
641
+ )
642
+ ```
643
+
644
+ ### Using require.js / r.js
645
+
646
+ To use this with require.js we are only going to change a few things from above.
647
+
648
+ 1. In your `config/i18n-js.yml` we need to add a better location for the i18n to be exported. You want to use this location so that it can be properly precompiled by r.js.
649
+
650
+ ```yaml
651
+ export_i18n_js: "app/assets/javascript/nls"
652
+ ```
653
+
654
+ 2. In your `config/require.yml` we need to add a map, shim all the translations, and include them into the appropriate modules
655
+
656
+ ```yaml
657
+ # In your maps add (if you do not have this you will need to add it)
658
+ map:
659
+ '*':
660
+ i18n: 'nls/i18n'
661
+
662
+ # In your shims
663
+ shims:
664
+ nls/welcome:
665
+ deps:
666
+ + i18n
667
+
668
+ nls/global:
669
+ deps:
670
+ + i18n
671
+
672
+ # Finally in your modules
673
+ modules:
674
+ + name: 'application'
675
+ include:
676
+ + i18n
677
+ + 'nls/global'
678
+
679
+ + name: 'welcome'
680
+ exclude:
681
+ + application
682
+ include:
683
+ + 'nls/welcome'
684
+ ```
685
+ 3. When `rake assets:precompile` is executed it will optimize the translations into the correct modules so they are loaded with their assigned module, and loading them with requirejs is as simple as requiring any other shim.
686
+
687
+ ```javascript
688
+ define(['welcome/other_asset','nls/welcome'], function (otherAsset){
689
+ // ...
690
+ });
691
+ ```
692
+ 4. (optional) As an additional configuration we can make a task to be run before the requirejs optimizer. This will allow any automated scripts that run the requirejs optimizer to export the strings before we run r.js
693
+
694
+ ```rake
695
+ # lib/tasks/i18n.rake
696
+ Rake::Task[:'i18n:js:export'].prerequisites.clear
697
+ task :'i18n:js:export' => :'i18n:js:before_export'
698
+ task :'requirejs:precompile:external' => :'i18n:js:export'
699
+
700
+ namespace :i18n do
701
+ namespace :js do
702
+ task :before_export => :'assets:environment' do
703
+ I18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{yml,rb}')]
704
+ I18n.backend.load_translations
705
+ end
706
+ end
707
+ end
708
+ ```
709
+
545
710
  ## Using I18n.js with other languages (Python, PHP, ...)
546
711
 
547
712
  The JavaScript library is language agnostic; so you can use it with PHP, Python, [your favorite language here].
548
713
  The only requirement is that you need to set the `translations` attribute like following:
549
714
 
550
- I18n.translations = {};
715
+ ```javascript
716
+ I18n.translations = {};
551
717
 
552
- I18n.translations["en"] = {
553
- message: "Some special message for you"
554
- }
718
+ I18n.translations["en"] = {
719
+ message: "Some special message for you"
720
+ }
555
721
 
556
- I18n.translations["pt-BR"] = {
557
- message: "Uma mensagem especial para você"
558
- }
722
+ I18n.translations["pt-BR"] = {
723
+ message: "Uma mensagem especial para você"
724
+ }
725
+ ```
559
726
 
560
727
  ## Known Issues
561
728
 
562
729
  ### Missing translations in precompiled file(s) after adding any new locale file
563
730
 
564
731
  Due to the design of `sprockets`:
732
+
565
733
  - `depend_on` only takes file paths, not directory paths
566
- - registered `preprocessors` are only run when fingerprint of any asset file, including `.erb` files, is changed
734
+ - registered `preprocessors` are only run when the fingerprint of any asset file, including `.erb` files, is changed
567
735
 
568
- New locale files won't be picked up unless any existing locale file content is changed.
569
- You can workaround it manually by running
570
- ```bash
571
- $ rake assets:clobber
572
- ```
573
- to clear the asset cache.
574
- **Or**
575
- Change something in existing locale file.
576
- **Or**
577
- Change `config.assets.version`
736
+ This means that new locale files will not be detected, and so they will not trigger a i18n-js refresh. There are a few approaches to work around this:
737
+
738
+ 1. You can force i18n-js to update its translations by completely clearing the assets cache. Use one of the following:
739
+
740
+ ```bash
741
+ $ rake assets:clobber
742
+ # Or, with older versions of Rails:
743
+ $ rake tmp:cache:clear
744
+ ```
745
+
746
+ These commands will remove *all* fingerprinted assets, and you will have to recompile them with
578
747
 
579
- **Note:** `rake assets:clobber` will also remove all fingerprinted assets.
580
- If you are precompiling assets on target machine(s),
581
- old assets might be removed and cannot be served in cached pages.
748
+ ```
749
+ $ rake assets:precompile
750
+ ```
751
+ or similar commands. If you are precompiling assets on the target machine(s), cached pages may be broken by this, so they will need to be refreshed.
752
+
753
+ 2. You can change something in a different locale file.
582
754
 
583
- Please see issue #213 for detail & related discussion.
755
+ 3. Finally, you can change `config.assets.version`.
584
756
 
757
+ **Note:** See issue [#213](https://github.com/fnando/i18n-js/issues/213) for more details and discussion of this issue.
585
758
 
586
759
  ## Maintainer
587
760