Use the browser.i18n infrastructure to implement internationalization across your whole app or extension.

_DetectLanguageReturnResult
_DetectLanguageReturnResultLanguages
LanguageCode
detectLanguage
getAcceptLanguages
getMessage
getUILanguage
LanguageCode: string

An ISO language code such as en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. For an unknown language, und will be returned, which means that [percentage] of the text is unknown to CLD

  • Detects the language of the provided text using CLD.

    Parameters

    • text: string

      User input string to be translated.

    Returns Promise<_DetectLanguageReturnResult>

  • Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale, use i18n.getUILanguage.

    Returns Promise<string[]>

  • Gets the localized string for the specified message. If the message is missing, this method returns an empty string (''). If the format of the getMessage() call is wrong — for example, messageName is not a string or the substitutions array has more than 9 elements — this method returns undefined.

    Parameters

    • messageName: string

      The name of the message, as specified in the messages.json file.

    • Optionalsubstitutions: any

      Substitution strings, if the message requires any.

    Returns string

    Message localized for current locale.

  • Gets the browser UI language of the browser. This is different from i18n.getAcceptLanguages which returns the preferred user languages.

    Returns string

    The browser UI language code such as en-US or fr-FR.