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

@superset-ui/translation

Package Overview
Dependencies
Maintainers
14
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superset-ui/translation - npm Package Compare versions

Comparing version 0.14.9 to 0.14.20

esm/types/index.js

14

esm/index.js
"use strict";
exports.__esModule = true;
var _exportNames = {
configure: true,
t: true,
tn: true
};
exports.tn = exports.t = exports.configure = void 0;
var _TranslatorSingleton = require("./TranslatorSingleton");
exports.configure = _TranslatorSingleton.configure;
exports.t = _TranslatorSingleton.t;
exports.tn = _TranslatorSingleton.tn;
Object.keys(_TranslatorSingleton).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
exports[key] = _TranslatorSingleton[key];
});

@@ -21,4 +16,3 @@ var _types = require("./types");

if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
exports[key] = _types[key];
});

@@ -8,2 +8,4 @@ "use strict";

var _core = require("@superset-ui/core");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -20,3 +22,3 @@

lang: 'en',
plural_forms: 'nplurals=1; plural=0'
plural_forms: 'nplurals=2; plural=(n != 1)'
}

@@ -31,2 +33,4 @@ }

_defineProperty(this, "locale", void 0);
const {

@@ -37,4 +41,42 @@ languagePack = DEFAULT_LANGUAGE_PACK

this.i18n = new _jed.default(languagePack);
this.locale = this.i18n.options.locale_data.superset[''].lang;
}
/**
* Add additional translations on the fly, used by plugins.
*/
addTranslation(key, texts) {
const translations = this.i18n.options.locale_data.superset;
if (key in translations) {
_core.logging.warn("Duplicate translation key \"" + key + "\", will override.");
}
translations[key] = texts;
}
/**
* Add a series of translations.
*/
addTranslations(translations) {
if (translations && !Array.isArray(translations)) {
Object.entries(translations).forEach(([key, vals]) => this.addTranslation(key, vals));
} else {
_core.logging.warn('Invalid translations');
}
}
addLocaleData(data) {
// always fallback to English
const translations = (data == null ? void 0 : data[this.locale]) || (data == null ? void 0 : data.en);
if (translations) {
this.addTranslations(translations);
} else {
_core.logging.warn('Invalid locale data');
}
}
translate(input, ...args) {

@@ -44,4 +86,10 @@ return this.i18n.translate(input).fetch(...args);

translateWithNumber(singular, plural, num = 0, ...args) {
return this.i18n.translate(singular).ifPlural(num, plural).fetch(...args);
translateWithNumber(key, ...args) {
const [plural, num, ...rest] = args;
if (typeof plural === 'number') {
return this.i18n.translate(key).ifPlural(plural, key).fetch(plural, num, ...args);
}
return this.i18n.translate(key).ifPlural(num, plural).fetch(...rest);
}

@@ -48,0 +96,0 @@

@@ -5,2 +5,5 @@ "use strict";

exports.configure = configure;
exports.addTranslation = addTranslation;
exports.addTranslations = addTranslations;
exports.addLocaleData = addLocaleData;
exports.t = t;

@@ -35,2 +38,14 @@ exports.tn = tn;

function addTranslation(key, translations) {
return getInstance().addTranslation(key, translations);
}
function addTranslations(translations) {
return getInstance().addTranslations(translations);
}
function addLocaleData(data) {
return getInstance().addLocaleData(data);
}
function t(input, ...args) {

@@ -40,4 +55,4 @@ return getInstance().translate(input, ...args);

function tn(singular, plural, num, ...args) {
return getInstance().translateWithNumber(singular, plural, num, ...args);
function tn(key, ...args) {
return getInstance().translateWithNumber(key, ...args);
}

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

export { configure, t, tn } from './TranslatorSingleton';
export * from './TranslatorSingleton';
export * from './types';
//# sourceMappingURL=index.d.ts.map
"use strict";
exports.__esModule = true;
var _exportNames = {
configure: true,
t: true,
tn: true
};
exports.tn = exports.t = exports.configure = void 0;
var _TranslatorSingleton = require("./TranslatorSingleton");
exports.configure = _TranslatorSingleton.configure;
exports.t = _TranslatorSingleton.t;
exports.tn = _TranslatorSingleton.tn;
Object.keys(_TranslatorSingleton).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
exports[key] = _TranslatorSingleton[key];
});

@@ -21,4 +16,3 @@ var _types = require("./types");

if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
exports[key] = _types[key];
});

@@ -1,14 +0,18 @@

