static-i18n-jade-brunch
This is a simple fork to static-jade-brunch which adds support to i18n using the amazing i18n-node module.
Just like with static-jade-brunch, this plugin converts your jade templates into html before publishing. However, it creates multiple versions of each html, one for each locale that you defined.
For instance, you can configure your brunch as:
exports.config: ... plugins: i18n: locales: 'en''de'
For each jade template, this plugin will create a en.html and de.html file.
index.jade is not converted
And for each locale, the i18n-node module will create a file inside a directory called locales in the root of your project. It will also keep it updated to untranslated strings, so that you know what you still have to translate.
If before the brunch compilation the directory structure is something like:
app
| assets
| | font
| | img
| scripts
| styles
| partials
| | presentation.jade
| index.jade
after the brunch build
the content of app directory would be like:
| assets
| | font
| | img
| | partials
| | | presentation.en.html
| | | presentation.de.html
| | index.html
| scripts
| styles
| partials
| | presentation.jade
| index.jade
and the content of the public/
directory:
css
| ...
js
| app.js
| templates.js
| vendor.js
partials
| presentation.en.html
| presentation.de.html
index.html
TODO: add examples on how to use the translator helper inside jade templates.
Usage
Add "jade-brunch": "x.y.z"
and "static-i18n-jade-brunch": "x.y.z"
to package.json
of your brunch app.
Pick a plugin version that corresponds to your minor (y) brunch version.
If you want to use git version of plugin, add:
"jade-brunch": "git+ssh://git@github.com:brunch/jade-brunch.git"
"static-i18n-jade-brunch": "git+ssh://git@github.com:airmind/static-i18n-jade-brunch.git"
Useful convensions
Brunch concatenates all your files in app/
, test/
and vendor/
directories to two files by default:
app.js
contains your application code.vendor.js
contains code of libraries you depend on (e.g. jQuery).
To avoid the inclusion of compiled jade file in app.js
by the jade-brunch
plugin, is possible to add a template
file handler that point to a different output file. Inside config.coffee:
templates: joinTo: 'js/templates.js': /.+\.jade$/
The brunch
compiler ignore each file starting with _
(underscore) and that is useful for the chunks of jade that are included or extended.
The brunch
compiler copy the content of the assets/
directory without recompile it.
To permit others plugin (eg. auto-reload-brunch plugin) to manage the files generated by static-i18n-jade-brunch
, all the generated files are placed inside the assets/
directory.
Configuration Options
The plugin can be configured to filter wich file to compile and to place in the assets
directory, it can:
- build only the files inside the directories that match a regular expression in the
config.plugins.static_jade.path
array. (best) - build only the files that end with the extension specified by
config.plugins.static_jade.extension
string. - place the output files in the relative path specified in
asset
option (app/assets
by default). It can be useful when the project is using more assets directories (see config.conventions.assets)
Config example:
plugins: jade: pretty: yes # Adds pretty-indentation whitespaces to output (false by default) static_jade: # all optionals extension: ".static.jade" # static-compile each file with this extension in `assets` path: /appdocs/ # static-compile each file in this directories asset: "app/jade_asset" # specify the compilation output i18n: locale: 'en''de'# an array of locales to use
License
Copyright (c) 2012 Alexandre Rosenfeld.
Licensed under the MIT license.