Documentation: Chrome i18n API
A promise-based wrapper for the Chrome i18n API.
- isAvailableI18n()
- detectI18Language(text)
- getI18nAcceptLanguages()
- getI18nUILanguage()
- getI18nMessage(key)
- getDefaultLanguage()
isAvailableI18n(method?: ApiMethodName<typeof chrome.i18n>): booleanThe optional method is a native function name, for example isAvailableI18n("getMessage").
Import the public ApiMethodName type from @addon-core/browser for your own typed helpers.
This checks callable presence without invoking the method; permissions and argument support still require handling.
Returns true when the i18n namespace is present on the API selected by browser() in the current context.
Returns false if the namespace or WebExtension environment is absent, or if accessing it throws.
The check is synchronous, does not log, and reads the current API on every call without caching.
Without an argument, it checks namespace presence only. Pass a native method name to also check that it is callable.
Neither form verifies permissions, argument support, or a successful operation. See method availability.
import {isAvailableI18n} from "@addon-core/browser";
if (isAvailableI18n()) {
// The namespace is present; handle operation-specific failures when using it.
}detectI18Language(text: string): Promise<chrome.i18n.LanguageDetectionResult>
Detects the primary language of the provided text.
getI18nAcceptLanguages(): Promise<string[]>
Retrieves the user's preferred accept languages list.
getI18nUILanguage(): string | undefined
Returns the browser's UI language code.
getI18nMessage(key: string): string | undefined
Retrieves the localized message for the specified key.
getDefaultLanguage(): string | undefined
Extracts the default locale as declared in the extension manifest.