README.md in i18n-js-3.0.0.rc7 vs README.md in i18n-js-3.0.0.rc8

- old
+ new

@@ -119,10 +119,69 @@ - Any `String`: considered as a relative path for a folder to `Rails.root` and export `i18n.js` to that folder for `rake i18n:js:export` - `nil`: Disable `i18n.js` exporting To find more examples on how to use the configuration file please refer to the tests. +##### Fallbacks + +If you specify the `fallbacks` option, you will be able to fill missing translations with those inside fallback locale(s). +Default value is `true`. + +Examples: +```yaml +fallbacks: true + +translations: +- file: "public/javascripts/i18n/%{locale}.js" + only: '*' +``` +This will enable merging fallbacks into each file. (set to `false` to disable). +If you use `I18n` with fallbacks, the fallbacks defined there will be used. +Otherwise `I18n.default_locale` will be used. + +```yaml +fallbacks: :de + +translations: +- file: "public/javascripts/i18n/%{locale}.js" + only: '*' +``` +Here, the specified locale `:de` will be used as fallback for all locales. + +```yaml +fallbacks: + fr: ["de", "en"] + de: "en" + +translations: +- file: "public/javascripts/i18n/%{locale}.js" + only: '*' +``` +Fallbacks defined will be used, if not defined (e.g. `:pl`) `I18n.fallbacks` or `I18n.default_locale` will be used. + +```yaml +fallbacks: :default_locale + +translations: +- file: "public/javascripts/i18n/%{locale}.js" + only: '*' +``` +Setting the option to `:default_locale` will enforce the fallback to use the `I18n.default_locale`, ignoring `I18n.fallbacks`. + +Examples: +```yaml +fallbacks: false + +translations: +- file: "public/javascripts/i18n/%{locale}.js" + only: '*' +``` +You must disable this feature by setting the option to `false`. + +To find more examples on how to use the configuration file please refer to the tests. + + #### Vanilla JavaScript Just add the `i18n.js` file to your page. You'll have to build the translations object by hand or using your favorite programming language. More info below. @@ -317,9 +376,20 @@ I18n.l("time.formats.short", "2009-11-09T18:10:34"); // JSON format with local Timezone (part of ISO-8601) I18n.l("time.formats.short", "2009-11-09T18:10:34Z"); // JSON format in UTC (part of ISO-8601) I18n.l("date.formats.short", 1251862029000); // Epoch time I18n.l("date.formats.short", "09/18/2009"); // mm/dd/yyyy I18n.l("date.formats.short", (new Date())); // Date object + +You can also add placeholders to the date format: + + I18n.translations["en"] = { + date: { + formats: { + ordinal_day: "%B %{day}" + } + } + } + I18n.l("date.formats.ordinal_day", "2009-09-18", { day: '18th' }); // Sep 18th If you prefer, you can use the `I18n.strftime` function to format dates. var date = new Date(); I18n.strftime(date, "%d/%m/%Y");