This helper helps you to localize your email templates created with zurbs panini. Currently this helper will only work in a custom clone of the panini code and not as a panini-helper as described here.
Make a clone of the panini source
git clone https://github.com/zurb/panini.git
Add the localization.js to the helpers folder.
Register the new handler in render.js#61:
this.Handlebars.registerHelper('localize', require('../helpers/localize')(pageData.page));
Now reference your extended clone in your email project package.json
.
The helper is searching for statements like this {{#localize}}paragraphXY{{/localize}}
. paragraphXY
is the key inside the localize JSON. Based on the current page-name the helper will look up in the localization folder for files with the same name. But it is a little bit smarter. It will also look for files wich start with the same string. If your page is called for example Foo.Bar.Page1.pl-PL.html
, the following localization files will be crawled:
Foo.json
Foo.PL.json
Foo.pl-PL.json
Foo.Bar.json
Foo.Bar.PL.json
Foo.Bar.Page1.json
Foo.Bar.Page1.PL.json
Foo.Bar.Page1.pl-PL.json
Let's say you have a very common localization string like a contact email wich is for all your emails in all languages the same. And you don't want to put this email address inside the partial or template. Now you can put this email into Foo.json
. But for a single language your want an other email address, just override it in Foo.pl-PL.sjon
.
Another scenario could be to have a email for a whole country, then put this into Foo.us.json
for example. Now all us pages will inherit this value (unless they do not have their own value).
Very straight forward - use key and value:
{
"key1": "hello",
"key2": "world"
}
You can create your project with the following structure:
src\layouts\Brand1.Project.html
src\layouts\Brand2.Project.html
src\localization\Brand1.Project.json
src\localization\Brand1.Project.en.json
src\localization\Brand1.Project.en-US.json
src\localization\Brand1.Project.de.json
src\localization\Brand1.Project.de-DE.json
src\localization\Brand1.Project.de.json
src\localization\Brand1.Project.Page1.json
src\localization\Brand1.Project.Page1.en.json
src\localization\Brand1.Project.Page1.en-US.json
src\localization\Brand1.Project.Page1.de.json
src\localization\Brand1.Project.Page1.de-DE.json
src\localization\Brand1.Project.Page1.de.json
src\pages\Brand1.Project.Page1.html
src\pages\Brand1.Project.Page1.en.html
src\pages\Brand1.Project.Page1.en-US.html
src\pages\Brand1.Project.Page1.de.html
src\pages\Brand1.Project.Page1.de-DE.html
src\pages\Brand1.Project.Page1.de.html
src\pages\Brand1.Project.Page1.html (contains the page content)
src\pages\Brand1.Project.Page1.us.html (contains us-specific stuff like other address format)
how it work?