Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
i18nify
is an internationalization plugin for
browserify.
It works greath with
jedify.
If you have the following files:
// entry.js
const hello = require('i18nify', './hello/%s')
console.log(i18n)
// hello/en.js
module.exports = 'Hello World'
// hello/nb.js
module.exports = 'Hallo Verden'
And then runs:
mkdir bundle
browserify \
--entry entry.js \
--plugin \
[ i18nify \
-l en \
-l nb \
-o 'bundle/%s.js' \
] \
--outfile bundle/main.js
The the following the files will be produced.
bundle/main.js
bundle/en.js
bundle/nb.js
Then, in your html file you should add main.js
and one of the language
spesific files.
If you are using browserify entries, then the localized bundle must run before the main bundle because entries are executed synchronous on script execution.
If you do not use entries, then the load order does not matter which means you
can use the async
flag on the script tag.
<script src="bundle/en.js"></script>
<script src="bundle.main.js"></script>
When creating a bundle, i18nify
should be used as a browserify
plugin.
browserify -p [ i18nify OPTIONS ]
where OPTIONS are:
-l
--lang
Add language code. This should be set multiple times to add multiple
languages.
-o
--output
Output expression that maps to a corresponding entry file at the same
index. This should include %s in the string which will be replaced with
the language code.
It can either be reference a FILE or be a CMD. CMDs are executed with
$LANG set to the current language code.
Optionally specify a function that returns a valid value for this
argument.
-d
--default
Default language code. Defaults to the first language defined.
--factor-bundle
Similar to -o expect it maps to factor-bundle. CMDs are executed with
$FILE set to the corresponding input file.
Moment.js does not have a locale/en.js
language file. To support this, the
easiest way is to just tell browserify
to ignore it.
Eg.
// entry.js
try {
require('i18nify', 'moment/locale/%s.js')
} catch(e) {}
const moment = require('moment')
console.log(moment().format('LL'))
And when running browserify:
mkdir bundle
browserify \
--entry entry.js \
--ignore moment/locale/en.js \
--plugin \
[ i18nify \
-l en \
-l nb \
-o 'bundle/%s.js' \
] \
--outfile bundle/main.js
If you are writing a library which will be required from node_modules, then you
should add i18nify
as a browserify transform. If the library consumer is not
using i18nify
as a plugin, it will just bundle all the language variations in
the main bundle and just work.
factor-bundle
?i18nify
works with factor-bundle
. Just add multiple --factor-bundle
options which maps to the -o
option in factor-bundle
.
Eg.
mkdir bundle
browserify \
--entry foo.js \
--entry bar.js \
\
--plugin \
[ i18nify \
-l en \
-l nb \
-o 'bundle/%s.js' \
--factor-bundle bundle/foo.%.js \
--factor-bundle bundle/bar.%.js \
] \
--plugin \
[ factor-bundle \
-o bundle/foo.js \
-o bundle/bar.js \
] \
\
--outfile bundle/common.js \
The above command will produce the following files in the bundle
folder. Then
it is up to you to include the right combination.
common.js
en.js
nb.js
foo.js
foo.en.js
foo.nb.js
bar.js
bar.en.js
bar.nb.js
watchify
?Yes, that should work out of the box.
npm install --save i18nify
I'm available on IRC in #browserify@freenode
with username tellnes
.
MIT
FAQs
An internationalization plugin for browserify
The npm package i18nify receives a total of 9 weekly downloads. As such, i18nify popularity was classified as not popular.
We found that i18nify 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.