{"id":21038336,"url":"https://github.com/qlaffont/rosetty","last_synced_at":"2025-05-15T15:33:28.978Z","repository":{"id":37049507,"uuid":"483135130","full_name":"qlaffont/rosetty","owner":"qlaffont","description":"Complete Intl/I18n solution for browser and node","archived":false,"fork":false,"pushed_at":"2025-05-15T02:01:33.000Z","size":1688,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-15T03:27:35.754Z","etag":null,"topics":["datefns","formatjs","i18n","intl","rosetta","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/rosetty","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qlaffont.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-19T07:08:40.000Z","updated_at":"2025-05-15T02:01:37.000Z","dependencies_parsed_at":"2024-02-07T14:26:35.215Z","dependency_job_id":"f2ad85d4-4a43-4ce6-8b69-dbe974dbe55a","html_url":"https://github.com/qlaffont/rosetty","commit_stats":null,"previous_names":["qlaffont/rosetty","flexper/rosetty"],"tags_count":345,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Frosetty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Frosetty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Frosetty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Frosetty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qlaffont","download_url":"https://codeload.github.com/qlaffont/rosetty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254367881,"owners_count":22059581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datefns","formatjs","i18n","intl","rosetta","typescript"],"created_at":"2024-11-19T13:31:22.526Z","updated_at":"2025-05-15T15:33:28.963Z","avatar_url":"https://github.com/qlaffont.png","language":"TypeScript","readme":"[![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)](https://codeclimate.com/github/qlaffont/rosetty/test_coverage) ![npm](https://img.shields.io/npm/v/rosetty) ![npm](https://img.shields.io/npm/dm/rosetty) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/rosetty) ![NPM](https://img.shields.io/npm/l/rosetty)\n\n# Rosetty\n\nComplete Intl/I18n solution for browser and node. Old Owner: [@flexper](https://github.com/flexper)\n\n- React Implementation : [Rosetty React](https://github.com/qlaffont/rosetty-react)\n\n## Usage\n\n```js\nconst { rosetty } = require('rosetty');\n\nconst r = rosetty(\n  {\n    en: {\n      dict: {\n        test: 'This is a test',\n      },\n      locale: 'en-GB',\n    },\n  },\n  'en'\n);\n\nconsole.log(r.t('test')); // This is a test\n```\n\n## API\n\n### rosetty(config, defaultLang?)\n\n**Options**\n\n| Field Name        | Type                     | Description                                                    |\n| ----------------- | ------------------------ | -------------------------------------------------------------- |\n| config            | Record\u003cstring, Language\u003e | Specify dictionary and locale to use for each lang             |\n| defaultLang       | string?                  | Specify default language to use (should be the same as config) |\n| translateFallback | boolean?                 | Return fallback if translation is not defined                  |\n\n**Return**\n\n| Field Name         | Type                                                                                                                             | Description                                                                                                               |\n| ------------------ | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |\n| changeLang         | (newLang: string) =\u003e void                                                                                                        | Change current lang                                                                                                       |\n| languages          | string[]                                                                                                                         | List of languages who can be selected                                                                                     |\n| getCurrentLang     | () =\u003e string                                                                                                                     | Return current lang                                                                                                       |\n| t                  | (key: string, params?: Record\u003cstring, any\u003e, dict?: Record\u003cstring, any\u003e) =\u003e string OR undefined                                   | Return translated text \u003chttps://github.com/lukeed/rosetta#rosettatkey-params-lang\u003e. If dict is defined, he will use dict. |\n| displayNames       | [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames) | Consistent translation of language, region and script display names                                                       |\n| listFormat         | [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat)     | Language-sensitive list formatting                                                                                        |\n| numberFormat       | [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat) | Language-sensitive number formatting                                                                                      |\n| pluralRules        | [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules)   | Plural-sensitive formatting and plural-related language rules                                                             |\n| dateTimeFormat     | [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat)            | Language-sensitive date and time formatting                                                                               |\n| relativeTimeFormat | [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)        | Language-sensitive relative time formatting                                                                               |\n| collator           | [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator)                  | Language-sensitive string comparison                                                                                      |\n| segmenter          | [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)                 | Language-sensitive text segmentation                                                                                      |\n| durationFormat     | [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat)            | Language-sensitive duration formatting (Experimental)                                                                     |\n\n### Locale Configuration\n\nThe `locale` field in the configuration should be a valid BCP 47 language tag (e.g., 'en-GB', 'fr', 'de-DE') or an Intl.Locale instance.\n\n```js\n// Using string locale\nconst config = {\n  en: {\n    dict: {},\n    locale: 'en-GB'\n  }\n};\n\n// Using Intl.Locale\nconst config = {\n  en: {\n    dict: {},\n    locale: new Intl.Locale('en-GB')\n  }\n};\n```\n\n### Polyfill Support (Node.JS OR Browser)\n\nTo use this library, you maybe need to add polyfills as some features are still experimental.\n\nTo fix this :\n\n- Install [missing polyfills](https://formatjs.github.io/docs/polyfills)\n- Use [polyfill-fastly.io](https://polyfill-fastly.io/) to get the polyfills\n- Use your bundler to import the polyfills (webpack, [vite](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy), etc).\n\n## Maintain\n\nThis package use [TSdx](https://github.com/jaredpalmer/tsdx). Please check documentation to update this package.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqlaffont%2Frosetty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqlaffont%2Frosetty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqlaffont%2Frosetty/lists"}