Gathering detailed insights and metrics for y18n-browser
Gathering detailed insights and metrics for y18n-browser
npm install y18n-browser
Typescript
Module System
Node Version
NPM Version
70.9
Supply Chain
99.3
Quality
75.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
1,364
Last Day
3
Last Week
4
Last Month
15
Last Year
72
1 Stars
64 Commits
2 Watching
6 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.2
Package Id
y18n-browser@1.0.2
Size
4.90 kB
NPM Version
4.2.0
Node Version
7.9.0
Cumulative downloads
Total Downloads
Last day
-25%
3
Compared to previous day
Last week
-42.9%
4
Compared to previous week
Last month
400%
15
Compared to previous month
Last year
-50.3%
72
Compared to previous year
The bare-bones internationalization library.
simple string translation:
1var __ = require('y18n').__ 2 3console.log(__('my awesome string %s', 'foo'))
output:
my awesome string foo
pluralization support:
1var __n = require('y18n').__n 2 3console.log(__n('one fish %s', '%d fishes %s', 2, 'foo'))
output:
2 fishes foo
The JSON language files can be stored anywhere as long as you can include them
when you instantiate a new Y18N.
File names correspond to locales, e.g., en.json
, pirate.json
.
When strings are observed for the first time they will be added to the JSON file corresponding to the current locale.
It is recommended to create a helper file/module to handle constructing a new Y18N instance like so:
y18n.js
1import Y18N from 'y18n-browser' 2 3export default new Y18N({ 4 sources: { 5 en: require('./path/to/en.json'), 6 pirate: require('./path/to/pirate.json'), 7 } 8})
Create an instance of y18n with the config provided, options include:
sources
: an object mapping to existing json source fileswriteLocalUpdates
: should newly observed strings be written to local storage, default false
.locale
: what locale should be used.fallbackToLanguage
: should fallback to a language-only file (e.g. en.json
)
be allowed if a file matching the locale does not exist (e.g. en_US.json
),
default true
.Now you can use your configured instance anywhere.
Print a localized string, %s
will be replaced with arg
s.
Print a localized string with appropriate pluralization. If %d
is provided
in the string, the count
will replace this placeholder.
Set the current locale being used.
What locale is currently being used?
Update the current locale with the key value pairs in obj
.
1{ 2 "Hello": "Hello!", 3 "Hello %s %s": "Hello %s %s", 4 "%d cat": { 5 "one": "%d cat", 6 "other": "%d cats" 7 }, 8 "%d %s cat": { 9 "one": "%d %s cat", 10 "other": "%d %s cats" 11 }, 12 "There is one monkey in the %s": { 13 "one": "There is one monkey in the %s", 14 "other": "There are %d monkeys in the %s" 15 } 16}
ISC
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More