Customer account extensions do not render locales when the language is not in its market. So, we might be in the spanish market, which does not have the french language included, in the french language, and I am getting these errors:
The error is consistent, since it does not only affect the extensions developed in-house, but also any third-party extension, as in the InPost extension depicted in the image.
If we add all languages to the market it works again, but this is going against the merchantâs business model.
There is an ongoing issue with previews and the cli on development environment for the customer accounts. Is it related?
In our case, we encountered i18n issues within both the customer account and the checkout pages. Upon investigating our theme, we discovered that interactions with the Cart Ajax API had been implemented without locale-aware URLs.
Resolving this seems to have fixed the incorrect market/language attribution. This makes sense for the checkoutâif the cart contains conflicting signals regarding a productâs origin or the customer journey, the system defaults. However, it remains a bit less clear why this specific fix also resolved the issues within the customer accounts.
@0_0 I have also struggled with this and I have found a workaround for the extensions I have built myself. Since this seems to be a bug in the translate function, I have just built my own:
Create a LocaleHelper.ts file in the src folder of your extension with this code, adjust the locale imports and default locale to your needs:
import en from '../locales/en.default.json';
import de from '../locales/de.json';
import fr from '../locales/fr.json';
import it from '../locales/it.json';
import nl from '../locales/nl.json';
import pl from '../locales/pl.json';
const LOCALES = { de, en, fr, it, nl, pl };
export function translate(locale: string, key: string): string {
const language = getLanguage(locale);
const localeData = LOCALES[language];
return (localeData as Record<string, string>)[key]
?? (en as Record<string, string>)[key]
?? key;
}
Then import the translate function from this file in your extension and use it by passing the current locale and the translation-key for the text you want to translate:
Keep in mind this does not work with dynamic placeholders out of the box. But you could chain a string replace function to the translate function call to do the replacement of the placeholder manually.
@felix-wiethoelter Thank you for sharing!
One problem still is the menu which is buggy as well, I can create a menu extension but that would mess up the layoutâŠ