diff --git a/README.md b/README.md index b46e061..41f350b 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,10 @@ will access to `another-key` in `new-ns.yaml`. Be sure to add your namespace nam "i18n": { ... "ns": ["default", "new-ns"] } +additionally, use `intlbase` to wrap path with a i18n based relative path: + + a(href=intlbase('/faq')) + ## TODO diff --git a/bin/lib/build/pug.js b/bin/lib/build/pug.js index 4a67d93..fd6c490 100644 --- a/bin/lib/build/pug.js +++ b/bin/lib/build/pug.js @@ -1,6 +1,7 @@ // Generated by LiveScript 1.6.0 -var fs, fsExtra, pug, livescript, stylus, path, jsYaml, marked, aux, lc, mdOptions, pugExtapi, main; +var fs, path, fsExtra, pug, livescript, stylus, jsYaml, marked, aux, lc, mdOptions, pugExtapi, main; fs = require('fs'); +path = require('path'); fsExtra = require('fs-extra'); pug = require('pug'); livescript = require('livescript'); @@ -73,6 +74,14 @@ main = { pugExtapi.i18n = function(it){ return opt.i18n.t(it); }; + pugExtapi.intlbase = function(p){ + p == null && (p = ""); + if (opt.i18n.language) { + return path.join("/intl", opt.i18n.language, p); + } else { + return p; + } + }; (pugExtapi.filters || (pugExtapi.filters = {})).i18n = function(t, o){ return opt.i18n.t(t); }; diff --git a/lib/build/pug.ls b/lib/build/pug.ls index d2afe0f..007d4c6 100644 --- a/lib/build/pug.ls +++ b/lib/build/pug.ls @@ -1,4 +1,4 @@ -require! <[fs fs-extra pug livescript stylus path js-yaml marked ./aux]> +require! <[fs path fs-extra pug livescript stylus path js-yaml marked ./aux]> lc = {i18n: {}} md-options = html: {breaks: true, renderer: new marked.Renderer!} @@ -33,6 +33,7 @@ main = do opt: (opt = {}) -> if opt.i18n => pug-extapi.i18n = -> opt.i18n.t(it) + pug-extapi.intlbase = (p = "") -> if opt.i18n.language => path.join("/intl",opt.i18n.language,p) else p pug-extapi.{}filters.i18n = (t, o) -> opt.i18n.t(t) lc.i18n = opt.i18n map: (list) -> diff --git a/src/pug/index.pug b/src/pug/index.pug index b7772c5..5c1ada4 100644 --- a/src/pug/index.pug +++ b/src/pug/index.pug @@ -21,3 +21,4 @@ html i18n key filter div= i18n("i18n key") div= i18n("alternative:namespace-test") + div= intlbase("/") diff --git a/static/index.html b/static/index.html index 93d3cc5..829a3b7 100644 --- a/static/index.html +++ b/static/index.html @@ -9,4 +9,4 @@ div.textContent = "livescript filter test";