Skip to content

translations

github-actions[bot] edited this page Nov 28, 2024 · 1 revision

Translations (alpha)

The plugin supports translations. To add a new language, create a new file in packages/app/src/locales with the language code (e.g. qeta-fi.ts). Create the translations as described here https://backstage.io/docs/plugins/internationalization/ using the qetaTranslationRef from @drodil/backstage-plugin-qeta as the translation reference:

// packages/app/src/locales/qeta-fi.ts
import { qetaTranslationRef } from '@drodil/backstage-plugin-qeta';
import { createTranslationMessages } from '@backstage/core-plugin-api/alpha';

const fi = createTranslationMessages({
  ref: qetaTranslationRef,
  full: false,
  translations: {
    'answerList.errorLoading': 'Vastauksia ei voitu ladata',
    'answerList.noAnswers': 'Ei vastauksia',
  },
});

export default fi;

Then add the translation to your packages/app/src/App.tsx:

import { createTranslationResource } from '@backstage/core-plugin-api/alpha';
import { qetaTranslationRef } from '@drodil/backstage-plugin-qeta';

const app = createApp({
  //...
  __experimentalTranslations: {
    availableLanguages: ['en', 'fi'],
    resources: [
      createTranslationResource({
        ref: qetaTranslationRef,
        translations: {
          fi: () => import('./locales/qeta-fi'),
        },
      }),
    ],
  },
});

Using predefined translations

You can also use the predefined translations from the plugin:

import { qetaTranslations } from '@drodil/backstage-plugin-qeta';

const app = createApp({
  //...
  __experimentalTranslations: {
    availableLanguages: ['en', 'fi'],
    resources: [qetaTranslations],
  },
});

Note that these translations might not contain your desired language. If you want to add a new language, you need to contribute it to the plugin in plugins/qeta/src/locales/ and add it in the plugins/qeta/src/translation.ts with the right language code.

Clone this wiki locally