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

rosetty

Package Overview
Dependencies
Maintainers
1
Versions
353
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rosetty - npm Package Compare versions

Comparing version 1.3.65 to 1.4.0

2

dist/index.d.ts

@@ -175,3 +175,3 @@ import { Locale } from 'date-fns';

export declare const locales: Locales;
export declare const rosetty: <T extends AnyObject>(initialConfig: Record<string, Language>, defaultLang?: string) => RosettyReturn<T>;
export declare const rosetty: <T extends AnyObject>(initialConfig: Record<string, Language>, defaultLang?: string, translateFallback?: boolean) => RosettyReturn<T>;
export {};

@@ -30,3 +30,3 @@ 'use strict';

var locales = dateFNSLocaleFiles;
var rosetty = function rosetty(initialConfig, defaultLang) {
var rosetty = function rosetty(initialConfig, defaultLang, translateFallback) {
var _Object$entries, _Object$entries$map;

@@ -88,3 +88,4 @@

t: function t(key, params) {
return actualLang ? rosettaInstance.t(key, params) : undefined;
return actualLang ? rosettaInstance.t(key, params) || (translateFallback ? key : undefined) : // eslint-disable-next-line prettier/prettier
translateFallback ? key : undefined;
},

@@ -91,0 +92,0 @@ //Intl Polyfill

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("date-fns"),o=require("date-fns/locale"),r=(e=require("rosetta"))&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}exports.locales=o,exports.rosetty=function(e,o){var a,l,u,c,i=e;if("object"!=typeof e)throw new Error("rosetty: data must be an object with at least one language");i=Object.keys(i).reduce((function(e,t){return"object"==typeof i[t]&&"object"==typeof i[t].dict&&"object"==typeof i[t].locale&&(e[t]=i[t]),e}),{});var f=r(null==(a=Object.entries(i))||null==(l=a.map((function(e){return[e[0],e[1].dict]})))?void 0:l.reduce((function(e,t){var o;return n({},e,((o={})[t[0]]=t[1],o))}),{})),s=function(e){if(!i[e])throw new Error("rosetty: language "+e+" not found");u=i[e],c=e,f.locale(e)};return o&&s(o),{changeLang:s,languages:Object.keys(i),getCurrentLang:function(){return c},t:function(e,t){return c?f.t(e,t):void 0},displayNames:function(e,t){var o;return new Intl.DisplayNames([null==(o=u)?void 0:o.locale.code],t).of(e)},listFormat:function(e,t){var o;return new Intl.ListFormat(null==(o=u)?void 0:o.locale.code,t).format(e)},numberFormat:function(e,t){var o;return new Intl.NumberFormat(null==(o=u)?void 0:o.locale.code,t).format(e)},pluralRules:function(e,t){var o;return new Intl.PluralRules(null==(o=u)?void 0:o.locale.code,t).select(e)},format:function(e,o,r){return void 0===r&&(r={}),t.format(e,o,n({},r,{locale:u.locale}))},formatRelative:function(e,o,r){return void 0===r&&(r={}),t.formatRelative(e,o,n({},r,{locale:u.locale}))},formatDistance:function(e,o,r){return void 0===r&&(r={}),t.formatDistance(e,o,n({},r,{locale:u.locale}))},formatDistanceToNow:function(e,o){return void 0===o&&(o={}),t.formatDistanceToNow(e,n({},o,{locale:u.locale}))},formatDuration:function(e,o){return void 0===o&&(o={}),t.formatDuration(e,n({},o,{locale:u.locale}))}}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("date-fns"),o=require("date-fns/locale"),r=(e=require("rosetta"))&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}exports.locales=o,exports.rosetty=function(e,o,a){var l,u,c,i,f=e;if("object"!=typeof e)throw new Error("rosetty: data must be an object with at least one language");f=Object.keys(f).reduce((function(e,t){return"object"==typeof f[t]&&"object"==typeof f[t].dict&&"object"==typeof f[t].locale&&(e[t]=f[t]),e}),{});var s=r(null==(l=Object.entries(f))||null==(u=l.map((function(e){return[e[0],e[1].dict]})))?void 0:u.reduce((function(e,t){var o;return n({},e,((o={})[t[0]]=t[1],o))}),{})),d=function(e){if(!f[e])throw new Error("rosetty: language "+e+" not found");c=f[e],i=e,s.locale(e)};return o&&d(o),{changeLang:d,languages:Object.keys(f),getCurrentLang:function(){return i},t:function(e,t){return i&&s.t(e,t)||(a?e:void 0)},displayNames:function(e,t){var o;return new Intl.DisplayNames([null==(o=c)?void 0:o.locale.code],t).of(e)},listFormat:function(e,t){var o;return new Intl.ListFormat(null==(o=c)?void 0:o.locale.code,t).format(e)},numberFormat:function(e,t){var o;return new Intl.NumberFormat(null==(o=c)?void 0:o.locale.code,t).format(e)},pluralRules:function(e,t){var o;return new Intl.PluralRules(null==(o=c)?void 0:o.locale.code,t).select(e)},format:function(e,o,r){return void 0===r&&(r={}),t.format(e,o,n({},r,{locale:c.locale}))},formatRelative:function(e,o,r){return void 0===r&&(r={}),t.formatRelative(e,o,n({},r,{locale:c.locale}))},formatDistance:function(e,o,r){return void 0===r&&(r={}),t.formatDistance(e,o,n({},r,{locale:c.locale}))},formatDistanceToNow:function(e,o){return void 0===o&&(o={}),t.formatDistanceToNow(e,n({},o,{locale:c.locale}))},formatDuration:function(e,o){return void 0===o&&(o={}),t.formatDuration(e,n({},o,{locale:c.locale}))}}};
//# sourceMappingURL=rosetty.cjs.production.min.js.map

@@ -24,3 +24,3 @@ import { format, formatRelative, formatDistance, formatDistanceToNow, formatDuration } from 'date-fns';

var locales = dateFNSLocaleFiles;
var rosetty = function rosetty(initialConfig, defaultLang) {
var rosetty = function rosetty(initialConfig, defaultLang, translateFallback) {
var _Object$entries, _Object$entries$map;

@@ -82,3 +82,4 @@

t: function t(key, params) {
return actualLang ? rosettaInstance.t(key, params) : undefined;
return actualLang ? rosettaInstance.t(key, params) || (translateFallback ? key : undefined) : // eslint-disable-next-line prettier/prettier
translateFallback ? key : undefined;
},

@@ -85,0 +86,0 @@ //Intl Polyfill

{
"version": "1.3.65",
"version": "1.4.0",
"license": "MIT",

@@ -64,3 +64,5 @@ "main": "dist/index.js",

"devDependencies": {
"@jest/globals": "^29.1.2",
"@size-limit/preset-small-lib": "8.1.0",
"@types/jest": "^29.1.1",
"@typescript-eslint/eslint-plugin": "5.39.0",

@@ -67,0 +69,0 @@ "@typescript-eslint/parser": "5.39.0",

@@ -41,2 +41,3 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/1ff0c28615640d86e758/maintainability)](https://codeclimate.com/github/flexper/rosetty/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/1ff0c28615640d86e758/test_coverage)](https://codeclimate.com/github/flexper/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)

| defaultLang | string? | Specify default language to use (should be the same as config) |
| defaultLang | boolean? | Return fallback if translation is not defined |

@@ -43,0 +44,0 @@ **Return**

@@ -250,3 +250,4 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */

initialConfig: Record<string, Language>,
defaultLang?: string
defaultLang?: string,
translateFallback?: boolean
): RosettyReturn<T> => {

@@ -308,4 +309,6 @@ let config: Record<string, Language> = initialConfig;

actualLang
? rosettaInstance.t(key as unknown as string, params)
: undefined,
? rosettaInstance.t(key as unknown as string, params) ||
(translateFallback ? key : undefined)
: // eslint-disable-next-line prettier/prettier
(translateFallback ? key : undefined),
//Intl Polyfill

@@ -312,0 +315,0 @@ displayNames: (langCode: string, options: Partial<DisplayNamesOptions>) => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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