Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 25, 2024 via pnpm

y18n 5.0.8

the bare-bones internationalization library used by yargs
Package summary
Share
0
issues
1
license
1
ISC
Package created
27 Jul 2015
Version published
7 Apr 2021
Maintainers
3
Total deps
1
Direct deps
0
License
ISC

Issues

0
This package has no issues

Licenses

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
y18n@5.0.8
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of y18n 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does y18n do?

The y18n JavaScript library, which is frequently utilized by the yargs package, provides a bare-bones solution for internationalization of your projects. This lightweight library allows you to maintain localization support within your application by offering both singular and plural string translation functionalities along with JSON language file handling. Drawing inspiration from the i18n package, y18n assists in creating an application with a global reach by taking care of language-specific translations.

How do you use y18n?

To successfully adopt y18n in your coding projects, you need to import it and initialize an instance. Here are a few snippets demonstrating its usage:

  • Simple string translation:
const __ = require('y18n')().__;
console.log(__('my awesome string %s', 'foo'));

The output for this will be: my awesome string foo

  • Using tagged template literals:
const __ = require('y18n')().__;
const str = 'foo';
console.log(__`my awesome string ${str}`);

The output for this will be: my awesome string foo

  • Pluralization support:
const __n = require('y18n')().__n;
console.log(__n('one fish %s', '%d fishes %s', 2, 'foo'));

The output for this will be: 2 fishes foo

JSON language files should be placed in a directory, typically ./locales. The file name signifies the locale, such as en.json, pirate.json and so on.

Where are the y18n docs?

The documentation for y18n can be found within its npm package description here, and more comprehensive details are available on its GitHub repository at git+https://github.com/yargs/y18n.git. The README on the GitHub page mirrors the npm package documentation, and it provides a detailed view of creating an instance of y18n with necessary configurations, an understanding of its methods including translation, pluralization, locale management, and the use of JSON language files.