@goodandready/dsh-russian-lang 0.1.32 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/pure.js CHANGED
@@ -33,17 +33,20 @@ const getCurrencyFormat = (cur) => {
33
33
  }
34
34
 
35
35
  export const formatNumber = (val) => {
36
+ if (val === null || val === undefined || val === '') return ''
36
37
  const n = typeof val === 'number' ? val : Number(val)
37
38
  return isNaN(n) ? String(val) : numberFormat.format(n)
38
39
  }
39
40
 
40
41
  export const formatCurrency = (val, cur) => {
42
+ if (val === null || val === undefined || val === '') return ''
41
43
  const n = typeof val === 'number' ? val : Number(val)
42
44
  if (isNaN(n)) return String(val)
43
45
  return getCurrencyFormat(cur).format(n)
44
46
  }
45
47
 
46
48
  export const formatRelativeTime = (val, unit) => {
49
+ if (val === null || val === undefined || val === '') return ''
47
50
  if (typeof val === 'number' && typeof unit === 'string') {
48
51
  return relativeTimeFormat.format(val, unit)
49
52
  }
@@ -116,15 +119,18 @@ export const inflect = (phrase, cName) => {
116
119
 
117
120
  // ------------------------------------------------- подстановка и плюрализация
118
121
 
119
- export const fill = (template, params) => String(template).replace(/\{(\w+)(?::(\w+))?\}/g, (match, name, spec) => {
120
- if (!(name in params)) return match
121
- const val = params[name]
122
- if (spec === 'number') return formatNumber(val)
123
- if (spec === 'reltime') return formatRelativeTime(val)
124
- if (spec === 'currency') return formatCurrency(val, params.currency || 'RUB')
125
- if (INFLECT_CASES.has(spec)) return inflect(String(val), spec)
126
- return String(val)
127
- })
122
+ export const fill = (template, params) => {
123
+ if (!params || typeof params !== 'object') return String(template)
124
+ return String(template).replace(/\{(\w+)(?::(\w+))?\}/g, (match, name, spec) => {
125
+ if (!(name in params)) return match
126
+ const val = params[name]
127
+ if (spec === 'number') return formatNumber(val)
128
+ if (spec === 'reltime') return formatRelativeTime(val)
129
+ if (spec === 'currency') return formatCurrency(val, params.currency || 'RUB')
130
+ if (INFLECT_CASES.has(spec)) return inflect(String(val), spec)
131
+ return String(val)
132
+ })
133
+ }
128
134
 
129
135
  const pluralRules = new Intl.PluralRules('ru-RU')
130
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-russian-lang",
3
- "version": "0.1.32",
3
+ "version": "0.2.0",
4
4
  "description": "Russian localization for the DeepSeek Harness web UI: adds Русский as the third option in the native Settings - General - Language menu. Translates the full core surface (100% coverage of DSH 0.1.1-rc.2) plus 16 community plugin namespaces - 51 namespaces, 2899 strings (about 64% hand-reviewed, the rest machine-drafted and tracked as status: draft), with Russian plural forms, count-key plurals, a typography pass (guillemets, em dash, nbsp), a wrong-layout input hint and browser spellcheck. The locale runtime snapshot is extended at runtime on unpatched cores; no files in the DSH installation are modified. The choice is persisted through the plugin-owned russian-lang namespace.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -46,7 +46,7 @@
46
46
  "scripts": {
47
47
  "build": "python3 build.py",
48
48
  "check": "python3 tools/lint_translations.py && python3 check-coverage.py && python3 tools/term_check.py --ci",
49
- "test": "python3 test/test_extract.py",
49
+ "test": "node --test test/*.mjs && node test/_repro.cjs && python3 test/test_tools.py && python3 test/test_extract.py && python3 test/test_overflow.py",
50
50
  "smoke": "python3 test/smoke.py",
51
51
  "lint": "python3 tools/lint_translations.py"
52
52
  },