Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
JavaScript internationalization libraries translate an application's messages and format them for each user's language and region. A message catalog maps each message key to its translation in every supported locale, including the plural forms that each language requires. These libraries localize the menus, notifications, and checkout flows of web and mobile apps sold in more than one market.
Popularity
i18next has the most monthly downloads in this comparison, at 132.0M.
public compile<Result extends CompilationResult = MessageFunction<"string">>(
value: string,
lang: string,
): Result {
if (this.fallbackPrefix && value.startsWith(this.fallbackPrefix)) {
return value.slice(this.fallbackPrefix.length) as Result;
}
let result: MessageFunction<"string">;
try {
result = this.getMessageFormatInstance(lang).compile(value);
} catch (err) {
if (this.throwOnError) {
throw err;
}
// eslint-disable-next-line no-console console.error(err);
// eslint-disable-next-line no-console console.error(
`[ngx-translate-messageformat-compiler] Could not compile message for lang '${lang}': '${value}'`,
);
result = compileFallback(value, lang);
}
if (!this.throwOnError) {
result = wrapInterpolationFunction(result, value);
}
return result as Result;
}
i18n-js
Translates keys from a locale-keyed translations object, such as one exported from Ruby on Rails.
Downloads / mo
3.1M
Stars
239
Last release
4.5.4
License
MIT
Strengths
Bundles Rails base translations.Base translations format dates, numbers, and sentence connectors.
Loads translations lazily.The store method merges more translations in as each locale loads.
(
getMessages: GetMessages,
initialLocale: string = 'en',
availableLocales: Locale[] | any = [{ locale: 'en', name: 'English' }],
polyglotOptions: any = {}
): I18nProvider => {
let locale = initialLocale;
const messages = getMessages(initialLocale);
if (messages instanceof Promise) {
throw new Error(
`The i18nProvider returned a Promise for the messages of the default locale (${initialLocale}). Please update your i18nProvider to return the messages of the default locale in a synchronous way.`
);
}
let availableLocalesFinal, polyglotOptionsFinal;
if (Array.isArray(availableLocales)) {
// third argument is an array of locales availableLocalesFinal = availableLocales;
polyglotOptionsFinal = polyglotOptions;
} else {
// third argument is the polyglotOptions availableLocalesFinal = [{ locale: 'en', name: 'English' }];
polyglotOptionsFinal = availableLocales;
}
const polyglot = new Polyglot({
locale,
phrases: { '': '', ...messages },
...polyglotOptionsFinal,
});
let translate = polyglot.t.bind(polyglot);
return {
translate: (key: string, options: any = {}) => translate(key, options),
changeLocale: (newLocale: string) =>
// We systematically return a Promise for the messages because // getMessages may return a Promise Promise.resolve(getMessages(newLocale as string)).then(
(messages: TranslationMessages) => {
locale = newLocale;
const newPolyglot = new Polyglot({
locale: newLocale,
phrases: { '': '', ...messages },
...polyglotOptions,
});
translate = newPolyglot.t.bind(newPolyglot);
}
),
getLocale: () => locale,
getLocales: () => availableLocalesFinal,
};
}
FAQ
i18next is a translation framework for JavaScript that loads translation resources, selects the active language, and translates keys through its t function. It splits translations into namespaces that load from separate files.
ICU message format is a standard syntax for translated messages with plural, select, and number placeholders. IntlMessageFormat, Lingui, and @messageformat/core format ICU messages directly, while i18next needs a format plugin.
Lingui loads message catalogs compiled ahead of time and formats their ICU messages at runtime. Its CLI extracts and compiles the catalogs before the app loads them.
i18n-js translates keys from a locale-keyed translations object, such as one exported from Ruby on Rails. It bundles the Rails base translations for dates, numbers, and sentence connectors.
Paraglide JS compiles translation messages into typed ESM functions. Bundlers remove the message functions that an app never calls.
Lingui compiles catalogs ahead of time and ships a runtime without a MessageFormat parser. i18next loads translation resources at runtime and organizes them into namespaces.
For coding agents
Found your internationalization library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.