Sails JS hook to allow internationalization using the i18n module.
This is essentially a port of the Sails v0.12.x core i18n hook. Sails 1.0 uses the more lightweight i18n-2 module, so if you're missing some of the features from i18n
, this hook's for you!
npm install --save sails-hook-i18n
See the Sails internationalization docs for the basics of using i18n with Sails.
See the i18n module README for full documentation -- any property set on sails.config.i18n
(in the config/i18n.js
file) will be passed directly in to the i18n
module. Below are some common config properties.
Property | Type | Default | Details |
---|---|---|---|
locales |
((array)) | ['en','es','fr','de'] | List of supported locale codes |
localesDirectory |
((string)) | '/config/locales' | The project-relative path to the folder containing your locale translations (i.e. stringfiles) |
defaultLocale |
((string)) | 'en' | The default locale for the site. Note that this setting will be overridden for any request that sends an "Accept-Language" header (i.e. most browsers), but it's still useful if you need to localize the response for requests made by non-browser clients (e.g. cURL). |
updateFiles |
((boolean)) | false | Whether to automatically add new keys to locale (translation) files when they are encountered during a request. |