Table of Contents

Localization

Localization is performed through a tagging process plus a per-user language preference. Tags follow the format {DICT:SECTION/KEY}, where DICT is a constant identifying a translation, SECTION is the dictionary block to look in, and KEY is the key inside that section.

Related docs.
React Hooks & Events — useTranslate — how React widgets pull strings.
MibTranslationConfig — the config that loads dictionaries.

Where translations come from

Three layered sources, in priority order (highest priority wins):

  1. Environment variables (MIBDICT_<lang>_<section>_<key>) — per-deployment overrides.
  2. Custom dictionaries (Custom/Dictionaries/<component>/<lang>.mibconfig) — customisation-specific files shipped by the customer's customisation repo.
  3. Default dictionaries (Config/Dictionary/<lang>.mibconfig) — the framework's ship-default base.

The merge is computed at BFF startup and refreshed on dictionary file changes (when the host filesystem supports change-watching).

{DICT:Section/Key} markup

Suppose you have:

<?xml version="1.0" encoding="utf-8"?>
<translations>
  <Header>
    <Title>My beautiful title</Title>
  </Header>
</translations>

The tag {DICT:Header/Title} resolves to My beautiful title.

The tag replacement is applied as a post-processing pass on the BFF's render response, so it works for static markup and for database-backed content (mediatype labels, field titles, page configuration values, rows in MIB3UX_PAGE_CONFIGURATIONS like ALERT_DELETE_MESSAGE).

This means: anywhere a string ends up in the /api/v2/display/<page>/<id> response body, you can write {DICT:Section/Key} and the BFF substitutes it before the React shell ever sees it. The shell does not need to know about translations for backend-supplied content.

React-side localization

For strings the React widget renders itself (e.g. button labels in a custom component), use the useTranslate hook from @agilecontent/mib-modules:

import { useTranslate } from '@agilecontent/mib-modules';

const MyWidget = () => {
  const t = useTranslate();
  return (
    <button>{t('Articles', 'Publish')}</button>   // resolves {DICT:Articles/Publish}
  );
};

The hook pulls from the same dictionary sources as the {DICT:...} markup — there is no separate translation store on the React side. The shell asks the BFF to resolve {DICT:Articles/Publish} against the user's active language and caches the result.

For static text you want to embed in a config string (e.g. a ALERT_DELETE_MESSAGE page config), use the {DICT:...} markup directly — the BFF substitutes it server-side and the React shell just gets the resolved string. Don't use useTranslate to re-translate a string the BFF already substituted; the double-pass can fail in edge cases where the substituted text contains its own {DICT:...} token.

Switching language

Per-request override

Passing ?language=<code> on a URL forces that language for the current request only:

https://cms.example.com/app/articles_list?language=pt-br

Invalid language codes (codes not declared in MibTranslationConfig) silently fall back to the default language configured in MibCmsFrontEndServerBaseConfig.

Per-user language

A user's interface language is their profile language (the language field of the user in the authorization service), which the React shell's Account page edits (see Menus — Account page). How the BFF picks the language of a request, from 7.0.4 (MEDIAIBOX-12329, MibServer3#1985):

  1. a language query-string parameter with a valid code (not on an AJAX request);
  2. the profile language as the session carries it: sign-in copies it into a claim, and the account page re-issues the session cookie when the user changes their own language. A session without claims (opened before the upgrade, or an agent host) reads it from the authorization service instead;
  3. the default language of MibCmsFrontEndServerBaseConfig (then en-US).

The interface_language preference (MIB3UX_PREFERENCES_VALUES) plays no part from 7.0.4. Up to 7.0.3 (and on 6.0) the BFF read it from the authorization service before every request and let it win over the profile language; it is written only by the authorization server's own account screen, which the React CMS does not use. A language changed directly in the authorization server reaches the CMS at the user's next sign-in.

In server code, read the language with await Context.GetLanguageAsync(): from 7.0.4 the BaseContext.Language getter is [Obsolete] and returns null until something has resolved it.

Custom dictionaries

The customer customisation can ship dictionary files layered on top of the framework defaults without forking the framework:

Custom/Dictionaries/MyComponent1/en-us.mibconfig
Custom/Dictionaries/MyComponent1/pt-br.mibconfig
Custom/Dictionaries/MyComponent1/es-ar.mibconfig

Each file is a standard XML translation dictionary:

<?xml version="1.0" encoding="utf-8"?>
<translations>
  <MyComponent1>
    <PublishButton>Publish article</PublishButton>
    <ReviewButton>Submit for review</ReviewButton>
  </MyComponent1>
</translations>

At BFF startup the framework merges these into the in-memory translation table, with custom values winning over the default values for the same key.

Note

The folder name Custom/Dictionaries is case-sensitive on Linux filesystems (the typical container deployment). Match the casing exactly.

Per-component file naming is a convention, not a requirement — the framework merges all *.mibconfig files under Custom/Dictionaries/**/. Use one file per component to keep diffs clean.

Environment-variable overrides

Dictionary entries can also be set through env vars. Pattern:

MIBDICT_<language>_<section>_<key> = <value>

The language code is written without the hyphen (enus, ptbr, eses, esar, …). Using a hyphenated locale (en-us) throws an exception at startup.

Env vars override values from dictionary files, so this is the canonical way to apply per-environment string customisations without touching the customer base image. Common use case: overriding the default browser page title:

MIBDICT_ENUS_HEADER_TITLE=Editorial Console

After deploying with the new env var, the browser tab for English users shows "Editorial Console" instead of the default "Media-iBox CMS".

Inspecting current translations

Three ways to verify which value will be served for a given key:

  1. Direct request — GET /api/v2/display/<page>/<id> for any page that uses the key. The substituted string appears in the response body where the {DICT:...} markup would be.
  2. Health endpoint — some deployments expose a debug endpoint that dumps the merged dictionary; check the deployment's HealthChecks configuration.
  3. Custom test page — drop a test component that renders the markup verbatim; the substituted string is the rendered output.

Common gotchas

  • Hyphenated env vars. MIBDICT_EN-US_HEADER_TITLE throws on startup. Always MIBDICT_ENUS_….
  • Case-sensitive paths on Linux. Custom/dictionaries/... is not the same as Custom/Dictionaries/....
  • Cache TTL. The merged dictionary is cached. New env vars and new dictionary files take effect only after a BFF restart — and the browser caches /api/v1/Dictionary too (Cache-Control: private, max-age=3600, must-revalidate, with an ETag, MIB 7.0), so an open session can keep the old texts for up to an hour; a hard refresh fetches them again.
  • Double substitution. Don't pass a {DICT:...} token through useTranslate — the BFF will substitute the outer token before the shell ever sees it.

See also