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',
});updatesends aPATCHand 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');listresolves to one page,{ total, resources }. Page with_countand_offset.updatesets the entry with aPUT, 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' } });updatepatches 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
- localization API reference: every method and type.
- Errors and retries
- ovok.projects for project settings and features.
Last updated on