@ham2k/extension-sdk 0.1.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/README.md +58 -0
- package/dist/activityAdifImport.js +45 -0
- package/dist/activityExports.js +157 -0
- package/dist/activityScoring.js +227 -0
- package/dist/appClock.js +42 -0
- package/dist/dxcc.js +25 -0
- package/dist/exportNames.js +57 -0
- package/dist/i18n/activityExports.en.json +4 -0
- package/dist/i18n/activityExports.es.json +4 -0
- package/dist/i18n/activityScoring.en.json +11 -0
- package/dist/i18n/activityScoring.es.json +11 -0
- package/dist/i18n.js +43 -0
- package/dist/index.d.ts +1361 -0
- package/dist/index.js +231 -0
- package/dist/location.js +19 -0
- package/dist/modes.js +28 -0
- package/dist/number-format.js +68 -0
- package/dist/referenceActivity.js +226 -0
- package/dist/scoring.js +163 -0
- package/dist/settingsPanels.js +59 -0
- package/dist/templateContext.js +113 -0
- package/dist/templates.js +76 -0
- package/dist/testOperation.js +6 -0
- package/dist/types.js +0 -0
- package/package.json +110 -0
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import i18next from "i18next";
|
|
2
|
+
function createCachedTranslator(resources) {
|
|
3
|
+
let cachedLocale;
|
|
4
|
+
let cachedT;
|
|
5
|
+
return (ctx) => {
|
|
6
|
+
const locale = ctx.locale ?? "en";
|
|
7
|
+
if (!cachedT || cachedLocale !== locale) {
|
|
8
|
+
cachedLocale = locale;
|
|
9
|
+
cachedT = createTranslator(resources, locale);
|
|
10
|
+
}
|
|
11
|
+
return cachedT;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function createTranslator(resources, currentLocale) {
|
|
15
|
+
const instance = i18next.createInstance();
|
|
16
|
+
instance.init({
|
|
17
|
+
lng: currentLocale,
|
|
18
|
+
fallbackLng: "en",
|
|
19
|
+
resources,
|
|
20
|
+
// Explicit because the engine has no Intl. i18next's PluralResolver
|
|
21
|
+
// probes for Intl.PluralRules, does not find it under QuickJS-NG, and logs
|
|
22
|
+
// "Your environment seems not to be Intl API compatible" through the host
|
|
23
|
+
// log on EVERY translator build — and createCachedTranslator builds one per
|
|
24
|
+
// extension per locale, so that is live noise on every platform.
|
|
25
|
+
//
|
|
26
|
+
// Declaring v3 makes the supported plural shape a decision rather than a
|
|
27
|
+
// silent fallback. It is inert for correctness today: no catalog uses a
|
|
28
|
+
// plural-suffixed key in either shape, and no call
|
|
29
|
+
// site passes `count` to t() — the one place that needs a plural spells it
|
|
30
|
+
// out with a ternary (core/scoring/src/scoring.ts). If a catalog ever does
|
|
31
|
+
// want plurals, v3's `key`/`key_plural` pair is what will work here.
|
|
32
|
+
compatibilityJSON: "v3",
|
|
33
|
+
interpolation: {
|
|
34
|
+
escapeValue: false
|
|
35
|
+
// Not in a browser/HTML environment
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return (key, options) => instance.t(key, options);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
createCachedTranslator,
|
|
42
|
+
createTranslator
|
|
43
|
+
};
|