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

i18n-dialect

Package Overview
Dependencies
Maintainers
9
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-dialect - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

12

dist/src/controller.js

@@ -34,3 +34,3 @@ "use strict";

_this.pluralSelect = pluralSelect;
onReady(localeName);
onReady(name);
}

@@ -97,3 +97,3 @@ catch (e) {

: this.defaultPluralSelect(descriptor.factor);
return forms[formIndex + 0]; // explicit cast to number; some gettext formulas may return just true/false - that's bad.
return forms[(formIndex || 0) + 0]; // explicit cast to number; some gettext formulas may return just true/false - that's bad.
}

@@ -106,3 +106,3 @@ };

descriptor.substitutions.forEach(function (value, index) {
tmpStr = tmpStr.replace(new RegExp('%' + (index + 1), 'ig'), value.toString());
tmpStr = tmpStr.replace(new RegExp('%' + (index + 1), 'ig'), (value || '').toString());
});

@@ -125,3 +125,7 @@ // substitute plurality factor

var item = items_1[_i];
dict[this.getDictKeyForEntry(item)] = item.type === 'single' ? [item.translation] : item.translations;
var key = this.getDictKeyForEntry(item);
if (!key) {
continue;
}
dict[key] = item.type === 'single' ? [item.translation || ''] : item.translations;
}

@@ -128,0 +132,0 @@ return dict;

{
"name": "i18n-dialect",
"version": "1.0.6",
"version": "1.0.7",
"description": "Internationalization support library",

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

"test": "karma start --browsers Firefox --single-run",
"build": "tsc index.ts --outDir dist",
"build": "tsc --noEmit && tsc index.ts --outDir dist",
"testwatch": "karma start --browsers Firefox"

@@ -27,2 +27,3 @@ },

"array-xor": "^0.1.1",
"assert": "^1.4.1",
"browserify": "^14.4.0",

@@ -46,5 +47,3 @@ "eslint": "3.13.1",

},
"dependencies": {
"@types/assert": "^0.0.31"
}
}
"dependencies": {}
}

@@ -158,1 +158,2 @@ // ================= mocha =======================

}

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

import {
Descriptor,
PluralDescriptor
} from './types';
import { Descriptor, Scalar } from './types';
import { I18NEntry, TranslationJson, TranslationMeta } from 'i18n-proto';

@@ -14,3 +11,3 @@

protected translationGetter: (name: string, onReady: (name: string, contents: string) => void) => void,
protected onFailedSubstitution: (str: string, substitutions: (string | number)[]) => void | undefined,
protected onFailedSubstitution: (str: string, substitutions: Scalar[]) => void | undefined,
protected defaultPluralSelect: (factor: number) => number

@@ -47,3 +44,3 @@ ) { }

this.pluralSelect = pluralSelect;
onReady(localeName);
onReady(name);
} catch (e) {

@@ -115,3 +112,3 @@ onError && onError(e);

: this.defaultPluralSelect(descriptor.factor);
return forms[formIndex + 0]; // explicit cast to number; some gettext formulas may return just true/false - that's bad.
return forms[(formIndex || 0) + 0]; // explicit cast to number; some gettext formulas may return just true/false - that's bad.
}

@@ -126,3 +123,3 @@ }

descriptor.substitutions.forEach((value, index) => {
tmpStr = tmpStr.replace(new RegExp('%' + (index + 1), 'ig'), value.toString());
tmpStr = tmpStr.replace(new RegExp('%' + (index + 1), 'ig'), (value || '').toString());
});

@@ -148,3 +145,7 @@

for (let item of items) {
dict[this.getDictKeyForEntry(item)] = item.type === 'single' ? [item.translation] : item.translations;
let key = this.getDictKeyForEntry(item);
if (!key) {
continue;
}
dict[key] = item.type === 'single' ? [item.translation || ''] : item.translations;
}

@@ -151,0 +152,0 @@

@@ -5,3 +5,4 @@ export {

PluralTranslation,
PluralContextualTranslation
PluralContextualTranslation,
Scalar
} from 'i18n-stex/src/types';

@@ -8,0 +9,0 @@ import { Scalar } from 'i18n-stex/src/types';

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

import * as assert from 'assert';
declare function require(name: string): any;
const assert = require('assert');
import { PluralI18NEntry, SingleI18NEntry } from 'i18n-proto';

