diff --git a/.eslintignore b/.eslintignore index 60181e855a4..012f471e24a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -17,7 +17,7 @@ vendor # TS generate from cue by cuetsy **/*.gen.ts -# Auto-generated localisation files +# Auto-generated internationalization files public/locales/_build/ public/locales/**/*.js diff --git a/.gitignore b/.gitignore index 3deb19b8a6b..e0d745fae40 100644 --- a/.gitignore +++ b/.gitignore @@ -162,7 +162,7 @@ compilation-stats.json !pkg/coremodel/**/*_gen.go !pkg/framework/**/*_gen.go -# Auto-generated localisation files +# Auto-generated internationalization files public/locales/_build/ public/locales/**/*.js diff --git a/.prettierignore b/.prettierignore index 9e089437f68..ab2787f4961 100644 --- a/.prettierignore +++ b/.prettierignore @@ -18,7 +18,7 @@ vendor # TS generate from cue by cuetsy **/*.gen.ts -# Auto-generated localisation files +# Auto-generated internationalization files public/locales/_build/ public/locales/**/*.js diff --git a/contribute/localization.md b/contribute/internationalization.md similarity index 95% rename from contribute/localization.md rename to contribute/internationalization.md index 97a220732b8..0e32a685e7b 100644 --- a/contribute/localization.md +++ b/contribute/internationalization.md @@ -1,4 +1,4 @@ -# Localisation +# Internationalization Grafana uses the [LinguiJS](https://github.com/lingui/js-lingui) framework for managing translating phrases in the Grafana frontend. @@ -59,7 +59,7 @@ For components used all over the site, use just two segments: ### Top-level provider -In [AppWrapper.tsx](/public/app/AppWrapper.tsx) the app is wrapped with `I18nProvider` from `public/app/core/localisation.tsx` where the Lingui instance is created with the user's preferred locale. This sets the appropriate context and allows any component from `@lingui/macro` to use the translations for the user's preferred locale. +In [AppWrapper.tsx](/public/app/AppWrapper.tsx) the app is wrapped with `I18nProvider` from `public/app/core/internationalization/index.tsx` where the Lingui instance is created with the user's preferred locale. This sets the appropriate context and allows any component from `@lingui/macro` to use the translations for the user's preferred locale. ### Message format diff --git a/public/app/AppWrapper.tsx b/public/app/AppWrapper.tsx index 838ac06bd4a..0f4627e338c 100644 --- a/public/app/AppWrapper.tsx +++ b/public/app/AppWrapper.tsx @@ -15,7 +15,7 @@ import { GrafanaApp } from './app'; import { AppChrome } from './core/components/AppChrome/AppChrome'; import { AppNotificationList } from './core/components/AppNotifications/AppNotificationList'; import { NavBar } from './core/components/NavBar/NavBar'; -import { I18nProvider } from './core/localisation'; +import { I18nProvider } from './core/internationalization'; import { GrafanaRoute } from './core/navigation/GrafanaRoute'; import { RouteDescriptor } from './core/navigation/types'; import { contextSrv } from './core/services/context_srv'; diff --git a/public/app/core/localisation.tsx b/public/app/core/internationalization/index.tsx similarity index 94% rename from public/app/core/localisation.tsx rename to public/app/core/internationalization/index.tsx index d3a44a3175a..4004759b71a 100644 --- a/public/app/core/localisation.tsx +++ b/public/app/core/internationalization/index.tsx @@ -4,7 +4,7 @@ import React, { useEffect } from 'react'; import config from 'app/core/config'; -import { messages } from '../../locales/en/messages'; +import { messages } from '../../../locales/en/messages'; let i18nInstance: I18n; @@ -15,7 +15,7 @@ export async function getI18n(locale = 'en') { // Dynamically load the messages for the user's locale const imp = config.featureToggles.internationalization && - (await import(`../../locales/${locale}/messages`).catch((err) => { + (await import(`../../../locales/${locale}/messages`).catch((err) => { // TODO: Properly return an error if we can't find the messages for a locale return err; })); diff --git a/public/test/helpers/TestProvider.tsx b/public/test/helpers/TestProvider.tsx index ba71a620dfa..c3b0e8fe06f 100644 --- a/public/test/helpers/TestProvider.tsx +++ b/public/test/helpers/TestProvider.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { I18nProvider } from '../../app/core/localisation'; +import { I18nProvider } from '../../app/core/internationalization'; const TestProvider: React.FC = ({ children }) => { return {children};