Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rosetty

Package Overview
Dependencies
Maintainers
0
Versions
353
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rosetty

[![Maintainability](https://api.codeclimate.com/v1/badges/1ff0c28615640d86e758/maintainability)](https://codeclimate.com/github/qlaffont/rosetty/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/1ff0c28615640d86e758/test_coverage)](

  • 3.1.24
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
increased by52.03%
Maintainers
0
Weekly downloads
 
Created
Source

Maintainability Test Coverage npm npm Snyk Vulnerabilities for npm package NPM

Rosetty

Complete Intl/I18n solution for browser and node. Old Owner: @flexper

  • React Implementation : Rosetty React

Usage

const { rosetty } = require('rosetty');
const { enGB } = require('date-fns/locale');

const r = rosetty(
  {
    en: {
      dict: {
        test: 'This is a test',
      },
      locale: enGB,
    },
  },
  'en'
);

console.log(r.t('test')); // This is a test

API

rosetty(config, defaultLang?)

Options

Field NameTypeDescription
configRecord<string, Language>Specify dictionnary and locale to use for each lang
defaultLangstring?Specify default language to use (should be the same as config)
translateFallbackboolean?Return fallback if translation is not defined

Return

Field NameTypeDescription
changeLang(newLang: string) => voidChange current lang
languagesstring[]List of languages who can be selected
getCurrentLang() => stringReturn current lang
t(key: string, params?: Record<string, any>, dict?: Record<string, any>) => string OR undefinedReturn translated text https://github.com/lukeed/rosetta#rosettatkey-params-lang. If dict is defined, he will use dict.
displayNamesDocumentationConsistent translation of language, region and script display names https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames
listFormatDocumentationLanguage-sensitive list formatting https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat
numberFormatDocumentationLanguage-sensitive list formatting https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
pluralRulesDocumentationPlural-sensitive formatting and plural-related language rules https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules
formatDocumentationReturn the formatted date string in the given format https://date-fns.org/v3.3.0/docs/format
formatRelativeDocumentationRepresent the date in words relative to the given base date. https://date-fns.org/v3.3.0/docs/formatRelative
formatDistanceDocumentationReturn the distance between the given dates in words. https://date-fns.org/v3.3.0/docs/formatDistance
formatDistanceToNowDocumentationReturn the distance between the given date and now in words. https://date-fns.org/v3.3.0/docs/formatDistanceToNow
formatDurationDocumentationReturn human-readable duration string i.e. "9 months 2 days" https://date-fns.org/v3.3.0/docs/formatDuration

WARNING FOR LOCALE !

You need to import locale from date-fns package.

const { enGB } = require('date-fns/locale');

Maintain

This package use TSdx. Please check documentation to update this package.

FAQs

Package last updated on 06 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc