New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ckpack/i18n

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckpack/i18n - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

8

dist/index.d.ts

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

import type { Messages, Params } from './types';
import type { Messages, Message, Params } from './types';
declare class I18n {

@@ -49,3 +49,9 @@ locale: string;

setLocale(locale: string): boolean;
/**
* 动态设置语言数据
* @param locale 语言类型
* @param messages 语言环境内容
*/
setLocaleMessage(locale: string, message: Message): void;
}
export default I18n;

@@ -51,3 +51,3 @@ /**

this.fallbackLocale = fallbackLocale || locale;
this.messages = messages;
this.messages = messages || {};
}

@@ -95,4 +95,12 @@ /**

}
/**
* 动态设置语言数据
* @param locale 语言类型
* @param messages 语言环境内容
*/
setLocaleMessage(locale, message) {
this.messages[locale] = message;
}
}
export default I18n;

@@ -57,3 +57,3 @@ (function (global, factory) {

this.fallbackLocale = fallbackLocale || locale;
this.messages = messages;
this.messages = messages || {};
}

@@ -101,2 +101,10 @@ /**

}
/**
* 动态设置语言数据
* @param locale 语言类型
* @param messages 语言环境内容
*/
setLocaleMessage(locale, message) {
this.messages[locale] = message;
}
}

@@ -103,0 +111,0 @@

2

dist/index.min.js

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

!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(e="undefined"!=typeof globalThis?globalThis:e||self).I18n=s()}(this,(function(){"use strict";return class{constructor(e){const{locale:s,fallbackLocale:t,messages:o}=e;this.locale=s,this.fallbackLocale=t||s,this.messages=o}t(e,s){const t=this.locale,o=e.split(".");return function(e,s){if(!e||"string"!=typeof e||!s)return e;const t=e.split(/[{}]/);let o="";for(let e=0;e<t.length;e+=1){const i=t[e];if(i)if(e%2!=0){if(!(i in s)&&!Array.isArray(s))throw new Error(`${i} not in params`);o+=s[i]}else o+=i}return o}(this.getMessagesByLocale(o,t)||this.getMessagesByLocale(o,this.fallbackLocale),s)}getMessagesByLocale(e,s){return e.reduce(((e,s)=>{if(e&&s in e)return e[s]}),this.messages[s])}setLocale(e){return-1!==Object.keys(this.messages).indexOf(e)&&(this.locale=e,!0)}}}));
!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(e="undefined"!=typeof globalThis?globalThis:e||self).I18n=s()}(this,(function(){"use strict";return class{constructor(e){const{locale:s,fallbackLocale:t,messages:o}=e;this.locale=s,this.fallbackLocale=t||s,this.messages=o||{}}t(e,s){const t=this.locale,o=e.split(".");return function(e,s){if(!e||"string"!=typeof e||!s)return e;const t=e.split(/[{}]/);let o="";for(let e=0;e<t.length;e+=1){const i=t[e];if(i)if(e%2!=0){if(!(i in s)&&!Array.isArray(s))throw new Error(`${i} not in params`);o+=s[i]}else o+=i}return o}(this.getMessagesByLocale(o,t)||this.getMessagesByLocale(o,this.fallbackLocale),s)}getMessagesByLocale(e,s){return e.reduce(((e,s)=>{if(e&&s in e)return e[s]}),this.messages[s])}setLocale(e){return-1!==Object.keys(this.messages).indexOf(e)&&(this.locale=e,!0)}setLocaleMessage(e,s){this.messages[e]=s}}}));

@@ -0,5 +1,6 @@

export interface Message {
[message: string]: any;
}
export interface Messages {
[locale: string]: {
[message: string]: any;
};
[locale: string]: Message;
}

@@ -6,0 +7,0 @@ export interface Params {

{
"name": "@ckpack/i18n",
"version": "0.1.0",
"version": "0.2.0",
"description": "The World's smallest fastest internationalization library",

@@ -5,0 +5,0 @@ "repository": "https://github.com/ckpack/i18n",

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