i18n plugin for Wintersmith
Using wintersmith:
wintersmith plugin install i18n
Manually:
npm install --save wintersmith-i18n
Then add wintersmith-i18n
to your plugins list in wintersmith's config.json
.
Set the locales you want in your config.json
, like so:
{
"i18n": {
"locales": ["en", "it", "sv", "ja"]
}
}
The default directory is ./locales
resolved from your project root.
See https://github.com/mashpie/i18n-node#list-of-all-configuration-options for all options.
The plugin will make the standard i18n functions (__
, __n
, etc.) available globally in your templates.
You also must call setLocale
with the locale you want to use, the method returns the locale or the default locale if no matching locale is found. Which is convenient for doing this:
<html lang="{{ setLocale('sv') }}">
..
<p>{{ __('Do you like turtles?') }}
See the example/
directory for a complete usage example.