initI18n function exported

Last updated: 2026-03-01T23:25:47.122Z

Metrics

LOC: 19 Complexity: 4 Params: 2

Signature

initI18n( lang: "auto" | "en" | "pt_BR" | "es" = "auto", ): : Promise<void>

Summary

Initialises the i18n catalog for the given language. Must be called once at app startup, before any t() or localizeHTML() calls. Passing "auto" (default) delegates to Chrome's native locale resolution.

Source Code

export async function initI18n(
  lang: "auto" | "en" | "pt_BR" | "es" = "auto",
): Promise<void> {
  if (lang === "auto") {
    _catalog = null;
    return;
  }
  try {
    const url = chrome.runtime.getURL(`_locales/${lang}/messages.json`);
    const res = await fetch(url);
    if (!res.ok) {
      _catalog = null;
      return;
    }
    _catalog = (await res.json()) as MessageCatalog;
  } catch {
    _catalog = null;
  }
}

No outgoing dependencies.

Impact (Incoming)

graph LR initI18n["initI18n"] FillableElement["FillableElement"] renderShell["renderShell"] render["render"] main["main"] debounce["debounce"] FillableElement -->|uses| initI18n renderShell -->|uses| initI18n render -->|uses| initI18n main -->|uses| initI18n debounce -->|uses| initI18n style initI18n fill:#dbeafe,stroke:#2563eb,stroke-width:2px click initI18n "6ba39c0538592b1c.html" click FillableElement "2ecf5aaac3f668a8.html" click renderShell "49d8574256a889e1.html" click render "89e5905fc5b1676c.html" click main "14348c66c1e5604a.html" click debounce "806c18ff0675c421.html"
SourceType
FillableElement uses
renderShell uses
render uses
main uses
debounce uses