gulp-pug-i18n
i18n library for Pug (previously Jade). This plugin extends gulp-pug with i18n functionality.
How to use?
var gulp = ;var pug = ; gulp;
Configuration
Module function takes an object for configuration.
data
object
(optional) Pass additional data (including functions) to Pug.
Example: A Markdown function to use in template: { md: require('marked') }
i18n
object
locales
(required) Path to search for i18n files. Supports glob patterns.
Example: src/locale/*.{yml,json}
namespace
(optional) Default value: $i18n
Set to null to use root scope.
default
(optional) Specify a default locale. Plugin will remove single curly braces if it matches the current locale to the default locale that is set. For more information check Advanced Usage below.
filename
(optional) How to name rendered Pug (Jade) files. Supports directories.
Available variables:
- Filename related:
basename
,origname
,origext
- Locale related:
lang
,script
,region
,sort
Note: Add _lower
to variable for lowercase, _upper
for uppercase.
Default value: {{basename}}.{{lang}}.html
Advanced usage
Using single curly braces outside a double braces will make that variable only show if it's not empty.
For example if we use {{basename}}{.{{lang}}}{-{{region}}}.html
, lang or region will be printed only if they are not empty.
en_US
→index.en-US.html
en
→index.en.html
de_DE
→index.de-DE.html
_DE
→index-DE.html
(we are using this only to show this example, don't use like this)
Another example: {{basename}}{-{{lang}}}{-{{region}}}.html
, default locale is en
en
→index.html
tr
→index-tr.html