
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.
browser-i18n
Advanced tools
Simple i18n module for the browser, compatible with the i18n server module data files.
A simple in-browser i18n module, compatible with the i18n-node server module data files. Meant to be use with a module bundler (like parcel).
By using npm:
npm i browser-i18n --save
import I18n from 'browser-i18n';
const i18n = new I18n({
language: 'fr',
path: '/locales',
extension: '.json'
});
console.log( i18n.__('Hello') );
// Output: 'Bonjour'
console.log( i18n.__('Oh, hi %s!', 'Mark') );
// Output: 'Oh, salut Mark!'
// Or using the global selector ...
console.log( __('Hello') );
// Output: 'Bonjour'
One file for each language. They may have the following structure:
// /locales/en.json
{
"Hello": "Hello",
"Oh, hi %s!": "Oh, hi %s!",
"Bye!": "Bye!"
}
// /locales/fr.json
{
"Hello": "Bonjour",
"Oh, hi %s!": "Oh, salut %s!",
"Bye!": "Au revoir!"
}
Put your locales folder accessible publicly. You can do it by putting it in your public root:
.
└── public
└── locales
├── en.json
└── fr.json
Or, using express:
app.use('/locales', express.static(path.join(__dirname, 'locales')));
Configuration:
const i18n = new I18n({
language: 'fr', // The langage wanted - Default 'en'
path: '/locales', // The path to access the locales files - Default '/locales'
extension: '.json', // Local file extension - Default '.json'
setGobal: true, // Set the function '__' on a global scope - Default true
onReady: callback, // Set a callback triggered when the dataFile is loaded
verbose: true // Set the verbosity of the object - Default to true
});
FAQs
Simple i18n module for the browser, compatible with the i18n server module data files.
The npm package browser-i18n receives a total of 2 weekly downloads. As such, browser-i18n popularity was classified as not popular.
We found that browser-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.