* scaffolding for grafana-prometheus i18n * markup * extract translations * fix tests * add loadResources + fix object properties * fix typo + prettier * remove useTranslate * update workflow to trigger on changes to grafana-sql/grafana-prometheus packages
12 lines
471 B
TypeScript
12 lines
471 B
TypeScript
import { LANGUAGES, ResourceLoader, Resources } from '@grafana/i18n';
|
|
|
|
const resources = LANGUAGES.reduce<Record<string, () => Promise<{ default: Resources }>>>((acc, lang) => {
|
|
acc[lang.code] = async () => await import(`./locales/${lang.code}/grafana-prometheus.json`);
|
|
return acc;
|
|
}, {});
|
|
|
|
export const loadResources: ResourceLoader = async (resolvedLanguage: string) => {
|
|
const translation = await resources[resolvedLanguage]();
|
|
return translation.default;
|
|
};
|