
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
A simple localization library using ini files with string formatting.
Consider a locale/en.ini file:
[greeting]
hello = Hello, $name ; You can use placeholders to insert data into strings
hi = Hi, $name
An index.js file:
const locini = require('locini');
locini.loadFromSync(`${__dirname}/locale`);
console.log(
locini.use('en').greeting.hello.format({ name: 'John' })
);
// Expected output: Hello, John
Placeholder format:
$key
$[key]
$key[alt]
$[key][alt]
Where:
key is an object property key.
alt is an alternative text used if key does not exists.
If alt is not specified and key does not exists,
the placeholder will be replaced with an empty string.
'Name: $name'.format({ name: 'John' }) //-> Name: John
'Name: $name[Anonymous]'.format() //-> Name: Anonymous
'Values: $0, $1'.format('first', 'second') //-> Values: first, second
'Item cost: $[cost]$'.format({ cost: 10 }) //-> Item cost: 10$
Locale id is a unique key to distinct locales. By default it is set to locale's filename. You can override it in your locale file as follows:
# Overriding locale id
[locini]
id = overridden_id
Replace placeholders in the string with property values from the key object.
The key object:
If first is an object: { ...first, ...[first, ...rest] }
Else: [first, ...rest]
Returns formatted string.
Define locale using id locale id and locale ini string.
Load locale file by it's filename.
options: File reading options.
Synchronously load locale by it's filename.
options: File reading options.
Load locale files from specified directory dirname.
filter: Directory file filter (filename => boolean).
options: File reading options.
Synchronously load locale files from specified directory dirname.
filter: Directory file filter (filename => boolean).
options: File reading options.
Get locale object by id locale.
Get all stored locales as Map<string, object>.
FAQs
A simple localization library using ini files.
We found that locini 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
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.