i18n: fixes translations for plugins before v12.1.0 (#109948)

i18n: fixes translated plugins before 12.1.0
This commit is contained in:
Hugo Häggmark 2025-08-21 13:06:50 +02:00 committed by GitHub
parent 429cb9d916
commit bba89fdb42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 2 deletions

View File

@ -89,8 +89,15 @@ export async function initPluginTranslations(id: string, loaders?: ResourceLoade
return { language };
}
export function getI18nInstance() {
return i18n;
export function getI18nInstance(): typeof i18n {
// in Grafana versions < 12.1.0 the i18n instance is exposed through the default export
// used by plugins that support translations from Grafana >= 11.0.0
const instance: typeof i18n & { default?: typeof i18n } = i18n;
if (instance && instance.default) {
return instance.default;
}
return instance;
}
interface Module {