Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1.2 KB
Raw Blame
import { getDeploymentBaseUrl } from '@platform/transport/deploymentBase';
import i18n from 'i18next';
import Backend from 'i18next-http-backend';
import { initReactI18next } from 'react-i18next';

import { getEffectiveWorkbenchLanguage, normalizeWorkbenchLanguage } from './languages';

void i18n
  .use(Backend)
  .use(initReactI18next)
  .init({
    backend: {
      loadPath: (_languages: readonly string[], namespaces: readonly string[]) =>
        `${getDeploymentBaseUrl()}/locales/{{lng}}${
          namespaces[0] === 'fonts' || namespaces[0] === 'metadata' ? `.${namespaces[0]}` : ''
        }.json`,
      // Changes with locale content, so a release never reads the previous one's cached translations; the service
      // worker caches only these versioned URLs.
      queryStringParams: { v: import.meta.env.LOCALE_VERSION },
    },
    lng: getEffectiveWorkbenchLanguage(normalizeWorkbenchLanguage(globalThis.document?.documentElement.lang) ?? 'en'),
    debug: false,
    fallbackLng: 'en',
    fallbackNS: 'translation',
    ns: ['translation'],
    defaultNS: 'translation',
    interpolation: {
      escapeValue: false,
    },
    returnNull: false,
  });

export default i18n;