We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@strapi/sdk-plugin
The translation files aren't picked up properly. In the past, there was a helper function that converted the object into an array
const importedTrads = await Promise.all( locales.map((locale) => { return import(`./translations/${locale}.json`) .then(({ default: data }) => { return { data: prefixPluginTranslations(data, pluginId), // <--- this helper locale, }; }) .catch(() => { return { data: {}, locale, }; }); }) );
but that is gone when creating a new plugin with this package
Translation files should work automatically, I tested using the helperFunction and it worked https://github.com/strapi/strapi/blob/504076d2165a82f124620a3f1f3e3a6017e97f3f/packages/core/email/admin/src/utils/prefixPluginTranslations.ts
Complete working example:
import { getTranslation } from './utils/getTranslation'; import { PLUGIN_ID } from './pluginId'; import { Initializer } from './components/Initializer'; import { PluginIcon } from './components/PluginIcon'; export default { register(app: any) { app.addMenuLink({ to: `plugins/${PLUGIN_ID}`, icon: PluginIcon, intlLabel: { id: `${PLUGIN_ID}.plugin.name`, defaultMessage: PLUGIN_ID, }, Component: async () => { const { App } = await import('./pages/App'); return App; }, }); app.registerPlugin({ id: PLUGIN_ID, initializer: Initializer, isReady: false, name: PLUGIN_ID, }); }, async registerTrads(app: any) { const { locales } = app; const importedTranslations = await Promise.all( (locales as string[]).map((locale) => { return import(`./translations/${locale}.json`) .then(({ default: data }) => { return { data: prefixPluginTranslations(data, PLUGIN_ID), locale, }; }) .catch(() => { return { data: {}, locale, }; }); }) ); return importedTranslations; }, }; type TradOptions = Record<string, string>; const prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => { if (!pluginId) { throw new TypeError("pluginId can't be empty"); } return Object.keys(trad).reduce((acc, current) => { acc[`${pluginId}.${current}`] = trad[current]; return acc; }, {} as TradOptions); };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What version of
@strapi/sdk-plugin
are you using?What's Wrong?
The translation files aren't picked up properly.
In the past, there was a helper function that converted the object into an array
but that is gone when creating a new plugin with this package
To Reproduce
Expected Behaviour
Translation files should work automatically, I tested using the helperFunction and it worked
https://github.com/strapi/strapi/blob/504076d2165a82f124620a3f1f3e3a6017e97f3f/packages/core/email/admin/src/utils/prefixPluginTranslations.ts
Complete working example:
The text was updated successfully, but these errors were encountered: