
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
amdi18n-loader
Advanced tools
Webpack i18n loader helps your projects to process internationalization (i18n).
It's quite similar to require.js i18n plugin.
Features:
.json
files, and more, .coffee
fileshtml[lang]
attribute, global varible or browser/system settingsnpm install amdi18n-loader
First look at require.js i18n plugin's docs here.
The structure of language packages are like this:
lang.js
zh-cn/lang.js
zh-hk/lang.js
lang.js:
define({
// root means the common language package
root:{
HELLO:'hello'
},
// we have the language packages below:
'zh-cn':true,
'zh-hk':true
});
zh-cn/lang.js example:
define({
// please note: no wrapper object here!
HELLO:'hello in zh-cn'
});
Then use it like this:
define([
'amdi18n-loader!lang'
],function(amdi18n){
// By default, it will lookup `window._i18n.locale`,
//
// If not found, it will try to use the html[lang] attribute,
// For example: <html lang="en"> then language `en` was used,
//
// If still not found, it will try to use browser/system settings
// navigator.languages[0] || navigator.language || navigator.userLanguage (.toLowerCase())
//
// If nothing found, `root` was used.
//
// You can manully change the language by
// `amdi18n.init(language)`;
console.log(amdi18n.HELLO);
});
You can pass queries to enable or disable some langs.
// We use commonjs now. It matters nothing.
var lang = require('amdi18n-loader?enable=[zh-cn]!');
// It's not ok to use zh-hk now!
lang.init('zh-hk');
The code below behaviors the same:
// We use commonjs now. It matters nothing.
// Notice: we use `|` to as separator,
// Because webpack will break the comma.
var lang = require('amdi18n-loader?disable=[zh-hk|en-us]!');
// It's not ok to use zh-hk now!
lang.init('zh-hk');
It's ok to use both enable
and disable
, but if any one disables a lang, the lang will not be usable. You can decide which to use by the length of list.
In some case, accessing root
object is required (#19). You can pass a query expose-root
to expose the root
object.
require('amdi18n-loader?expose-root=1!')
If you choose to use .json
files as your lang files in webpack 4+, You need to specify the type of json files, otherwise webpack will try to parse the final script content as JSON, and throws errors.
// in module.rules
{
// to avoid affecting other json files
// you'd better specify the lang files only,
test: /\.json$/,
type: 'javascript/auto'
},
mocha
in devDependencies
. #32 (By umar-khan)false
value of a language key in root file ignored. #33 (By dlangerenken)export default{
without whitespace in ESM module lang files. #30 (By dlangerenken)navigator.languages
not exists on IE. #28 (By gitgrimbo)navigator.languages
navigator.language
and navigator.userLanguage
. #25export default {}
). #16root
object. #19webpack.config.js
) and passing options.enable
/ disable
queries invalid. #10enable
, no longer required to specify in root.enable
and disable
queries. #6.coffee
language files. (By Mullerzs)FAQs
webpack i18n loader similar to require.js i18n plugin
The npm package amdi18n-loader receives a total of 2,927 weekly downloads. As such, amdi18n-loader popularity was classified as popular.
We found that amdi18n-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.