bobril-g11n
Advanced tools
Comparing version 5.0.1 to 5.0.2
# CHANGELOG | ||
## 5.0.2 | ||
Make it compatible with noUncheckedIndexedAccess. | ||
## 5.0.1 | ||
@@ -4,0 +8,0 @@ |
@@ -0,0 +0,0 @@ export * from './src/msgFormatParser'; |
{ | ||
"name": "bobril-g11n", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Bobril globalization", | ||
@@ -29,2 +29,3 @@ "main": "index.js", | ||
"noFallthroughCasesInSwitch": true, | ||
"noUncheckedIndexedAccess": true, | ||
"strict": true, | ||
@@ -31,0 +32,0 @@ "strictNullChecks": true |
@@ -16,3 +16,3 @@ import { MsgAst } from "./msgFormatParser"; | ||
for (let i = 0; i < msgAst.length; i++) { | ||
let item = msgAst[i]; | ||
let item = msgAst[i]!; | ||
extractUsedParamsRec(usedParams, item); | ||
@@ -19,0 +19,0 @@ } |
export function jsonp(url: string): Promise<void> { | ||
return new Promise((r, e) => { | ||
let script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.charset = 'utf-8'; | ||
let script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.onload = () => { | ||
@@ -10,3 +9,3 @@ r(); | ||
script.onerror = (_ev) => { | ||
e('Failed to load ' + url); | ||
e("Failed to load " + url); | ||
}; | ||
@@ -13,0 +12,0 @@ script.src = url; |
@@ -8,12 +8,25 @@ export interface ILocaleRules { | ||
let defs: { | ||
en: ILocaleRules; | ||
[locale: string]: ILocaleRules; | ||
} = Object.create(null); | ||
defs['en'] = { | ||
defs["en"] = { | ||
pluralFn(n: number, ord: boolean) { | ||
var s = String(n).split("."), v0 = !s[1], t0 = Number(s[0]) == n, n10: any = t0 && s[0].slice(-1), n100: any = t0 && s[0].slice(-2); | ||
if (ord) return n10 == 1 && n100 != 11 ? "one" : n10 == 2 && n100 != 12 ? "two" : n10 == 3 && n100 != 13 ? "few" : "other"; return n == 1 && v0 ? "one" : "other" | ||
var s = String(n).split("."), | ||
v0 = !s[1], | ||
t0 = Number(s[0]) == n, | ||
n10: any = t0 && s[0]!.slice(-1), | ||
n100: any = t0 && s[0]!.slice(-2); | ||
if (ord) | ||
return n10 == 1 && n100 != 11 | ||
? "one" | ||
: n10 == 2 && n100 != 12 | ||
? "two" | ||
: n10 == 3 && n100 != 13 | ||
? "few" | ||
: "other"; | ||
return n == 1 && v0 ? "one" : "other"; | ||
}, | ||
td: ",", | ||
dd: "." | ||
dd: ".", | ||
}; | ||
@@ -26,5 +39,4 @@ | ||
export function getLanguageFromLocale(locale: string): string { | ||
let idx = locale.indexOf('-'); | ||
if (idx >= 0) | ||
return locale.substr(0, idx); | ||
let idx = locale.indexOf("-"); | ||
if (idx >= 0) return locale.substr(0, idx); | ||
return locale; | ||
@@ -38,3 +50,3 @@ } | ||
if (!d) { | ||
d = defs['en']; | ||
d = defs["en"]; | ||
} | ||
@@ -41,0 +53,0 @@ } |
@@ -171,3 +171,3 @@ import { isObject, isArray } from "bobril"; | ||
if (isParserError(identificator)) return identificator; | ||
if (identificator[0] <= "9") { | ||
if (identificator[0]! <= "9") { | ||
if (isCloseBracketToken()) { | ||
@@ -201,3 +201,3 @@ advanceNextToken(); | ||
id: identificator, | ||
format | ||
format, | ||
} as const; | ||
@@ -282,3 +282,3 @@ let name = parseIdentificator(); | ||
if (m) { | ||
format.offset = parseInt(m[1], 10); | ||
format.offset = parseInt(m[1]!, 10); | ||
} else if (chars === "offset:") { | ||
@@ -285,0 +285,0 @@ skipWs(); |
@@ -58,5 +58,3 @@ import * as moment from "moment"; | ||
return (val, _opt) => { | ||
return moment(val) | ||
.locale(locale) | ||
.fromNow(true); | ||
return moment(val).locale(locale).fromNow(true); | ||
}; | ||
@@ -72,5 +70,3 @@ } | ||
return (val, _opt) => { | ||
return moment(val) | ||
.locale(locale) | ||
.fromNow(false); | ||
return moment(val).locale(locale).fromNow(false); | ||
}; | ||
@@ -81,5 +77,3 @@ } | ||
return (val, _opt) => { | ||
return noFuture(moment(val)) | ||
.locale(locale) | ||
.fromNow(true); | ||
return noFuture(moment(val)).locale(locale).fromNow(true); | ||
}; | ||
@@ -95,5 +89,3 @@ } | ||
return (val, _opt) => { | ||
return noFuture(moment(val)) | ||
.locale(locale) | ||
.fromNow(false); | ||
return noFuture(moment(val)).locale(locale).fromNow(false); | ||
}; | ||
@@ -103,5 +95,3 @@ } | ||
return (val, _opt) => { | ||
return moment(val) | ||
.locale(locale) | ||
.calendar(); | ||
return moment(val).locale(locale).calendar(); | ||
}; | ||
@@ -117,5 +107,3 @@ } | ||
return (val, _opt) => { | ||
return moment(val) | ||
.locale(locale) | ||
.format(style); | ||
return moment(val).locale(locale).format(style); | ||
}; | ||
@@ -139,3 +127,3 @@ } | ||
if (i > 0) comp.addBody("+"); | ||
let item = msgAst[i]; | ||
let item = msgAst[i]!; | ||
if (typeof item === "string") { | ||
@@ -167,3 +155,3 @@ comp.addBody(comp.addConstant(item)); | ||
if (i > 0) comp.addBody(","); | ||
let item = vals[i]; | ||
let item = vals[i]!; | ||
if (isString(item)) { | ||
@@ -170,0 +158,0 @@ comp.addBody(comp.addConstant(item)); |
@@ -31,3 +31,3 @@ import * as b from "bobril"; | ||
pathToTranslation: () => undefined, | ||
runScriptAsync: jsonp | ||
runScriptAsync: jsonp, | ||
}; | ||
@@ -77,3 +77,3 @@ | ||
} | ||
let format: IMessageFormat; | ||
let format: IMessageFormat | undefined; | ||
if (Array.isArray(message)) { | ||
@@ -170,3 +170,3 @@ if (typeof message[0] === "string") { | ||
} | ||
let key = keysByTranslationId[m]; | ||
let key = keysByTranslationId[m]!; | ||
if (message.length == 1) return [key]; | ||
@@ -243,3 +243,3 @@ return [key, serializeParams(message[1])]; | ||
.then(() => cfg.runScriptAsync!(p!)) | ||
.catch(e => { | ||
.catch((e) => { | ||
console.warn(e); | ||
@@ -289,3 +289,3 @@ if (locale != cfg.defaultLocale) | ||
for (let i = 0; i < msgs.length; i++) { | ||
key2TranslationId.set(msgs[i], i); | ||
key2TranslationId.set(msgs[i]!, i); | ||
} | ||
@@ -292,0 +292,0 @@ return; |
@@ -25,2 +25,3 @@ { | ||
"noImplicitThis": true, | ||
"noUncheckedIndexedAccess": true, | ||
"noUnusedLocals": true, | ||
@@ -40,3 +41,3 @@ "noUnusedParameters": true, | ||
"files": [ | ||
"C:/Users/boris/.bbcore/tools/jasmine330.d.ts" | ||
"C:/Users/b.letocha/.bbcore/tools/jasmine330.d.ts" | ||
], | ||
@@ -43,0 +44,0 @@ "include": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56101
14
1284