ChemPal Documentation - v1.6.0
    Preparing search index...

    Function i18n

    • Translates a message key into the currently-active locale. Drop-in replacement for chrome.i18n.getMessage(key, subs), but reads the app's own locale so the UI can switch language live (see setLocale).

      Parameters

      • key: string

        The message key, e.g. "results_retry".

      • Optionalsubstitutions: string | string[]

        Positional substitution value(s) for $name$ placeholders.

      Returns string

      The translated, substituted string (or the key if unknown).

      i18n("results_error", ["timeout"]); // => "Error: timeout" (en) / "Błąd: timeout" (pl)
      
      export function i18n(key: string, substitutions?: string | string[]): string {
      return resolveMessage(currentLocale, key, substitutions);
      }