
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@davidbarratt/react.i18n
Advanced tools
React i18n provides React bindings for banana-i18n.
import { IntlProvider, Message } from '@wikimedia/react.i18n';
const locale = 'en-US';
const messages = {
en: {
'hello-world': 'Hello $1!',
'world': 'World',
}
};
const App = () => (
<IntlProvider locale={locale} messages={messages}>
<Message id="hello-world" placeholders={[
'David'
]} />
</IntlProvider>
);
export default App;
// Rendered Output:
// Hello David!
The placeholders can also be React components:
<Message id="hello-world" placeholders={[
<strong><Message id="world" /></strong>,
]} />
// Rendered Output:
// Hello <strong>World</strong>!
The BananaContext
can also be used directly to return a string as described in
React's Context.Consumer
documentation.
import { IntlProvider, BananaContext } from '@wikimedia/react.i18n';
const locale = 'en-US';
const messages = {
en: {
'hello-world': 'Hello $1!',
'world': 'World',
}
};
const App = () => (
<IntlProvider locale={locale} messages={messages}>
<BananaContext.Consumer>
{banana =>
banana.i18n( 'hello-world', 'David' )
}
</BananaContext.Consumer>
</IntlProvider>
);
export default App;
// Rendered Output:
// Hello David!
or with React's Context Hook:
import { useContext } from 'react';
import { IntlProvider, BananaContext } from '@wikimedia/react.i18n';
const locale = 'en-US';
const messages = {
en: {
'hello-world': 'Hello $1!',
'world': 'World',
}
};
const App = () => {
const banana = useContext(BananaContext);
return (
<IntlProvider locale={locale} messages={messages}>
{banana.i18n( 'hello-world', 'David' )}
</IntlProvider>
);
};
export default App;
// Rendered Output:
// Hello David!
Message
can no longer be used as a function. To use the Banana object
directly, get the context consumer as described above.FAQs
React bindings for banana-i18n
The npm package @davidbarratt/react.i18n receives a total of 0 weekly downloads. As such, @davidbarratt/react.i18n popularity was classified as not popular.
We found that @davidbarratt/react.i18n demonstrated a not healthy version release cadence and project activity because the last version was released 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.