
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@chainplatform/language
Advanced tools
A lightweight and flexible language management system for React Native apps. Supports local storage, lazy loading, API-based translation loading, and full React Context integration.
Intlnpm install @chainplatform/language
# or
yarn add @chainplatform/language
import React from "react";
import { LanguageProvider } from "@chainplatform/language";
import App from "./App";
export default function Root() {
return (
<LanguageProvider
fallback="en"
translations={{
en: { hello: "Hello" },
vi: { hello: "Xin chào" }
}}
>
<App />
</LanguageProvider>
);
}
t() functionYou can use the LanguageContext hook or withLanguage HOC to access translation functions.
import React, { useContext } from "react";
import { LanguageContext } from "@chainplatform/language";
export default function MyComponent() {
const { t, changeLanguage } = useContext(LanguageContext);
return (
<>
<Text>{t("hello")}</Text>
<Button title="Switch to Vietnamese" onPress={() => changeLanguage("vi")} />
</>
);
}
import React from "react";
import { withLanguage } from "@chainplatform/language";
function MyComponent({ t, language }) {
return <Text>{t("hello")} ({language})</Text>;
}
export default withLanguage(MyComponent);
<LanguageProvider
fallback="en"
lazyLoad={async (lang) => {
switch (lang) {
case "vi":
return await import("./locales/vi.json").then(m => m.default);
case "en":
return await import("./locales/en.json").then(m => m.default);
default:
return {};
}
}}
>
<App />
</LanguageProvider>
<LanguageProvider
fallback="en"
loadFromApi={async (lang) => {
const res = await fetch(`https://example.com/i18n/${lang}.json`);
return await res.json();
}}
>
<App />
</LanguageProvider>
By default, it uses @chainplatform/sdk’s retrieveStorage and saveStorage.
You can override with your own implementation:
<LanguageProvider
storage={{
get: async (key) => AsyncStorage.getItem(key),
set: async (key, val) => AsyncStorage.setItem(key, val)
}}
>
<App />
</LanguageProvider>
t("welcome", { name: "John" }); // "Welcome, John"
formatNumber(123456.78); // 123,456.78 or 123.456,78 depending on locale
format("DateTimeFormat", new Date(), { dateStyle: "medium" });
Language.init(options)Initializes the language manager.
Called automatically by LanguageProvider.
| Option | Type | Description |
|---|---|---|
| fallback | string | Default fallback language |
| translations | object | Predefined translations |
| lazyLoad | function | Async function to load translation file dynamically |
| loadFromApi | function | Async function to fetch translations from API |
| language | string | Force set initial language |
| storage | object | Custom { get, set } async storage methods |
| storage_key | string | Custom key for language storage |
Language.t(key, vars)Translates a key with optional variables.
Language.changeLanguage(lang)Changes the current language and saves it to storage.
Language.onLanguageChange(callback)Subscribes to language changes.
locales/en.json
{
"hello": "Hello",
"welcome": "Welcome, {name}!"
}
locales/vi.json
{
"hello": "Xin chào",
"welcome": "Chào mừng, {name}!"
}
MIT License © ChainPlatform
FAQs
@chainplatform/language
The npm package @chainplatform/language receives a total of 8 weekly downloads. As such, @chainplatform/language popularity was classified as not popular.
We found that @chainplatform/language demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.