
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
@ttoss/i18n
Advanced tools
@ttoss/i18n is a easiest way to use translations in your React application.
$ yarn add @ttoss/i18n
# or
$ npm install @ttoss/i18n
Import the I18nProvider and wrap your application with it. Add to it a function called loadLocaleData to load all the translation data.
import { I18nProvider, LoadLocaleData } from '@ttoss/i18n';
const loadLocaleData: LoadLocaleData = (locale) => {
switch (locale) {
case 'pt-BR':
return import('../i18n/compiled-lang/pt-BR.json');
default:
return import('../i18n/compiled-lang/en.json');
}
};
ReactDOM.render(
<I18nProvider
locale={window.navigator.language}
loadLocaleData={loadLocaleData}
>
<App />
</I18nProvider>,
document.getElementById('root')
);
Then import the useI18n hook and extract the intl, to get access to the formatMessage function and many others (using defineMessages is optional).
import { useI18n, defineMessages } from '@ttoss/i18n';
const messages = defineMessages({
myNameIs: {
description: 'My name is',
defaultValue: 'My name is {name}',
},
});
const App = () => {
const { intl, setLocale } = useI18n();
const [name, setName] = React.useState('Rayza');
return (
<div>
<div>
<button onClick={() => setLocale('en-US')}>en-US</button>
<button onClick={() => setLocale('pt-BR')}>pt-BR</button>
</div>
<input value={name} onChange={(e) => setName(e.target.value)} />
<h3>{intl.formatMessage(messages.myNameIs, { name })}</h3>
</div>
);
};
export default App;
To extract the translations run the command yarn i18n:extract, and to compile use yarn i18n:compile
yarn i18n:extract
yarn i18n:compile
{
"IDLw9V": {
"defaultMessage": "My name is {name}.",
"description": "My name is"
},
"tPkQ38": {
"defaultMessage": "Congrats",
"description": "Congrats"
}
}
{
"IDLw9V": {
"defaultMessage": "Meu nome é {name}.",
"description": "My name is"
},
"tPkQ38": {
"defaultMessage": "Parabéns",
"description": "Congrats"
}
}
import { MessageFormatElement } from 'react-intl';
export type MessageType = any;
export type LoadLocaleData = (locale: string) => Promise<MessagesType>;
export type I18nProviderProps = {
locale?: string;
loadLocaleData?: LoadLocaleData;
};
FAQs
## 📚 About
The npm package @ttoss/i18n receives a total of 25 weekly downloads. As such, @ttoss/i18n popularity was classified as not popular.
We found that @ttoss/i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.