@vrtmrz/livesync-commonlib 0.1.0-rc.5 → 0.1.0-rc.6
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 +11 -9
- package/dist/common/configForDoc.js +7 -2
- package/dist/common/models/setting.type.d.ts +2 -1
- package/dist/common/models/tweak.definition.d.ts +1 -1
- package/dist/common/settingConstants.d.ts +3 -2
- package/dist/common/settingConstants.js +2 -2
- package/dist/context.d.ts +2 -1
- package/dist/context.js +4 -0
- package/dist/replication/LiveSyncAbstractReplicator.d.ts +2 -1
- package/dist/serviceModules/Rebuilder.js +8 -3
- package/dist/services/BrowserServices.d.ts +2 -0
- package/dist/services/BrowserServices.js +4 -1
- package/dist/services/HeadlessServices.d.ts +2 -0
- package/dist/services/HeadlessServices.js +2 -1
- package/dist/services/base/CommonlibMessages.d.ts +318 -0
- package/dist/services/base/CommonlibMessages.js +313 -0
- package/dist/services/base/MessageTranslator.d.ts +5 -2
- package/dist/services/base/MessageTranslator.js +21 -0
- package/dist/services/base/ServiceBase.d.ts +1 -1
- package/dist/services/base/ServiceBase.js +2 -4
- package/dist/services/base/SettingService.d.ts +3 -0
- package/dist/services/base/SettingService.js +3 -2
- package/docs/development.md +27 -14
- package/docs/p2p-transport-lifecycle.md +10 -2
- package/docs/proven-in-use.md +18 -12
- package/docs/releasing.md +14 -0
- package/package.json +1 -26
- package/dist/common/i18n.d.ts +0 -18
- package/dist/common/i18n.js +0 -101
- package/dist/common/messages/combinedMessages.dev.d.ts +0 -7
- package/dist/common/messages/combinedMessages.dev.js +0 -44
- package/dist/common/messages/combinedMessages.prod.d.ts +0 -9276
- package/dist/common/messages/combinedMessages.prod.js +0 -9283
- package/dist/common/messages/de.d.ts +0 -297
- package/dist/common/messages/de.js +0 -7
- package/dist/common/messages/def.d.ts +0 -1123
- package/dist/common/messages/def.js +0 -7
- package/dist/common/messages/es.d.ts +0 -689
- package/dist/common/messages/es.js +0 -7
- package/dist/common/messages/fr.d.ts +0 -582
- package/dist/common/messages/fr.js +0 -7
- package/dist/common/messages/he.d.ts +0 -583
- package/dist/common/messages/he.js +0 -7
- package/dist/common/messages/ja.d.ts +0 -838
- package/dist/common/messages/ja.js +0 -7
- package/dist/common/messages/ko.d.ts +0 -800
- package/dist/common/messages/ko.js +0 -7
- package/dist/common/messages/ru.d.ts +0 -858
- package/dist/common/messages/ru.js +0 -7
- package/dist/common/messages/zh-tw.d.ts +0 -384
- package/dist/common/messages/zh-tw.js +0 -7
- package/dist/common/messages/zh.d.ts +0 -1093
- package/dist/common/messages/zh.js +0 -7
- package/dist/common/messagesJson/de.json +0 -295
- package/dist/common/messagesJson/en.json +0 -1121
- package/dist/common/messagesJson/es.json +0 -687
- package/dist/common/messagesJson/fr.json +0 -580
- package/dist/common/messagesJson/he.json +0 -581
- package/dist/common/messagesJson/ja.json +0 -836
- package/dist/common/messagesJson/ko.json +0 -798
- package/dist/common/messagesJson/ru.json +0 -856
- package/dist/common/messagesJson/zh-tw.json +0 -382
- package/dist/common/messagesJson/zh.json +0 -1091
- package/dist/common/rosetta.d.ts +0 -42
- package/dist/common/rosetta.js +0 -57
package/docs/proven-in-use.md
CHANGED
|
@@ -4,13 +4,13 @@ Commonlib is extracted from the implementation shared by [Self-hosted LiveSync](
|
|
|
4
4
|
|
|
5
5
|
The useful evidence is host- and contract-specific. Focused Commonlib tests establish reusable result semantics; Self-hosted LiveSync tests establish how those contracts compose into the Obsidian plug-in and CLI. The Webapp has focused adapter tests, and both the Webapp and WebPeer are type-checked and built, but they do not have an equally current end-to-end gate.
|
|
6
6
|
|
|
7
|
-
The
|
|
7
|
+
The code paths below identify the maintained Self-hosted LiveSync composition points used to establish this package boundary. The exact reviewed downstream revision and compatibility imports are recorded in [`migration/downstream-imports.json`](migration/downstream-imports.json), which is regenerated by the package-boundary tooling rather than copied into prose links. The integration descriptions must still be reviewed when the maintained downstream changes.
|
|
8
8
|
|
|
9
9
|
## Obsidian plug-in
|
|
10
10
|
|
|
11
|
-
The plug-in extends the neutral `ServiceContext` with Obsidian-owned capabilities in
|
|
11
|
+
The plug-in extends the neutral `ServiceContext` with Obsidian-owned capabilities in `src/modules/services/ObsidianServiceContext.ts`. One context instance carries the LiveSync-owned translator and event hub through the Service Hub rather than placing those dependencies in Commonlib globals. Commonlib supplies its typed English fallback when another host omits the translator.
|
|
12
12
|
|
|
13
|
-
The consumer
|
|
13
|
+
The consumer contract in `test/contracts/serviceContext.ts` checks shared result semantics and exact context identity across the composed services. The real-Obsidian suite documented in `test/e2e-obsidian/README.md` then covers plug-in loading, representative Svelte dialogue mounts, Vault reflection, CouchDB and Object Storage synchronisation, a two-device P2P Setup URI round-trip, two-Vault behaviour, and other Obsidian-owned boundaries.
|
|
14
14
|
|
|
15
15
|
Most replication and storage services used by the plug-in still enter through explicit `compat/*` paths. Those imports prove that the published compatibility boundary supports the current migration; they are not examples of a finished high-level client API.
|
|
16
16
|
|
|
@@ -20,37 +20,43 @@ Commonlib's confirmation contract can also convey a host-neutral vertical action
|
|
|
20
20
|
|
|
21
21
|
## CLI
|
|
22
22
|
|
|
23
|
-
The CLI extends the same neutral context with its database path and injected `StandardIo` in
|
|
23
|
+
The CLI extends the same neutral context with its database path and injected `StandardIo` in `src/apps/cli/services/NodeServiceContext.ts`. Its entry point creates the Node standard-I/O adapter once and passes it to command composition, while unit tests provide stream-independent fakes for parsing, prompts, standard output, and standard error.
|
|
24
24
|
|
|
25
|
-
The CLI filesystem composition receives a configured base directory and constructs the rooted Node storage adapter in
|
|
25
|
+
The CLI filesystem composition receives a configured base directory and constructs the rooted Node storage adapter in `src/apps/cli/adapters/NodeFileSystemAdapter.ts`. Commonlib's shared storage result table checks the focused root contract; the consumer adds its file cache, Vault-shaped operations, case handling, and command policy.
|
|
26
26
|
|
|
27
|
-
The maintained CLI checks include unit tests, Deno-driven CLI E2E, Compose-based compatibility runs, and the
|
|
27
|
+
The maintained CLI checks include unit tests, Deno-driven CLI E2E, Compose-based compatibility runs, and the CLI-to-real-Obsidian synchronisation scenario in `test/e2e-obsidian/scripts/cli-to-obsidian-sync.ts`. The latter is the strongest current evidence that the CLI and plug-in compose compatible Commonlib behaviour across two hosts.
|
|
28
28
|
|
|
29
29
|
## Webapp
|
|
30
30
|
|
|
31
|
-
The Webapp receives an already authorised `FileSystemDirectoryHandle` from its host and constructs `FileSystemAccessStorageAdapter` inside
|
|
31
|
+
The Webapp receives an already authorised `FileSystemDirectoryHandle` from its host and constructs `FileSystemAccessStorageAdapter` inside `src/apps/webapp/adapters/FSAPIFileSystemAdapter.ts`. The adapter does not call `showDirectoryPicker()`, choose a directory, or persist the handle. This is the maintained application example for the browser entry's root-ownership rule.
|
|
32
32
|
|
|
33
33
|
The browser and Node storage implementations run through the same Commonlib result contract, and the Webapp adapter has focused unit coverage. The Webapp is also type-checked and built by downstream verification. Its browser E2E has not been kept at the same level as the Obsidian and CLI suites, so the documentation does not treat Webapp integration as equivalent real-runtime evidence.
|
|
34
34
|
|
|
35
35
|
## WebPeer and browser service composition
|
|
36
36
|
|
|
37
|
-
The browser service composition in
|
|
37
|
+
The browser service composition in `src/apps/browser/createLiveSyncBrowserServiceHub.ts` supplies browser-owned API and UI services around a caller-supplied context. WebPeer and the browser applications exercise this compatibility surface through type checks and builds.
|
|
38
38
|
|
|
39
|
-
The Obsidian plug-in, CLI, and Webapp compose P2P ownership through `useP2PReplicatorFeature`. Commands and Obsidian views retain its live result object and resolve the current replicator when an action occurs. WebPeer still enters through the deprecated combined compatibility function, which now delegates the same ownership and lifecycle to the focused feature instead of maintaining a second implementation. Downstream Deno and Compose P2P E2E cover peer discovery and synchronisation
|
|
39
|
+
The Obsidian plug-in, CLI, and Webapp compose P2P ownership through `useP2PReplicatorFeature`. Commands and Obsidian views retain its live result object and resolve the current replicator when an action occurs. WebPeer still enters through the deprecated combined compatibility function, which now delegates the same ownership and lifecycle to the focused feature instead of maintaining a second implementation. Downstream Deno and Compose P2P E2E cover headless peer discovery and synchronisation. The real-Obsidian Setup URI workflow additionally covers first-device local initialisation, one-pass additional-device Fetch, explicit peer approval, Vault reflection, and a two-way note round-trip. The Webapp and WebPeer UI surfaces themselves remain build- and type-check evidence rather than equivalent real-runtime gates.
|
|
40
40
|
|
|
41
|
-
This is evidence that the current package boundary can be consumed without the Obsidian host, but it is not yet a recommended standalone Commonlib client factory. The high-level lifecycle, readiness, error, and disposal contract remains
|
|
41
|
+
This is evidence that the current package boundary can be consumed without the Obsidian host, but it is not yet a recommended standalone Commonlib client factory. The high-level lifecycle, readiness, error, and disposal contract remains future package work after Self-hosted LiveSync 1.0 rather than a gate for that release.
|
|
42
|
+
|
|
43
|
+
## Verification ownership
|
|
44
|
+
|
|
45
|
+
Commonlib tests the result and lifecycle contracts of the real implementations it publishes. A maintained host tests only its own composition, persistence, presentation, restart, and policy. When a current host test needs isolation, the host may inject the narrow structural capability it consumes and provide a small fake or spy for that test; Commonlib does not publish test-runner-specific mocks or expose its private service graph.
|
|
46
|
+
|
|
47
|
+
This is a boundary rule, not a requirement to build mock and spy infrastructure before LiveSync 1.0. Add a substitution seam only when a current consumer-owned test needs one. Exact-package downstream checks and focused real-runtime E2E remain the integration proof that the real Commonlib implementation and host composition work together.
|
|
42
48
|
|
|
43
49
|
## What a new consumer should copy
|
|
44
50
|
|
|
45
51
|
A new integration should start with the focused entries, not by reproducing Self-hosted LiveSync's compatibility imports:
|
|
46
52
|
|
|
47
|
-
- create one `ServiceContext` per independently composed client, inject its translator and events, and extend it only with capabilities owned by that host;
|
|
53
|
+
- create one `ServiceContext` per independently composed client, optionally inject its translator and events, and extend it only with capabilities owned by that host; an omitted translator renders Commonlib's canonical English messages;
|
|
48
54
|
- let the host select and authorise a storage root, then pass the root once to the Node or browser storage factory;
|
|
49
55
|
- inject `StandardIo` into CLI policy so that protocol output and prompts remain testable; and
|
|
50
56
|
- use `/remote-configurations` when a host needs to create or select saved remote profiles, while keeping naming prompts, persistence, and restart policy in the host; and
|
|
51
57
|
- run the relevant Commonlib result contract against another implementation before describing matching TypeScript shapes as compatible behaviour.
|
|
52
58
|
|
|
53
|
-
Use the
|
|
59
|
+
Use the named consumer paths as integration examples, while retaining the ownership and limitations stated in the [root README](../readme.md), [storage guide](platform-storage.md), [standard-I/O guide](platform-standard-io.md), and [remote configuration profile guide](remote-configurations.md).
|
|
54
60
|
|
|
55
61
|
## Maintenance rule
|
|
56
62
|
|
package/docs/releasing.md
CHANGED
|
@@ -13,6 +13,20 @@ npm run verify:package
|
|
|
13
13
|
|
|
14
14
|
The gate type-checks Commonlib, runs its complete unit suite, verifies the source boundary, builds the distributable package, installs its exact tarball into a clean consumer, and bundles representative browser and Node entry points. The source `package.json` remains private to prevent publishing the repository root. Only the generated `.package` directory is publishable, and its manifest defaults to public publication on the `next` dist-tag.
|
|
15
15
|
|
|
16
|
+
### Lockfile reproducibility
|
|
17
|
+
|
|
18
|
+
Regenerate `package-lock.json` with the reviewed npm CLI version pinned by the `Use the reviewed npm CLI` step in `.github/workflows/publish-npm.yml`. Do this after adding, removing, or updating a dependency, even when an older local npm reports that the lockfile is already up to date. npm minor versions can differ in how they record transitive optional peer dependencies; a lockfile accepted by an older client can otherwise fail the hosted `npm ci` before any tests run.
|
|
19
|
+
|
|
20
|
+
With the currently reviewed npm version, use:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx --yes npm@11.18.0 install --package-lock-only --ignore-scripts --no-audit --no-fund
|
|
24
|
+
npx --yes npm@11.18.0 ci
|
|
25
|
+
npm run verify:package
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Inspect the lockfile diff before committing it. A dependency-only maintenance change must not alter the source package version, and lockfile normalisation must not be described as a package upgrade when resolved versions and integrity values are unchanged. When the workflow selects a newer reviewed npm CLI, update this example in the same change.
|
|
29
|
+
|
|
16
30
|
Before publication, run the downstream workflow against an exact Self-hosted LiveSync ref which already consumes the package. The workflow installs the tarball produced from the selected Commonlib commit, then runs LiveSync type checks, unit tests, plug-in and application builds, and CLI E2E. Real Obsidian E2E remains local-only and is required when the changed boundary affects actual plug-in composition, storage, UI, or platform behaviour.
|
|
17
31
|
|
|
18
32
|
## Preparing a release
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vrtmrz/livesync-commonlib",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.6",
|
|
4
4
|
"description": "Shared data, storage, and replication primitives for Self-hosted LiveSync clients.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -101,11 +101,6 @@
|
|
|
101
101
|
"import": "./dist/common/coreEnvVars.js",
|
|
102
102
|
"default": "./dist/common/coreEnvVars.js"
|
|
103
103
|
},
|
|
104
|
-
"./compat/common/i18n": {
|
|
105
|
-
"types": "./dist/common/i18n.d.ts",
|
|
106
|
-
"import": "./dist/common/i18n.js",
|
|
107
|
-
"default": "./dist/common/i18n.js"
|
|
108
|
-
},
|
|
109
104
|
"./compat/common/logger": {
|
|
110
105
|
"types": "./dist/common/logger.d.ts",
|
|
111
106
|
"import": "./dist/common/logger.js",
|
|
@@ -126,16 +121,6 @@
|
|
|
126
121
|
"import": "./dist/common/models/setting.const.js",
|
|
127
122
|
"default": "./dist/common/models/setting.const.js"
|
|
128
123
|
},
|
|
129
|
-
"./compat/common/models/setting.const.defaults": {
|
|
130
|
-
"types": "./dist/common/models/setting.const.defaults.d.ts",
|
|
131
|
-
"import": "./dist/common/models/setting.const.defaults.js",
|
|
132
|
-
"default": "./dist/common/models/setting.const.defaults.js"
|
|
133
|
-
},
|
|
134
|
-
"./compat/common/models/setting.const.preferred": {
|
|
135
|
-
"types": "./dist/common/models/setting.const.preferred.d.ts",
|
|
136
|
-
"import": "./dist/common/models/setting.const.preferred.js",
|
|
137
|
-
"default": "./dist/common/models/setting.const.preferred.js"
|
|
138
|
-
},
|
|
139
124
|
"./compat/common/models/setting.type": {
|
|
140
125
|
"types": "./dist/common/models/setting.type.d.ts",
|
|
141
126
|
"import": "./dist/common/models/setting.type.js",
|
|
@@ -156,11 +141,6 @@
|
|
|
156
141
|
"import": "./dist/common/models/tweak.definition.js",
|
|
157
142
|
"default": "./dist/common/models/tweak.definition.js"
|
|
158
143
|
},
|
|
159
|
-
"./compat/common/rosetta": {
|
|
160
|
-
"types": "./dist/common/rosetta.d.ts",
|
|
161
|
-
"import": "./dist/common/rosetta.js",
|
|
162
|
-
"default": "./dist/common/rosetta.js"
|
|
163
|
-
},
|
|
164
144
|
"./compat/common/settingConstants": {
|
|
165
145
|
"types": "./dist/common/settingConstants.d.ts",
|
|
166
146
|
"import": "./dist/common/settingConstants.js",
|
|
@@ -206,11 +186,6 @@
|
|
|
206
186
|
"import": "./dist/events/coreEvents.js",
|
|
207
187
|
"default": "./dist/events/coreEvents.js"
|
|
208
188
|
},
|
|
209
|
-
"./compat/hub/hub": {
|
|
210
|
-
"types": "./dist/hub/hub.d.ts",
|
|
211
|
-
"import": "./dist/hub/hub.js",
|
|
212
|
-
"default": "./dist/hub/hub.js"
|
|
213
|
-
},
|
|
214
189
|
"./compat/interfaces/Confirm": {
|
|
215
190
|
"types": "./dist/interfaces/Confirm.d.ts",
|
|
216
191
|
"import": "./dist/interfaces/Confirm.js",
|
package/dist/common/i18n.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { AllMessageKeys, I18N_LANGS } from "./rosetta.js";
|
|
2
|
-
import type { TaggedType } from "./types.js";
|
|
3
|
-
export declare let currentLang: I18N_LANGS;
|
|
4
|
-
export declare function getResolvedLang(lang?: I18N_LANGS): I18N_LANGS;
|
|
5
|
-
export declare function isAutoDisplayLanguage(lang: I18N_LANGS): boolean;
|
|
6
|
-
export declare function __getMissingTranslations(): string[];
|
|
7
|
-
export declare function __onMissingTranslation(callback: (key: string) => void): void;
|
|
8
|
-
export declare function setLang(lang: I18N_LANGS): void;
|
|
9
|
-
export declare function $t(message: string, lang?: I18N_LANGS): string;
|
|
10
|
-
export declare function translateIfAvailable(message: string, lang?: I18N_LANGS): string;
|
|
11
|
-
/**
|
|
12
|
-
* TagFunction to Automatically translate.
|
|
13
|
-
* @param strings
|
|
14
|
-
* @param values
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
export declare function $f(strings: TemplateStringsArray, ...values: string[]): string;
|
|
18
|
-
export declare function $msg<T extends AllMessageKeys>(key: T, params?: Record<string, string>, lang?: I18N_LANGS): TaggedType<string, T>;
|
package/dist/common/i18n.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { getLanguage } from "./coreEnvFunctions.js";
|
|
2
|
-
import { allMessages } from "./messages/combinedMessages.prod.js";
|
|
3
|
-
const obsidianLangMap = {
|
|
4
|
-
de: "de",
|
|
5
|
-
es: "es",
|
|
6
|
-
ja: "ja",
|
|
7
|
-
ko: "ko",
|
|
8
|
-
ru: "ru",
|
|
9
|
-
zh: "zh",
|
|
10
|
-
"zh-cn": "zh",
|
|
11
|
-
"zh-hans": "zh",
|
|
12
|
-
"zh-tw": "zh-tw",
|
|
13
|
-
"zh-hk": "zh-tw",
|
|
14
|
-
"zh-mo": "zh-tw",
|
|
15
|
-
"zh-hant": "zh-tw"
|
|
16
|
-
};
|
|
17
|
-
function resolveLanguage(lang) {
|
|
18
|
-
if (lang !== "") return lang;
|
|
19
|
-
const obsidianLanguage = getLanguage().toLowerCase();
|
|
20
|
-
return obsidianLangMap[obsidianLanguage] ?? "def";
|
|
21
|
-
}
|
|
22
|
-
let currentLang = resolveLanguage("");
|
|
23
|
-
const missingTranslations = [];
|
|
24
|
-
let __onMissingTranslations = (key) => console.warn(key);
|
|
25
|
-
const msgCache = /* @__PURE__ */ new Map();
|
|
26
|
-
function getResolvedLang(lang = currentLang) {
|
|
27
|
-
return resolveLanguage(lang);
|
|
28
|
-
}
|
|
29
|
-
function isAutoDisplayLanguage(lang) {
|
|
30
|
-
return lang === "";
|
|
31
|
-
}
|
|
32
|
-
function __getMissingTranslations() {
|
|
33
|
-
return missingTranslations;
|
|
34
|
-
}
|
|
35
|
-
function __onMissingTranslation(callback) {
|
|
36
|
-
__onMissingTranslations = callback;
|
|
37
|
-
}
|
|
38
|
-
function setLang(lang) {
|
|
39
|
-
const resolvedLang = resolveLanguage(lang);
|
|
40
|
-
if (resolvedLang === currentLang) return;
|
|
41
|
-
currentLang = resolvedLang;
|
|
42
|
-
msgCache.clear();
|
|
43
|
-
}
|
|
44
|
-
function _getMessage(key, lang) {
|
|
45
|
-
if (key.trim() == "") return key;
|
|
46
|
-
const msgs = allMessages[key] ?? void 0;
|
|
47
|
-
const resolvedLang = resolveLanguage(lang);
|
|
48
|
-
let msg = msgs?.[resolvedLang];
|
|
49
|
-
if (!msg) {
|
|
50
|
-
if (missingTranslations.indexOf(key) === -1) {
|
|
51
|
-
__onMissingTranslations(key);
|
|
52
|
-
missingTranslations.push(key);
|
|
53
|
-
}
|
|
54
|
-
msg = msgs?.def;
|
|
55
|
-
}
|
|
56
|
-
return msg ?? key;
|
|
57
|
-
}
|
|
58
|
-
function getMessage(key) {
|
|
59
|
-
if (msgCache.has(key)) return msgCache.get(key);
|
|
60
|
-
const msg = _getMessage(key, currentLang);
|
|
61
|
-
msgCache.set(key, msg);
|
|
62
|
-
return msg;
|
|
63
|
-
}
|
|
64
|
-
function $t(message, lang) {
|
|
65
|
-
if (lang !== void 0) {
|
|
66
|
-
return _getMessage(message, lang);
|
|
67
|
-
}
|
|
68
|
-
return getMessage(message);
|
|
69
|
-
}
|
|
70
|
-
function translateIfAvailable(message, lang) {
|
|
71
|
-
if (message.trim() == "" || allMessages[message] === void 0) return message;
|
|
72
|
-
return $t(message, lang);
|
|
73
|
-
}
|
|
74
|
-
function $f(strings, ...values) {
|
|
75
|
-
let result = "";
|
|
76
|
-
for (let i = 0; i < values.length; i++) {
|
|
77
|
-
result += getMessage(strings[i]) + values[i];
|
|
78
|
-
}
|
|
79
|
-
result += getMessage(strings[strings.length - 1]);
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
function $msg(key, params = {}, lang) {
|
|
83
|
-
let msg = $t(key, lang);
|
|
84
|
-
for (const [placeholder, value] of Object.entries(params)) {
|
|
85
|
-
const regex = new RegExp(`\\\${${placeholder}}`, "g");
|
|
86
|
-
msg = msg.replace(regex, value);
|
|
87
|
-
}
|
|
88
|
-
return msg;
|
|
89
|
-
}
|
|
90
|
-
export {
|
|
91
|
-
$f,
|
|
92
|
-
$msg,
|
|
93
|
-
$t,
|
|
94
|
-
__getMissingTranslations,
|
|
95
|
-
__onMissingTranslation,
|
|
96
|
-
currentLang,
|
|
97
|
-
getResolvedLang,
|
|
98
|
-
isAutoDisplayLanguage,
|
|
99
|
-
setLang,
|
|
100
|
-
translateIfAvailable
|
|
101
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { PartialMessages as def } from "./def.js";
|
|
2
|
-
import { PartialMessages as es } from "./es.js";
|
|
3
|
-
import { PartialMessages as fr } from "./fr.js";
|
|
4
|
-
import { PartialMessages as he } from "./he.js";
|
|
5
|
-
import { PartialMessages as ja } from "./ja.js";
|
|
6
|
-
import { PartialMessages as ko } from "./ko.js";
|
|
7
|
-
import { PartialMessages as ru } from "./ru.js";
|
|
8
|
-
import { PartialMessages as zh } from "./zh.js";
|
|
9
|
-
import { PartialMessages as zhTw } from "./zh-tw.js";
|
|
10
|
-
import { expandKeywords } from "../rosetta.js";
|
|
11
|
-
const messages = {
|
|
12
|
-
...def,
|
|
13
|
-
...es,
|
|
14
|
-
...fr,
|
|
15
|
-
...he,
|
|
16
|
-
...ja,
|
|
17
|
-
...ko,
|
|
18
|
-
...ru,
|
|
19
|
-
...zh,
|
|
20
|
-
...zhTw
|
|
21
|
-
};
|
|
22
|
-
const w = Object.entries(messages).map(([lang, messageDefs]) => Object.entries(messageDefs).map(([key, value]) => [key, [lang, value]])).flat();
|
|
23
|
-
const _allMessages = w.reduce(
|
|
24
|
-
(acc, [key, value]) => {
|
|
25
|
-
if (!acc[key]) acc[key] = {};
|
|
26
|
-
acc[key][value[0]] = value[1];
|
|
27
|
-
return acc;
|
|
28
|
-
},
|
|
29
|
-
{}
|
|
30
|
-
);
|
|
31
|
-
const expandedMessage = {
|
|
32
|
-
...expandKeywords(_allMessages, "def"),
|
|
33
|
-
...expandKeywords(_allMessages, "es"),
|
|
34
|
-
...expandKeywords(_allMessages, "fr"),
|
|
35
|
-
...expandKeywords(_allMessages, "ja"),
|
|
36
|
-
...expandKeywords(_allMessages, "ko"),
|
|
37
|
-
...expandKeywords(_allMessages, "ru"),
|
|
38
|
-
...expandKeywords(_allMessages, "zh"),
|
|
39
|
-
...expandKeywords(_allMessages, "zh-tw")
|
|
40
|
-
};
|
|
41
|
-
const allMessages = expandedMessage;
|
|
42
|
-
export {
|
|
43
|
-
allMessages
|
|
44
|
-
};
|