import { TranslatorConfig } from './types';
interface Jed {
translate(input: string): Jed;
ifPlural(value: number, plural: string): Jed;
fetch(...args: unknown[]): string;
}
import { Jed, TranslatorConfig, Locale, Translations, LocaleData } from './types';
export default class Translator {
i18n: Jed;
locale: Locale;
constructor(config?: TranslatorConfig);
/**
* Add additional translations on the fly, used by plugins.
*/
addTranslation(key: string, texts: ReadonlyArray<string>): void;
/**
* Add a series of translations.
*/
addTranslations(translations: Translations): void;
addLocaleData(data: LocaleData): void;
translate(input: string, ...args: unknown[]): string;
translateWithNumber(singular: string, plural: string, num?: number, ...args: unknown[]): string;
translateWithNumber(key: string, ...args: unknown[]): string;
}
export {};
//# sourceMappingURL=Translator.d.ts.map

@@ -8,2 +8,4 @@ "use strict";

var _core = require("@superset-ui/core");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -20,3 +22,3 @@

lang: 'en',
plural_forms: 'nplurals=1; plural=0'
plural_forms: 'nplurals=2; plural=(n != 1)'
}

@@ -31,2 +33,4 @@ }

_defineProperty(this, "locale", void 0);
const {

@@ -37,4 +41,42 @@ languagePack = DEFAULT_LANGUAGE_PACK

this.i18n = new _jed.default(languagePack);
this.locale = this.i18n.options.locale_data.superset[''].lang;
}
/**
* Add additional translations on the fly, used by plugins.
*/
addTranslation(key, texts) {
const translations = this.i18n.options.locale_data.superset;
if (key in translations) {
_core.logging.warn("Duplicate translation key \"" + key + "\", will override.");
}
translations[key] = texts;
}
/**
* Add a series of translations.
*/
addTranslations(translations) {
if (translations && !Array.isArray(translations)) {
Object.entries(translations).forEach(([key, vals]) => this.addTranslation(key, vals));
} else {
_core.logging.warn('Invalid translations');
}
}
addLocaleData(data) {
// always fallback to English
const translations = (data == null ? void 0 : data[this.locale]) || (data == null ? void 0 : data.en);
if (translations) {
this.addTranslations(translations);
} else {
_core.logging.warn('Invalid locale data');
}
}
translate(input, ...args) {

@@ -44,4 +86,10 @@ return this.i18n.translate(input).fetch(...args);

translateWithNumber(singular, plural, num = 0, ...args) {
return this.i18n.translate(singular).ifPlural(num, plural).fetch(...args);
translateWithNumber(key, ...args) {
const [plural, num, ...rest] = args;
if (typeof plural === 'number') {
return this.i18n.translate(key).ifPlural(plural, key).fetch(plural, num, ...args);
}
return this.i18n.translate(key).ifPlural(num, plural).fetch(...rest);
}

@@ -48,0 +96,0 @@

import Translator from './Translator';
import { TranslatorConfig } from './types';
import { TranslatorConfig, Translations, LocaleData } from './types';
declare function configure(config?: TranslatorConfig): Translator;
declare function addTranslation(key: string, translations: string[]): void;
declare function addTranslations(translations: Translations): void;
declare function addLocaleData(data: LocaleData): void;
declare function t(input: string, ...args: unknown[]): string;
declare function tn(singular: string, plural: string, num?: number, ...args: unknown[]): string;
export { configure, t, tn };
declare function tn(key: string, ...args: unknown[]): string;
export { configure, addTranslation, addTranslations, addLocaleData, t, tn };
//# sourceMappingURL=TranslatorSingleton.d.ts.map

@@ -5,2 +5,5 @@ "use strict";

exports.configure = configure;
exports.addTranslation = addTranslation;
exports.addTranslations = addTranslations;
exports.addLocaleData = addLocaleData;
exports.t = t;

@@ -35,2 +38,14 @@ exports.tn = tn;

function addTranslation(key, translations) {
return getInstance().addTranslation(key, translations);
}
function addTranslations(translations) {
return getInstance().addTranslations(translations);
}
function addLocaleData(data) {
return getInstance().addLocaleData(data);
}
function t(input, ...args) {

@@ -40,4 +55,4 @@ return getInstance().translate(input, ...args);

function tn(singular, plural, num, ...args) {
return getInstance().translateWithNumber(singular, plural, num, ...args);
function tn(key, ...args) {
return getInstance().translateWithNumber(key, ...args);
}
{
"name": "@superset-ui/translation",
"version": "0.14.9",
"version": "0.14.20",
"description": "Superset UI translation",

@@ -31,6 +31,9 @@ "sideEffects": false,

},
"peerDependencies": {
"@superset-ui/core": "^0.14.18"
},
"publishConfig": {
"access": "public"
},
"gitHead": "92e0ccbec0e753335a03fb411b59242f4b624391"
"gitHead": "59f81e6c9ddee2a1a039b95b22954dca963db608"
}

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