@@ -6,3 +7,2 @@ import { Descriptor } from '../src/types';

import {
TranslationControllerTestable,
getController,

@@ -339,3 +339,3 @@ getFailedSubstitutions,

let t = getController();
let funcs = {
let funcs: any = {
// key: plurality formula

@@ -408,3 +408,3 @@ 'nplurals=1; plural=0;': {

try {
let plural = t.pMakePluralSelectFunction('nprals=1; plural=0;'); // typo
t.pMakePluralSelectFunction('nprals=1; plural=0;'); // typo
} catch (e) {

@@ -415,3 +415,3 @@ exceptions.push(e);

try {
let plural = t.pMakePluralSelectFunction('nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 :'); // invalid func syntax
t.pMakePluralSelectFunction('nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 :'); // invalid func syntax
} catch (e) {

@@ -430,3 +430,3 @@ exceptions.push(e);

assert.equal(name, 'cs_cz'); // should match with name passed to setLocale
assert.equal(t.mDictMeta().language, 'cs_CZ'); // should match with value in json
assert.equal((t.mDictMeta() || { language: '' }).language, 'cs_CZ'); // should match with value in json
assert.equal(Object.keys(t.mDictionary()).length, 4); // entries count in test file

@@ -444,3 +444,3 @@ assert.notEqual(t.mPluralSelect(), undefined);

let t = getController();
t.setLocale('cs_cz', (name: string) => {
t.setLocale('cs_cz', (_name: string) => {
let descr: Descriptor = {

@@ -463,3 +463,3 @@ type: '_t',

let t = getController();
t.setLocale('cs_cz', (name: string) => {
t.setLocale('cs_cz', (_name: string) => {
let descr: Descriptor = {

@@ -483,3 +483,3 @@ type: '_pt',

let t = getController();
t.setLocale('cs_cz', (name: string) => {
t.setLocale('cs_cz', (_name: string) => {
let descr: Descriptor = {

@@ -514,3 +514,3 @@ type: '_nt',

let t = getController();
t.setLocale('cs_cz', (name: string) => {
t.setLocale('cs_cz', (_name: string) => {
let descr: Descriptor = {

@@ -614,3 +614,3 @@ type: '_npt',

let t = getController();
t.setLocale('cs_cz', (name: string) => {
t.setLocale('cs_cz', (_name: string) => {
let descr: Descriptor = {

@@ -633,3 +633,3 @@ type: '_t',

let t = getController();
t.setLocale('cs_cz', (name: string) => {
t.setLocale('cs_cz', (_name: string) => {
let descr: Descriptor = {

@@ -653,3 +653,3 @@ type: '_pt',

let t = getController();
t.setLocale('cs_cz', (name: string) => {
t.setLocale('cs_cz', (_name: string) => {
let descr: Descriptor = {

@@ -684,3 +684,3 @@ type: '_nt',

let t = getController();
t.setLocale('cs_cz', (name: string) => {
t.setLocale('cs_cz', (_name: string) => {
let descr: Descriptor = {

@@ -687,0 +687,0 @@ type: '_npt',

import { TranslationController } from '../src/controller';
import { I18NEntry } from 'i18n-proto';
import {
Descriptor,
PluralDescriptor
} from '../src/types';
import { Descriptor } from '../src/types';

@@ -28,3 +25,3 @@ export class TranslationControllerTestable extends TranslationController {

let failedSubstitutions = [];
let failedSubstitutions: any[] = [];
let translationGetter = (name: string, onReady: (name: string, contents: string) => void) => onReady(name, '');

@@ -47,3 +44,3 @@

translationGetter,
(str, substitutions) => failedSubstitutions.push({ str, substitutions }),
(str, substitutions) => { failedSubstitutions.push({ str, substitutions }) },
// russian default plural selector

@@ -50,0 +47,0 @@ (n) => n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2

@@ -7,5 +7,8 @@ {

},
"target": "es5",
"experimentalDecorators": true,
"sourceMap": true,
"noImplicitAny": true,
"jsx": "react",
"strictNullChecks": true,

@@ -15,3 +18,3 @@ "noEmitHelpers": true,

"noUnusedLocals": true,
"noUnusedParameters": true,
"noUnusedParameters": true
},

@@ -18,0 +21,0 @@ "exclude": [

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