Namespaces

ovok.locales and ovok.localizations

Manage the languages a project supports and its translation entries.

  • Stable unknown
  • Release candidate since 0.4.49-rc.4
  • Development since 0.4.49-dev.517+4645a0a

ovok.locales holds the project's list of supported languages and its default language. ovok.localizations holds the translation entries for each language. Both are admin tools: call them from a console or a server client with the right project role, not from a patient app.

Set the supported languages

const locales = await ovok.locales.retrieve();

await ovok.locales.update({
  languages: ['en', 'de', 'fr'],
  defaultLanguage: 'en',
});
  • update sends a PATCH and resolves to the saved locales.

Read and edit translation entries

Entries are keyed by language and translation key.

const { total, resources } = await ovok.localizations.list('de', { search: 'welcome', _count: 20 });

const entry = await ovok.localizations.retrieve('de', 'home.welcome');

await ovok.localizations.update('de', 'home.welcome', { value: 'Willkommen' });
await ovok.localizations.delete('de', 'home.welcome');
  • list resolves to one page, { total, resources }. Page with _count and _offset.
  • update sets the entry with a PUT, so it creates a missing key.

Work with i18next documents

ovok.localizations.i18next reads and writes a whole language as one i18next document, so a client can load all strings in one request.

const document = await ovok.localizations.i18next.retrieve('de');

await ovok.localizations.i18next.update('de', { home: { welcome: 'Willkommen' } });
  • update patches the document. The server queues the write (202), so a read right after may not show it yet.
  • Values are text or nested objects.

Reference

Last updated on

On this page