What is @intlify/core?
@intlify/core is a core library for internationalization (i18n) in JavaScript applications. It provides essential functionalities for managing translations, formatting messages, and handling locale-specific data. This package is part of the Intlify project, which aims to offer a comprehensive solution for i18n in modern web applications.
What are @intlify/core's main functionalities?
Creating an i18n instance
This feature allows you to create an i18n instance with specified locales and messages. The i18n instance can then be used to manage translations in your application.
const { createI18n } = require('@intlify/core');
const i18n = createI18n({
locale: 'en',
messages: {
en: { welcome: 'Welcome' },
fr: { welcome: 'Bienvenue' }
}
});
Translating messages
This feature allows you to translate messages based on the current locale. The `t` method is used to fetch the translated message for a given key.
const message = i18n.t('welcome');
console.log(message); // Output: 'Welcome'
Changing locale
This feature allows you to change the current locale of the i18n instance. Once the locale is changed, all subsequent translations will be based on the new locale.
i18n.locale = 'fr';
const message = i18n.t('welcome');
console.log(message); // Output: 'Bienvenue'
Other packages similar to @intlify/core
i18next
i18next is a popular internationalization framework for JavaScript. It provides similar functionalities to @intlify/core, such as managing translations, handling locales, and formatting messages. i18next is known for its extensive plugin system and support for various frameworks like React, Vue, and Angular.
react-intl
react-intl is a library specifically designed for internationalization in React applications. It offers components and APIs to manage translations, format messages, and handle locale-specific data. While it is similar to @intlify/core in terms of functionality, react-intl is tailored for React and provides a more integrated experience for React developers.
vue-i18n
vue-i18n is an internationalization plugin for Vue.js applications. It provides functionalities for managing translations, handling locales, and formatting messages. vue-i18n is similar to @intlify/core but is specifically designed for Vue.js, offering seamless integration with Vue components and the Vue ecosystem.
v10.0.4 (2024-10-06T07:42:31Z)
This changelog is generated by GitHub Releases
<!-- Release notes generated using configuration in .github/release.yml at v10.0.4 -->
What's Changed
🐛 Bug Fixes
- fix: cannot resolve empty string on plural by @kazupon in https://github.com/intlify/vue-i18n/pull/1985
📝️ Documentations
- Add petite-vue-i18n package to README by @vikingair in https://github.com/intlify/vue-i18n/pull/1971
New Contributors
- @vikingair made their first contribution in https://github.com/intlify/vue-i18n/pull/1971
Full Changelog: https://github.com/intlify/vue-i18n/compare/v10.0.3...v10.0.4