Search code examples
internationalizationgulptemplate-engineprerendermarko

generate html template engine i18n


I am searching for a solution to modularize static html files and to add multilanguage support. I want to generate static html files with gulp which are then served through an apache server.

I am now thinking about using the template engine marko to modularize html files and to prerender html files (handlebars would also be an option; jade is no option cause i don't like the syntax).

For multilanguage support i am thinking about to add an i18n plugin (for example https://www.npmjs.com/package/i18n). But this plugin needs an express server; also for multilanguage i want to prerender the files. Has anybody a hint for me which i18n plugin would best fit for me? Maybe also which one would best work together with marko and gulp?

The result should be html files generated inside /de and /en.


Solution

  • The following sample app might help: https://github.com/marko-js-samples/marko-koa-i18n

    It is a server-based app that uses Koa and koa-i18n, but you can directly use i18n-2 to accomplish the same thing.

    Disclaimer: I have not used i18n-2 or koa-i18n

    A few things to note:

    The following Gulp plugin is currently out-of-date, but it might serve as a good starting point or you can submit a PR to improve it: https://github.com/viviangledhill/gulp-marko

    In your case, you will want to prerender each template multiple times, each time with a different i18n bundle instance passed in as a global property.

    If you would like more details please ask here or in the Gitter chat room: https://gitter.im/marko-js/marko

    Hope that helps.