this is the @magic-modules LanguageSwitch component. It provides a dynamic language switch menu
it redirects your current page to any of the other language versions that exist, but also assumes that there are alternatives for every language.
npm install --save-exact @magic-modules/language-switch
// in any component View
export const View = state => div({ class: 'page' }, LanguageSwitch(state)),
}
create your languages in the pages directory, for example:
/pages/
index.js // english page
/de/
index.js // german page
LanguageSwitch needs to know about the languages in your app.
// /assets/app.js
export const state = {
// ... other app state
languages: [
// the first language is the default fallback
{ code: 'en', to: '/', text: 'english' },
{ code: 'de', to: '/de/', text: 'deutsch' },
],
}
thats it, your magic app now knows about your languages
first release
bump required node version to 14.2.0
bump required node version to 14.15.4
do not use root to build language link to value
- allow multiple languages to be shown correctly
update dependencies
...