Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
@intlify/core-base
Advanced tools
@intlify/core-base is a core library for internationalization (i18n) in JavaScript applications. It provides essential functionalities for handling translations, message formatting, and locale management, making it easier to build multilingual applications.
Basic Translation
This feature allows you to define translations for different locales and switch between them. The code sample demonstrates how to create a context with messages in English and French, and how to switch the locale to get the translated message.
const { createCoreContext, translate } = require('@intlify/core-base');
const ctx = createCoreContext({
locale: 'en',
messages: {
en: {
hello: 'Hello, world!'
},
fr: {
hello: 'Bonjour, le monde!'
}
}
});
console.log(translate(ctx, 'hello')); // Output: Hello, world!
ctx.locale = 'fr';
console.log(translate(ctx, 'hello')); // Output: Bonjour, le monde!
Message Formatting
This feature allows you to use placeholders in your messages and replace them with dynamic values. The code sample shows how to define a message with a placeholder and provide a value for it during translation.
const { createCoreContext, translate } = require('@intlify/core-base');
const ctx = createCoreContext({
locale: 'en',
messages: {
en: {
greeting: 'Hello, {name}!'
}
}
});
console.log(translate(ctx, 'greeting', { name: 'Alice' })); // Output: Hello, Alice!
Locale Management
This feature provides the ability to manage the current locale and fallback locales. The code sample demonstrates how to set and get the current locale and how to define a fallback locale.
const { createCoreContext } = require('@intlify/core-base');
const ctx = createCoreContext({
locale: 'en',
fallbackLocale: 'fr',
messages: {
en: {
hello: 'Hello, world!'
},
fr: {
hello: 'Bonjour, le monde!'
}
}
});
console.log(ctx.locale); // Output: en
ctx.locale = 'fr';
console.log(ctx.locale); // Output: fr
i18next is a popular internationalization framework for JavaScript. It offers a wide range of features including translation, pluralization, and interpolation. Compared to @intlify/core-base, i18next has a larger ecosystem with plugins and integrations for various frameworks.
react-intl is a library specifically designed for React applications. It provides components and APIs for formatting dates, numbers, and strings, and for handling translations. While @intlify/core-base is more general-purpose, react-intl is tailored for React, making it easier to use in React projects.
vue-i18n is an internationalization plugin for Vue.js. It offers similar functionalities to @intlify/core-base but is specifically designed for Vue.js applications. It integrates seamlessly with Vue components and provides a simple API for managing translations and locales.
v10.0.0 (2024-09-10T04:41:41Z)
We are excited to announce the release of Vue I18n v10. We had many contributors.
Thanks for your contributing ❤️
petite-vue-i18n
General Availabilitypetite-vue-i18n
is an alternative distribution of Vue I18n, providing only minimal features.
If you don't need the full functionality of vue-i18n and are just looking for basic translation features with a smaller footprint, this will suit your use case.
For more details, please see the docs.
JIT compilation was introduced in v9.3, but it was not enabled by default.
However, it had the following issues:
Starting from v10, JIT compilation is enabled by default.
We provide an interface to extend the Locale type in TypeScript, similar to ComponentCustomProperties
in Vue.
This feature is useful when using vue-i18n as part of a framework.
For more details, see the PR for the Nuxt I18n use case.
$t
and t
Overload Signatures for Legacy API ModeIn Vue I18n v9, $t
and t
had different overload signatures in Composition API mode compared to Legacy API mode.
When migrating from Legacy API mode to Composition API mode, these differences sometimes caused confusion.
Starting from v10, Legacy API mode will use the same $t
and t
overload signatures as Composition API mode.
For details on the signature pattern, see the migration guide.
tc
and $tc
for Legacy API ModeThe t
and $t
functions already support pluralization, so tc
and $tc
can be replaced.
In v10, tc
and $tc
still exist to aid in migration, but they will be fully removed in v11.
If you use them, Vue I18n will display a console warning in your application.
For migration instructions, see the docs.
Some features were marked as deprecated in v9 with warnings.
These deprecated features will be completely removed in v10.
For more details on the deprecated features, see the docs.
$t
overloaded signature for Legacy API mode by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1832<i18n>
v8.x compatibility by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1844te
behavior v8.x compatibility on v9 by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1845tc
and $tc
for Legacy API mode by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1839formatter
option codes on Legacy API by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1826preserveDirectiveContent
option codes on Legacy API by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1827preserve
modifier codes on v-t
directive by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1828getChoiceIndex
on Legacy API by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1829allowComposition
option by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1817$t
types by @mitjans in https://github.com/intlify/vue-i18n/pull/1883Full Changelog: https://github.com/intlify/vue-i18n/compare/v9.13.1...v10.0.0
FAQs
@intlify/core-base
The npm package @intlify/core-base receives a total of 864,460 weekly downloads. As such, @intlify/core-base popularity was classified as popular.
We found that @intlify/core-base demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.