Multi-language support in PIE and pie-cookie-banner
#809
Replies: 2 comments 4 replies
-
Thanks for the write up @fernandofranca, it makes a lot of sense. I did wonder, could one alternate approach (basically your alternate flexible suggestion) be to store the translations in a separate package/export and have the consumer import it and pass down the appropriate translations object to the cookie banner at runtime? We still guarantee the copy is consistent but add some decoupling which could help with bundle size performance I think. Something like: import { en, de } from '@justeattakeaway/pie-cookie-banner-translations'; // OR something like '@justeattakeaway/pie-cookie-banner/translations'
import { PieCookieBanner } from '@justeattakeaway/pie-cookie-banner/react';
// arbitrary example of choosing a translation
const cookieTranslations = applicationLocale === 'de' ? de : en;
<PieCookieBanner copy={cookieTranslations}></PieCookieBanner> In any case, your solution seems excellent. Great stuff! 🎉 |
Beta Was this translation helpful? Give feedback.
-
@fernandofranca nice one, i have read through it and it LGTM. I had one question: Regarding the e.g function configureLocale(locale) {
const { setLocale } = configureLocalization({
sourceLocale,
targetLocales,
loadLocale: async (locale) => availableLocales[locale],
});
}
function initLocaleComponent(WrappedComponent) {
return class extends WrappedComponent {
constructor() {
super();
configureLocale(this.locale);
}
};
}
// Then here at the end which is where i think the error may not appear although did not test..
export default initLocaleComponent(MyComponent); |
Beta Was this translation helpful? Give feedback.
-
As a follow-up for the DSW-1195 spike (already published on Confluence), this discussion was created to gather opinions and ideas about how to handle the translation of the
pie-cookie-banner
component.These are some of the themes I believe might be worth discussing:
@lit/localize
library, what would be the best way to handle the translation of thepie-cookie-banner
component?Beta Was this translation helpful? Give feedback.
All reactions