Quick project put together to test for ways to create multilanguage sites using Harp
/harp.json
/public
/en
_data.json
...
/es
_data.json
...
/_layout.jade
Used to specify a default language. In this case 'en'.
{
"globals": {
"default_lang": "en"
}
}
Translation for the navigation menu goes in these files. This could be done in other ways, but the purpose of it was to separate structure from content.
We used some inline javascript to detect the selected language.
For this particular case we made /
ask you to choose a language, /en
to go to english and /es
to go to spanish. But you could figure out a way to show /en
by default when you go to /
.
You could also remove the need to add translations to /{lang}/_data.json
by moving the the navigation markup to each language directory. Which would work really nice for smaller sites.