@taon-dev/i18n 0.0.1
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/VERIFIED-BUILD-DATA.jsonc +5 -0
- package/assets/shared/shared_folder_info.txt +7 -0
- package/bin/i18n +5 -0
- package/bin/i18n-debug +5 -0
- package/bin/i18n-debug-brk +4 -0
- package/bin/start.js +38 -0
- package/browser/README.md +24 -0
- package/browser/fesm2022/i18n-browser.mjs +521 -0
- package/browser/fesm2022/i18n-browser.mjs.map +1 -0
- package/browser/package.json +23 -0
- package/browser/types/i18n-browser.d.ts +353 -0
- package/browser-prod/README.md +24 -0
- package/browser-prod/fesm2022/i18n-browser-prod.mjs +521 -0
- package/browser-prod/fesm2022/i18n-browser-prod.mjs.map +1 -0
- package/browser-prod/package.json +23 -0
- package/browser-prod/types/i18n-browser-prod.d.ts +353 -0
- package/browser-prod.re-export.json +1 -0
- package/browser-prod.split-namespaces.json +4 -0
- package/cli.d.ts +1 -0
- package/cli.js +8 -0
- package/cli.js.map +1 -0
- package/html/assets/generated/pwa/html-pwa.html +60 -0
- package/html/imports.html +3 -0
- package/index.d.ts +3 -0
- package/index.js +20 -0
- package/index.js.map +1 -0
- package/lib/build-info._auto-generated_.d.ts +24 -0
- package/lib/build-info._auto-generated_.js +30 -0
- package/lib/build-info._auto-generated_.js.map +1 -0
- package/lib/env/env.angular-node-app.d.ts +67 -0
- package/lib/env/env.angular-node-app.js +141 -0
- package/lib/env/env.angular-node-app.js.map +1 -0
- package/lib/env/env.docs-webapp.d.ts +67 -0
- package/lib/env/env.docs-webapp.js +141 -0
- package/lib/env/env.docs-webapp.js.map +1 -0
- package/lib/env/env.electron-app.d.ts +67 -0
- package/lib/env/env.electron-app.js +141 -0
- package/lib/env/env.electron-app.js.map +1 -0
- package/lib/env/env.mobile-app.d.ts +67 -0
- package/lib/env/env.mobile-app.js +141 -0
- package/lib/env/env.mobile-app.js.map +1 -0
- package/lib/env/env.npm-lib-and-cli-tool.d.ts +67 -0
- package/lib/env/env.npm-lib-and-cli-tool.js +141 -0
- package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -0
- package/lib/env/env.vscode-plugin.d.ts +67 -0
- package/lib/env/env.vscode-plugin.js +141 -0
- package/lib/env/env.vscode-plugin.js.map +1 -0
- package/lib/env/index.d.ts +6 -0
- package/lib/env/index.js +23 -0
- package/lib/env/index.js.map +1 -0
- package/lib/features/index.d.ts +4 -0
- package/lib/features/index.js +21 -0
- package/lib/features/index.js.map +1 -0
- package/lib/features/types.d.ts +4 -0
- package/lib/features/types.js +3 -0
- package/lib/features/types.js.map +1 -0
- package/lib/features/withLanguageLocalStorageSync.d.ts +9 -0
- package/lib/features/withLanguageLocalStorageSync.js +39 -0
- package/lib/features/withLanguageLocalStorageSync.js.map +1 -0
- package/lib/features/withNavigatorLanguage.d.ts +6 -0
- package/lib/features/withNavigatorLanguage.js +29 -0
- package/lib/features/withNavigatorLanguage.js.map +1 -0
- package/lib/features/withPreloadScopes.d.ts +8 -0
- package/lib/features/withPreloadScopes.js +25 -0
- package/lib/features/withPreloadScopes.js.map +1 -0
- package/lib/features/withServerSideLanguage.d.ts +6 -0
- package/lib/features/withServerSideLanguage.js +29 -0
- package/lib/features/withServerSideLanguage.js.map +1 -0
- package/lib/features/withTranslatedTitle.d.ts +34 -0
- package/lib/features/withTranslatedTitle.js +69 -0
- package/lib/features/withTranslatedTitle.js.map +1 -0
- package/lib/index._auto-generated_.d.ts +16 -0
- package/lib/index._auto-generated_.js +38 -0
- package/lib/index._auto-generated_.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +20 -0
- package/lib/index.js.map +1 -0
- package/lib/internals.d.ts +2 -0
- package/lib/internals.js +6 -0
- package/lib/internals.js.map +1 -0
- package/lib/package.json +4 -0
- package/lib/start-cli.d.ts +7 -0
- package/lib/start-cli.js +46 -0
- package/lib/start-cli.js.map +1 -0
- package/lib/transignal-config.d.ts +34 -0
- package/lib/transignal-config.js +42 -0
- package/lib/transignal-config.js.map +1 -0
- package/lib/transignal-param-handlers.d.ts +11 -0
- package/lib/transignal-param-handlers.js +31 -0
- package/lib/transignal-param-handlers.js.map +1 -0
- package/lib/transignal-service.d.ts +32 -0
- package/lib/transignal-service.js +206 -0
- package/lib/transignal-service.js.map +1 -0
- package/lib/transignal-testing.d.ts +8 -0
- package/lib/transignal-testing.js +14 -0
- package/lib/transignal-testing.js.map +1 -0
- package/lib/types.d.ts +124 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utility-types.d.ts +29 -0
- package/lib/utility-types.js +3 -0
- package/lib/utility-types.js.map +1 -0
- package/lib/utils.d.ts +15 -0
- package/lib/utils.js +20 -0
- package/lib/utils.js.map +1 -0
- package/lib-esm/app.d.ts +3 -0
- package/lib-esm/app.electron.d.ts +1 -0
- package/lib-esm/app.electron.js +2 -0
- package/lib-esm/app.electron.js.map +1 -0
- package/lib-esm/app.hosts.d.ts +95 -0
- package/lib-esm/app.hosts.js +157 -0
- package/lib-esm/app.hosts.js.map +1 -0
- package/lib-esm/app.js +460 -0
- package/lib-esm/app.js.map +1 -0
- package/lib-esm/app.vscode.d.ts +9 -0
- package/lib-esm/app.vscode.js +37 -0
- package/lib-esm/app.vscode.js.map +1 -0
- package/lib-esm/cli.d.ts +1 -0
- package/lib-esm/cli.js +4 -0
- package/lib-esm/cli.js.map +1 -0
- package/lib-esm/index.d.ts +3 -0
- package/lib-esm/index.js +4 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/lib/build-info._auto-generated_.d.ts +24 -0
- package/lib-esm/lib/build-info._auto-generated_.js +27 -0
- package/lib-esm/lib/build-info._auto-generated_.js.map +1 -0
- package/lib-esm/lib/env/env.angular-node-app.d.ts +67 -0
- package/lib-esm/lib/env/env.angular-node-app.js +137 -0
- package/lib-esm/lib/env/env.angular-node-app.js.map +1 -0
- package/lib-esm/lib/env/env.docs-webapp.d.ts +67 -0
- package/lib-esm/lib/env/env.docs-webapp.js +137 -0
- package/lib-esm/lib/env/env.docs-webapp.js.map +1 -0
- package/lib-esm/lib/env/env.electron-app.d.ts +67 -0
- package/lib-esm/lib/env/env.electron-app.js +137 -0
- package/lib-esm/lib/env/env.electron-app.js.map +1 -0
- package/lib-esm/lib/env/env.mobile-app.d.ts +67 -0
- package/lib-esm/lib/env/env.mobile-app.js +137 -0
- package/lib-esm/lib/env/env.mobile-app.js.map +1 -0
- package/lib-esm/lib/env/env.npm-lib-and-cli-tool.d.ts +67 -0
- package/lib-esm/lib/env/env.npm-lib-and-cli-tool.js +137 -0
- package/lib-esm/lib/env/env.npm-lib-and-cli-tool.js.map +1 -0
- package/lib-esm/lib/env/env.vscode-plugin.d.ts +67 -0
- package/lib-esm/lib/env/env.vscode-plugin.js +137 -0
- package/lib-esm/lib/env/env.vscode-plugin.js.map +1 -0
- package/lib-esm/lib/env/index.d.ts +6 -0
- package/lib-esm/lib/env/index.js +7 -0
- package/lib-esm/lib/env/index.js.map +1 -0
- package/lib-esm/lib/features/index.d.ts +4 -0
- package/lib-esm/lib/features/index.js +5 -0
- package/lib-esm/lib/features/index.js.map +1 -0
- package/lib-esm/lib/features/types.d.ts +4 -0
- package/lib-esm/lib/features/types.js +2 -0
- package/lib-esm/lib/features/types.js.map +1 -0
- package/lib-esm/lib/features/withLanguageLocalStorageSync.d.ts +9 -0
- package/lib-esm/lib/features/withLanguageLocalStorageSync.js +35 -0
- package/lib-esm/lib/features/withLanguageLocalStorageSync.js.map +1 -0
- package/lib-esm/lib/features/withNavigatorLanguage.d.ts +6 -0
- package/lib-esm/lib/features/withNavigatorLanguage.js +25 -0
- package/lib-esm/lib/features/withNavigatorLanguage.js.map +1 -0
- package/lib-esm/lib/features/withPreloadScopes.d.ts +8 -0
- package/lib-esm/lib/features/withPreloadScopes.js +21 -0
- package/lib-esm/lib/features/withPreloadScopes.js.map +1 -0
- package/lib-esm/lib/features/withServerSideLanguage.d.ts +6 -0
- package/lib-esm/lib/features/withServerSideLanguage.js +25 -0
- package/lib-esm/lib/features/withServerSideLanguage.js.map +1 -0
- package/lib-esm/lib/features/withTranslatedTitle.d.ts +34 -0
- package/lib-esm/lib/features/withTranslatedTitle.js +65 -0
- package/lib-esm/lib/features/withTranslatedTitle.js.map +1 -0
- package/lib-esm/lib/index._auto-generated_.d.ts +16 -0
- package/lib-esm/lib/index._auto-generated_.js +22 -0
- package/lib-esm/lib/index._auto-generated_.js.map +1 -0
- package/lib-esm/lib/index.d.ts +4 -0
- package/lib-esm/lib/index.js +4 -0
- package/lib-esm/lib/index.js.map +1 -0
- package/lib-esm/lib/internals.d.ts +2 -0
- package/lib-esm/lib/internals.js +3 -0
- package/lib-esm/lib/internals.js.map +1 -0
- package/lib-esm/lib/start-cli.d.ts +7 -0
- package/lib-esm/lib/start-cli.js +43 -0
- package/lib-esm/lib/start-cli.js.map +1 -0
- package/lib-esm/lib/transignal-config.d.ts +34 -0
- package/lib-esm/lib/transignal-config.js +36 -0
- package/lib-esm/lib/transignal-config.js.map +1 -0
- package/lib-esm/lib/transignal-param-handlers.d.ts +11 -0
- package/lib-esm/lib/transignal-param-handlers.js +25 -0
- package/lib-esm/lib/transignal-param-handlers.js.map +1 -0
- package/lib-esm/lib/transignal-service.d.ts +32 -0
- package/lib-esm/lib/transignal-service.js +197 -0
- package/lib-esm/lib/transignal-service.js.map +1 -0
- package/lib-esm/lib/transignal-testing.d.ts +8 -0
- package/lib-esm/lib/transignal-testing.js +10 -0
- package/lib-esm/lib/transignal-testing.js.map +1 -0
- package/lib-esm/lib/types.d.ts +124 -0
- package/lib-esm/lib/types.js +2 -0
- package/lib-esm/lib/types.js.map +1 -0
- package/lib-esm/lib/utility-types.d.ts +29 -0
- package/lib-esm/lib/utility-types.js +2 -0
- package/lib-esm/lib/utility-types.js.map +1 -0
- package/lib-esm/lib/utils.d.ts +15 -0
- package/lib-esm/lib/utils.js +15 -0
- package/lib-esm/lib/utils.js.map +1 -0
- package/lib-prod/build-info._auto-generated_.d.ts +24 -0
- package/lib-prod/build-info._auto-generated_.js +27 -0
- package/lib-prod/build-info._auto-generated_.js.map +1 -0
- package/lib-prod/env/env.angular-node-app.d.ts +67 -0
- package/lib-prod/env/env.angular-node-app.js +137 -0
- package/lib-prod/env/env.angular-node-app.js.map +1 -0
- package/lib-prod/env/env.docs-webapp.d.ts +67 -0
- package/lib-prod/env/env.docs-webapp.js +137 -0
- package/lib-prod/env/env.docs-webapp.js.map +1 -0
- package/lib-prod/env/env.electron-app.d.ts +67 -0
- package/lib-prod/env/env.electron-app.js +137 -0
- package/lib-prod/env/env.electron-app.js.map +1 -0
- package/lib-prod/env/env.mobile-app.d.ts +67 -0
- package/lib-prod/env/env.mobile-app.js +137 -0
- package/lib-prod/env/env.mobile-app.js.map +1 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +67 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +137 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +1 -0
- package/lib-prod/env/env.vscode-plugin.d.ts +67 -0
- package/lib-prod/env/env.vscode-plugin.js +137 -0
- package/lib-prod/env/env.vscode-plugin.js.map +1 -0
- package/lib-prod/env/index.d.ts +6 -0
- package/lib-prod/env/index.js +7 -0
- package/lib-prod/env/index.js.map +1 -0
- package/lib-prod/features/index.d.ts +4 -0
- package/lib-prod/features/index.js +5 -0
- package/lib-prod/features/index.js.map +1 -0
- package/lib-prod/features/types.d.ts +4 -0
- package/lib-prod/features/types.js +2 -0
- package/lib-prod/features/types.js.map +1 -0
- package/lib-prod/features/withLanguageLocalStorageSync.d.ts +9 -0
- package/lib-prod/features/withLanguageLocalStorageSync.js +35 -0
- package/lib-prod/features/withLanguageLocalStorageSync.js.map +1 -0
- package/lib-prod/features/withNavigatorLanguage.d.ts +6 -0
- package/lib-prod/features/withNavigatorLanguage.js +25 -0
- package/lib-prod/features/withNavigatorLanguage.js.map +1 -0
- package/lib-prod/features/withPreloadScopes.d.ts +8 -0
- package/lib-prod/features/withPreloadScopes.js +21 -0
- package/lib-prod/features/withPreloadScopes.js.map +1 -0
- package/lib-prod/features/withServerSideLanguage.d.ts +6 -0
- package/lib-prod/features/withServerSideLanguage.js +25 -0
- package/lib-prod/features/withServerSideLanguage.js.map +1 -0
- package/lib-prod/features/withTranslatedTitle.d.ts +34 -0
- package/lib-prod/features/withTranslatedTitle.js +65 -0
- package/lib-prod/features/withTranslatedTitle.js.map +1 -0
- package/lib-prod/index._auto-generated_.d.ts +16 -0
- package/lib-prod/index._auto-generated_.js +22 -0
- package/lib-prod/index._auto-generated_.js.map +1 -0
- package/lib-prod/index.d.ts +4 -0
- package/lib-prod/index.js +4 -0
- package/lib-prod/index.js.map +1 -0
- package/lib-prod/internals.d.ts +2 -0
- package/lib-prod/internals.js +3 -0
- package/lib-prod/internals.js.map +1 -0
- package/lib-prod/package.json +4 -0
- package/lib-prod/start-cli.d.ts +7 -0
- package/lib-prod/start-cli.js +43 -0
- package/lib-prod/start-cli.js.map +1 -0
- package/lib-prod/transignal-config.d.ts +34 -0
- package/lib-prod/transignal-config.js +36 -0
- package/lib-prod/transignal-config.js.map +1 -0
- package/lib-prod/transignal-param-handlers.d.ts +11 -0
- package/lib-prod/transignal-param-handlers.js +25 -0
- package/lib-prod/transignal-param-handlers.js.map +1 -0
- package/lib-prod/transignal-service.d.ts +32 -0
- package/lib-prod/transignal-service.js +197 -0
- package/lib-prod/transignal-service.js.map +1 -0
- package/lib-prod/transignal-testing.d.ts +8 -0
- package/lib-prod/transignal-testing.js +10 -0
- package/lib-prod/transignal-testing.js.map +1 -0
- package/lib-prod/types.d.ts +124 -0
- package/lib-prod/types.js +2 -0
- package/lib-prod/types.js.map +1 -0
- package/lib-prod/utility-types.d.ts +29 -0
- package/lib-prod/utility-types.js +2 -0
- package/lib-prod/utility-types.js.map +1 -0
- package/lib-prod/utils.d.ts +15 -0
- package/lib-prod/utils.js +15 -0
- package/lib-prod/utils.js.map +1 -0
- package/lib-prod.re-export.json +1 -0
- package/lib-prod.split-namespaces.json +4 -0
- package/package.json +39 -0
- package/scss/global.scss +94 -0
- package/scss/index.scss +2 -0
- package/scss/lib/index.scss +2 -0
- package/scss/vars.scss +7 -0
- package/src.d.ts +6 -0
- package/src.js +4 -0
- package/websql/README.md +24 -0
- package/websql/fesm2022/i18n-websql.mjs +521 -0
- package/websql/fesm2022/i18n-websql.mjs.map +1 -0
- package/websql/package.json +23 -0
- package/websql/types/i18n-websql.d.ts +353 -0
- package/websql-prod/README.md +24 -0
- package/websql-prod/fesm2022/i18n-websql-prod.mjs +521 -0
- package/websql-prod/fesm2022/i18n-websql-prod.mjs.map +1 -0
- package/websql-prod/package.json +23 -0
- package/websql-prod/types/i18n-websql-prod.d.ts +353 -0
- package/websql-prod.re-export.json +1 -0
- package/websql-prod.split-namespaces.json +4 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
2
|
+
import { effect, inject, PLATFORM_ID, provideAppInitializer } from '@angular/core';
|
|
3
|
+
import { injectTransignalConfig } from '../transignal-config';
|
|
4
|
+
import { TransignalService } from '../transignal-service';
|
|
5
|
+
/**
|
|
6
|
+
* Saves user selected language in selected storage e.g. localStorage
|
|
7
|
+
* Works only in browser environment
|
|
8
|
+
*
|
|
9
|
+
* @param key Key under which it should save the language in storage
|
|
10
|
+
* @param storage Storage to be used e.g. localStorage or sessionStorage
|
|
11
|
+
*/
|
|
12
|
+
export const withLanguageLocalStorageSync = (key = 'LANG', storage = 'localStorage') => {
|
|
13
|
+
return {
|
|
14
|
+
providers: [
|
|
15
|
+
provideAppInitializer(() => {
|
|
16
|
+
if (isPlatformBrowser(inject(PLATFORM_ID))) {
|
|
17
|
+
const transignalService = inject(TransignalService);
|
|
18
|
+
const store = window[storage];
|
|
19
|
+
const savedLanguage = store.getItem(key);
|
|
20
|
+
if (savedLanguage) {
|
|
21
|
+
const { availableLangs } = injectTransignalConfig();
|
|
22
|
+
if (availableLangs.includes(savedLanguage)) {
|
|
23
|
+
transignalService.activeLang.set(savedLanguage);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
effect(() => {
|
|
27
|
+
const updatedLang = transignalService.activeLang();
|
|
28
|
+
store.setItem(key, updatedLang);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=withLanguageLocalStorageSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withLanguageLocalStorageSync.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAI1C,MAAc,MAAM,EACpB,UAA6C,cAAc,EACf,EAAE;IAC9C,OAAO;QACL,SAAS,EAAE;YACT,qBAAqB,CAAC,GAAG,EAAE;gBACzB,IAAI,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;oBAC3C,MAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;oBACpD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;oBAE9B,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;oBACzC,IAAI,aAAa,EAAE,CAAC;wBAClB,MAAM,EAAE,cAAc,EAAE,GAAG,sBAAsB,EAAE,CAAC;wBACpD,IAAI,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;4BAC3C,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;wBAClD,CAAC;oBACH,CAAC;oBACD,MAAM,CAAC,GAAG,EAAE;wBACV,MAAM,WAAW,GAAG,iBAAiB,CAAC,UAAU,EAAE,CAAC;wBACnD,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;oBAClC,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TransignalFeature } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Sets active language depending on `navigator.language`, which represents user defined browser settings
|
|
4
|
+
* Works only in browser environment
|
|
5
|
+
*/
|
|
6
|
+
export declare const withNavigatorLanguage: <Languages extends string, Translations extends Record<string, Record<string, unknown>>>() => TransignalFeature<Languages, Translations>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
2
|
+
import { inject, PLATFORM_ID, provideAppInitializer } from '@angular/core';
|
|
3
|
+
import { injectTransignalConfig } from '../transignal-config';
|
|
4
|
+
import { TransignalService } from '../transignal-service';
|
|
5
|
+
/**
|
|
6
|
+
* Sets active language depending on `navigator.language`, which represents user defined browser settings
|
|
7
|
+
* Works only in browser environment
|
|
8
|
+
*/
|
|
9
|
+
export const withNavigatorLanguage = () => {
|
|
10
|
+
return {
|
|
11
|
+
providers: [
|
|
12
|
+
provideAppInitializer(() => {
|
|
13
|
+
if (isPlatformBrowser(inject(PLATFORM_ID))) {
|
|
14
|
+
const transignalService = inject(TransignalService);
|
|
15
|
+
const { availableLangs } = injectTransignalConfig();
|
|
16
|
+
const preferredLanguage = navigator.languages.map(language => language.split('-')[0].toLowerCase()).find(language => availableLangs.includes(language));
|
|
17
|
+
if (preferredLanguage) {
|
|
18
|
+
transignalService.activeLang.set(preferredLanguage);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=withNavigatorLanguage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withNavigatorLanguage.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAGW,EAAE;IAChD,OAAO;QACL,SAAS,EAAE;YACT,qBAAqB,CAAC,GAAG,EAAE;gBACzB,IAAI,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;oBAC3C,MAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;oBACpD,MAAM,EAAE,cAAc,EAAE,GAAG,sBAAsB,EAAE,CAAC;oBACpD,MAAM,iBAAiB,GACrB,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CACzE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACtD,IAAI,iBAAiB,EAAE,CAAC;wBACtB,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;oBACtD,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TransignalFeature } from './types';
|
|
2
|
+
import { StringKeys } from '../utility-types';
|
|
3
|
+
/**
|
|
4
|
+
* Preloads selected scopes in default language
|
|
5
|
+
* Use after language init by {@link withServerSideLanguage} or {@link withNavigatorLanguage}
|
|
6
|
+
* @param scopes Scopes which should be preloaded
|
|
7
|
+
*/
|
|
8
|
+
export declare const withPreloadScopes: <Languages extends string, Translations extends Record<string, Record<string, unknown>>>(scopes: StringKeys<Translations>[]) => TransignalFeature<Languages, Translations>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { effect, inject, provideAppInitializer } from '@angular/core';
|
|
2
|
+
import { TransignalService } from '../transignal-service';
|
|
3
|
+
/**
|
|
4
|
+
* Preloads selected scopes in default language
|
|
5
|
+
* Use after language init by {@link withServerSideLanguage} or {@link withNavigatorLanguage}
|
|
6
|
+
* @param scopes Scopes which should be preloaded
|
|
7
|
+
*/
|
|
8
|
+
export const withPreloadScopes = (scopes) => {
|
|
9
|
+
return {
|
|
10
|
+
providers: [
|
|
11
|
+
provideAppInitializer(() => {
|
|
12
|
+
const transignalService = inject(TransignalService);
|
|
13
|
+
effect(() => {
|
|
14
|
+
const _activeLang = transignalService.activeLang();
|
|
15
|
+
scopes.forEach(scope => transignalService.t(scope)(''));
|
|
16
|
+
});
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=withPreloadScopes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withPreloadScopes.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAI/B,MAAkC,EACU,EAAE;IAC9C,OAAO;QACL,SAAS,EAAE;YACT,qBAAqB,CAAC,GAAG,EAAE;gBACzB,MAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;gBACpD,MAAM,CAAC,GAAG,EAAE;oBACV,MAAM,WAAW,GAAG,iBAAiB,CAAC,UAAU,EAAE,CAAC;oBACnD,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC1D,CAAC,CAAC,CAAC;YACL,CAAC,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TransignalFeature } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Sets active language depending on `document.lang` attribute which should be set by the server.ts depending on `Accept-language` header
|
|
4
|
+
* Works only in SSR environment
|
|
5
|
+
*/
|
|
6
|
+
export declare const withServerSideLanguage: <Languages extends string, Translations extends Record<string, Record<string, unknown>>>() => TransignalFeature<Languages, Translations>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isPlatformServer } from '@angular/common';
|
|
2
|
+
import { DOCUMENT, inject, PLATFORM_ID, provideAppInitializer } from '@angular/core';
|
|
3
|
+
import { injectTransignalConfig } from '../transignal-config';
|
|
4
|
+
import { TransignalService } from '../transignal-service';
|
|
5
|
+
/**
|
|
6
|
+
* Sets active language depending on `document.lang` attribute which should be set by the server.ts depending on `Accept-language` header
|
|
7
|
+
* Works only in SSR environment
|
|
8
|
+
*/
|
|
9
|
+
export const withServerSideLanguage = () => {
|
|
10
|
+
return {
|
|
11
|
+
providers: [
|
|
12
|
+
provideAppInitializer(() => {
|
|
13
|
+
if (isPlatformServer(inject(PLATFORM_ID))) {
|
|
14
|
+
const transignalService = inject(TransignalService);
|
|
15
|
+
const { documentElement } = inject(DOCUMENT);
|
|
16
|
+
const { availableLangs } = injectTransignalConfig();
|
|
17
|
+
if (availableLangs.includes(documentElement.lang)) {
|
|
18
|
+
transignalService.activeLang.set(documentElement.lang);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=withServerSideLanguage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withServerSideLanguage.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAGU,EAAE;IAChD,OAAO;QACL,SAAS,EAAE;YACT,qBAAqB,CAAC,GAAG,EAAE;gBACzB,IAAI,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;oBAC1C,MAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;oBACpD,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;oBAC7C,MAAM,EAAE,cAAc,EAAE,GAAG,sBAAsB,EAAE,CAAC;oBACpD,IAAI,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;wBAClD,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;oBACzD,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TransignalFeature } from './types';
|
|
2
|
+
import { StringKeys } from '../utility-types';
|
|
3
|
+
/**
|
|
4
|
+
* Enables translation of title param in route definition with use of prepared {@link TitleStrategy}
|
|
5
|
+
* Automatically translates `title` param form route definition, sets website title and updates on language changes
|
|
6
|
+
* Also it is possible to use parameters from `navigation.extras.state`
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // src/app/app.routes.ts
|
|
11
|
+
* export const routes = [
|
|
12
|
+
* { path: 'base', title: 'base', children: [
|
|
13
|
+
* { path: 'child', title: 'child' },
|
|
14
|
+
* ],
|
|
15
|
+
* { path: 'aux', outlet: 'popup', title: 'popupTitle' }
|
|
16
|
+
* ];
|
|
17
|
+
*
|
|
18
|
+
* // src/app/transignal.ts
|
|
19
|
+
* export const transignal = prepareTransignal(<config>, withTranslatedTitle('global'));
|
|
20
|
+
*
|
|
21
|
+
* // src/app/i18n/global/en.ts
|
|
22
|
+
* export default {
|
|
23
|
+
* title: {
|
|
24
|
+
* base: 'Base title',
|
|
25
|
+
* child: 'Child title'
|
|
26
|
+
* popupTitle: 'Popup title'
|
|
27
|
+
* }
|
|
28
|
+
* };
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param scope scope under which there are title translations
|
|
32
|
+
* @param translationKey translation key under which there are translations, `title` by default
|
|
33
|
+
*/
|
|
34
|
+
export declare const withTranslatedTitle: <Languages extends string, Translations extends Record<string, Record<string, unknown>>>(scope: StringKeys<Translations>, translationKey?: string) => TransignalFeature<Languages, Translations>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { computed, effect, EnvironmentInjector, inject, makeEnvironmentProviders, runInInjectionContext, } from '@angular/core';
|
|
2
|
+
import { Title } from '@angular/platform-browser';
|
|
3
|
+
import { Router, TitleStrategy } from '@angular/router';
|
|
4
|
+
import { TransignalService } from '../transignal-service';
|
|
5
|
+
class TransignalTitleStrategy extends TitleStrategy {
|
|
6
|
+
t;
|
|
7
|
+
title = inject(Title);
|
|
8
|
+
injector = inject(EnvironmentInjector);
|
|
9
|
+
effectRef;
|
|
10
|
+
constructor(t) {
|
|
11
|
+
super();
|
|
12
|
+
this.t = t;
|
|
13
|
+
}
|
|
14
|
+
updateTitle(routerState) {
|
|
15
|
+
this.effectRef?.destroy();
|
|
16
|
+
const router = this.injector.get(Router);
|
|
17
|
+
const title = this.buildTitle(routerState) || 'default';
|
|
18
|
+
const translation = computed(() => this.t(title, router.getCurrentNavigation()?.extras.state));
|
|
19
|
+
this.effectRef = runInInjectionContext(this.injector, () => effect(() => this.title.setTitle(translation()), { manualCleanup: true }));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Enables translation of title param in route definition with use of prepared {@link TitleStrategy}
|
|
24
|
+
* Automatically translates `title` param form route definition, sets website title and updates on language changes
|
|
25
|
+
* Also it is possible to use parameters from `navigation.extras.state`
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // src/app/app.routes.ts
|
|
30
|
+
* export const routes = [
|
|
31
|
+
* { path: 'base', title: 'base', children: [
|
|
32
|
+
* { path: 'child', title: 'child' },
|
|
33
|
+
* ],
|
|
34
|
+
* { path: 'aux', outlet: 'popup', title: 'popupTitle' }
|
|
35
|
+
* ];
|
|
36
|
+
*
|
|
37
|
+
* // src/app/transignal.ts
|
|
38
|
+
* export const transignal = prepareTransignal(<config>, withTranslatedTitle('global'));
|
|
39
|
+
*
|
|
40
|
+
* // src/app/i18n/global/en.ts
|
|
41
|
+
* export default {
|
|
42
|
+
* title: {
|
|
43
|
+
* base: 'Base title',
|
|
44
|
+
* child: 'Child title'
|
|
45
|
+
* popupTitle: 'Popup title'
|
|
46
|
+
* }
|
|
47
|
+
* };
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param scope scope under which there are title translations
|
|
51
|
+
* @param translationKey translation key under which there are translations, `title` by default
|
|
52
|
+
*/
|
|
53
|
+
export const withTranslatedTitle = (scope, translationKey = 'title') => {
|
|
54
|
+
return {
|
|
55
|
+
providers: [
|
|
56
|
+
makeEnvironmentProviders([
|
|
57
|
+
{
|
|
58
|
+
provide: TitleStrategy,
|
|
59
|
+
useFactory: (service = inject(TransignalService)) => new TransignalTitleStrategy(service.t(scope).prefix(translationKey)),
|
|
60
|
+
},
|
|
61
|
+
]),
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=withTranslatedTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTranslatedTitle.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,MAAM,EAEN,mBAAmB,EACnB,MAAM,EACN,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAuB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI1D,MAAM,uBAAwB,SAAQ,aAAa;IAMpB;IALZ,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,QAAQ,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAEhD,SAAS,CAAwB;IAEzC,YAA6B,CAAuC;QAClE,KAAK,EAAE,CAAC;QADmB,MAAC,GAAD,CAAC,CAAsC;IAEpE,CAAC;IAED,WAAW,CAAC,WAAgC;QAC1C,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,SAAS,CAAC;QACxD,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,oBAAoB,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAE/F,IAAI,CAAC,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CACzD,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAC1E,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAIjC,KAA+B,EAC/B,cAAc,GAAG,OAAO,EACoB,EAAE;IAC9C,OAAO;QACL,SAAS,EAAE;YACT,wBAAwB,CAAC;gBACvB;oBACE,OAAO,EAAE,aAAa;oBACtB,UAAU,EAAE,CAAC,OAAO,GAAG,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAClD,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;iBACvE;aACF,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './build-info._auto-generated_';
|
|
2
|
+
export * from './internals';
|
|
3
|
+
export * from './start-cli';
|
|
4
|
+
export * from './transignal-config';
|
|
5
|
+
export * from './transignal-param-handlers';
|
|
6
|
+
export * from './transignal-service';
|
|
7
|
+
export * from './transignal-testing';
|
|
8
|
+
export * from './types';
|
|
9
|
+
export * from './utility-types';
|
|
10
|
+
export * from './utils';
|
|
11
|
+
export * from './features/types';
|
|
12
|
+
export * from './features/withLanguageLocalStorageSync';
|
|
13
|
+
export * from './features/withNavigatorLanguage';
|
|
14
|
+
export * from './features/withPreloadScopes';
|
|
15
|
+
export * from './features/withServerSideLanguage';
|
|
16
|
+
export * from './features/withTranslatedTitle';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// This file is auto-generated during init process. Do not modify.
|
|
3
|
+
// This disable this auto generate file.
|
|
4
|
+
// set property "shouldGenerateAutogenIndexFile: false"
|
|
5
|
+
// in taon.jsonc of your project.
|
|
6
|
+
export * from './build-info._auto-generated_';
|
|
7
|
+
export * from './internals';
|
|
8
|
+
export * from './start-cli';
|
|
9
|
+
export * from './transignal-config';
|
|
10
|
+
export * from './transignal-param-handlers';
|
|
11
|
+
export * from './transignal-service';
|
|
12
|
+
export * from './transignal-testing';
|
|
13
|
+
export * from './types';
|
|
14
|
+
export * from './utility-types';
|
|
15
|
+
export * from './utils';
|
|
16
|
+
export * from './features/types';
|
|
17
|
+
export * from './features/withLanguageLocalStorageSync';
|
|
18
|
+
export * from './features/withNavigatorLanguage';
|
|
19
|
+
export * from './features/withPreloadScopes';
|
|
20
|
+
export * from './features/withServerSideLanguage';
|
|
21
|
+
export * from './features/withTranslatedTitle';
|
|
22
|
+
//# sourceMappingURL=index._auto-generated_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index._auto-generated_.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,cAAc;AACd,kEAAkE;AAClE,wCAAwC;AACxC,wDAAwD;AACxD,kCAAkC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,yCAAyC,CAAC;AACxD,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internals.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC;AAC/E,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region tnp-helpers cli template
|
|
2
|
+
// import { Helpers, BaseCommandLineFeature } from 'tnp-helpers/src';
|
|
3
|
+
// import { BaseProject, BaseStartConfig } from 'tnp-helpers/src'; // @backend
|
|
4
|
+
// class $Version extends BaseCommandLineFeature<{}> {
|
|
5
|
+
// public _() {
|
|
6
|
+
// console.log(`Hello world from cli`);
|
|
7
|
+
// this._exit();
|
|
8
|
+
// }
|
|
9
|
+
// }
|
|
10
|
+
//#endregion
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param argsv process.argsv
|
|
14
|
+
* @param filename needed if you want ipc communicaiton
|
|
15
|
+
*/
|
|
16
|
+
export async function startCli(argsv, filename) {
|
|
17
|
+
//#region @backendFunc
|
|
18
|
+
console.log('Hello from cli');
|
|
19
|
+
console.log({ argsv });
|
|
20
|
+
process.exit(0);
|
|
21
|
+
//#region start config
|
|
22
|
+
// new BaseStartConfig({
|
|
23
|
+
// ProjectClass: BaseProject,
|
|
24
|
+
// functionsOrClasses: [
|
|
25
|
+
// {
|
|
26
|
+
// classOrFnName: '$Version',
|
|
27
|
+
// funcOrClass: $Version,
|
|
28
|
+
// },
|
|
29
|
+
// ],
|
|
30
|
+
// argsv,
|
|
31
|
+
// useStringArrForArgsFunctions: true,
|
|
32
|
+
// shortArgsReplaceConfig: {
|
|
33
|
+
// v: 'version',
|
|
34
|
+
// },
|
|
35
|
+
// callbackNotRecognizedCommand: async () => {
|
|
36
|
+
// Helpers.error(`Command not recognized`, false, true);
|
|
37
|
+
// },
|
|
38
|
+
// });
|
|
39
|
+
//#endregion
|
|
40
|
+
//#endregion
|
|
41
|
+
}
|
|
42
|
+
export default startCli;
|
|
43
|
+
//# sourceMappingURL=start-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-cli.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,kCAAkC;AAClC,qEAAqE;AACrE,8EAA8E;AAE9E,sDAAsD;AACtD,iBAAiB;AACjB,2CAA2C;AAC3C,oBAAoB;AACpB,MAAM;AACN,IAAI;AACJ,YAAY;AAEZ;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,KAAe,EAAE,QAAgB;IAC9D,sBAAsB;IACtB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC9B,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEhB,sBAAsB;IACtB,wBAAwB;IACxB,+BAA+B;IAC/B,0BAA0B;IAC1B,QAAQ;IACR,mCAAmC;IACnC,+BAA+B;IAC/B,SAAS;IACT,OAAO;IACP,WAAW;IACX,wCAAwC;IACxC,8BAA8B;IAC9B,oBAAoB;IACpB,OAAO;IACP,gDAAgD;IAChD,4DAA4D;IAC5D,OAAO;IACP,MAAM;IACN,YAAY;IACZ,YAAY;AACd,CAAC;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { TransignalFeature } from './features/types';
|
|
3
|
+
import { INTERNAL_TRANSIGNAL_CONFIG } from './internals';
|
|
4
|
+
import { TransignalService } from './transignal-service';
|
|
5
|
+
import { TransignalConfig } from './types';
|
|
6
|
+
import { StringKeys } from './utility-types';
|
|
7
|
+
/**
|
|
8
|
+
* Utility function to define a type of translations for type inference
|
|
9
|
+
*/
|
|
10
|
+
export declare const treeShakedTranslations: <Translations extends Record<string, Record<string, unknown>>>() => Translations;
|
|
11
|
+
export declare const TRANSIGNAL_CONFIG: InjectionToken<unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Use to inject transignal config
|
|
14
|
+
*/
|
|
15
|
+
export declare const injectTransignalConfig: <Languages extends string, Translations extends Record<string, Record<string, unknown>>>() => TransignalConfig<Languages, Translations>;
|
|
16
|
+
/**
|
|
17
|
+
* Prepares type-safe transignal object
|
|
18
|
+
* @param config Transignal configruation {@link TransignalConfig}
|
|
19
|
+
* @param features Extra tree-shakeable features
|
|
20
|
+
* - {@link withPreloadScopes} - preloads selected scopes
|
|
21
|
+
* - {@link withServerSideLanguage} - sets language based on `document.lang` in SSR environment
|
|
22
|
+
* - {@link withNavigatorLanguage} - sets language based on `navigator.language` in browser environment
|
|
23
|
+
* - {@link withLanguageLocalStorageSync} - syncs language with localStorage
|
|
24
|
+
* - {@link withTranslatedTitle} - enables translation of page title
|
|
25
|
+
*/
|
|
26
|
+
export declare const prepareTransignal: <Languages extends string, Translations extends Record<string, Record<string, unknown>>>(config: TransignalConfig<Languages, Translations>, ...features: NoInfer<TransignalFeature<Languages, Translations>[]>) => {
|
|
27
|
+
[INTERNAL_TRANSIGNAL_CONFIG]: {
|
|
28
|
+
config: TransignalConfig<Languages, Translations>;
|
|
29
|
+
features: TransignalFeature<Languages, Translations>[];
|
|
30
|
+
};
|
|
31
|
+
provide: () => import("@angular/core").EnvironmentProviders;
|
|
32
|
+
service: () => TransignalService<Languages, Translations, StringKeys<Translations>>;
|
|
33
|
+
t: <Scope extends StringKeys<Translations>>(scope: Scope) => import("./types").TranslateObj<Translations[Scope]>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { inject, InjectionToken, makeEnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { INTERNAL_TRANSIGNAL_CONFIG, TREE_SHAKED_TRANSLATIONS } from './internals';
|
|
3
|
+
import { TransignalService } from './transignal-service';
|
|
4
|
+
/**
|
|
5
|
+
* Utility function to define a type of translations for type inference
|
|
6
|
+
*/
|
|
7
|
+
export const treeShakedTranslations = () => TREE_SHAKED_TRANSLATIONS;
|
|
8
|
+
export const TRANSIGNAL_CONFIG = new InjectionToken('TRANSIGNAL_CONFIG');
|
|
9
|
+
/**
|
|
10
|
+
* Use to inject transignal config
|
|
11
|
+
*/
|
|
12
|
+
export const injectTransignalConfig = () => inject(TRANSIGNAL_CONFIG);
|
|
13
|
+
/**
|
|
14
|
+
* Prepares type-safe transignal object
|
|
15
|
+
* @param config Transignal configruation {@link TransignalConfig}
|
|
16
|
+
* @param features Extra tree-shakeable features
|
|
17
|
+
* - {@link withPreloadScopes} - preloads selected scopes
|
|
18
|
+
* - {@link withServerSideLanguage} - sets language based on `document.lang` in SSR environment
|
|
19
|
+
* - {@link withNavigatorLanguage} - sets language based on `navigator.language` in browser environment
|
|
20
|
+
* - {@link withLanguageLocalStorageSync} - syncs language with localStorage
|
|
21
|
+
* - {@link withTranslatedTitle} - enables translation of page title
|
|
22
|
+
*/
|
|
23
|
+
export const prepareTransignal = (config, ...features) => {
|
|
24
|
+
const service = () => inject(TransignalService);
|
|
25
|
+
return {
|
|
26
|
+
[INTERNAL_TRANSIGNAL_CONFIG]: { config, features },
|
|
27
|
+
provide: () => makeEnvironmentProviders([
|
|
28
|
+
{ provide: TRANSIGNAL_CONFIG, useValue: config },
|
|
29
|
+
TransignalService,
|
|
30
|
+
features.map(feature => feature.providers),
|
|
31
|
+
]),
|
|
32
|
+
service,
|
|
33
|
+
t: (scope) => service().t(scope),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=transignal-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transignal-config.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAGjF,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIzD;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAElC,EAAE,CAAC,wBAAmD,CAAC;AAE3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,cAAc,CAAC,mBAAmB,CAAC,CAAC;AAEzE;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAGlC,EAAE,CAAC,MAAM,CAA4C,iBAAiB,CAAC,CAAC;AAE5E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAI/B,MAAiD,EACjD,GAAG,QAA+D,EAClE,EAAE;IACF,MAAM,OAAO,GAAG,GAAG,EAAE,CACnB,MAAM,CAAuE,iBAAiB,CAAC,CAAC;IAClG,OAAO;QACL,CAAC,0BAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QAClD,OAAO,EAAE,GAAG,EAAE,CACZ,wBAAwB,CAAC;YACvB,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE;YAChD,iBAAiB;YACjB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;SAC3C,CAAC;QACJ,OAAO;QACP,CAAC,EAAE,CAAyC,KAAY,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;KAChF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TranslateParams } from './types';
|
|
2
|
+
export type ParamHandler = (translation: string, params?: TranslateParams) => string;
|
|
3
|
+
/**
|
|
4
|
+
* Param handler which allows for specification of basic params: `{name}`
|
|
5
|
+
*
|
|
6
|
+
* @param translation Translated text
|
|
7
|
+
* @param params Params provided to translation function
|
|
8
|
+
*/
|
|
9
|
+
export declare const simpleParamsHandler: ParamHandler;
|
|
10
|
+
export declare const noParamsHandler: ParamHandler;
|
|
11
|
+
export declare const simpleParamValueStringify: (paramValue: unknown) => any;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Param handler which allows for specification of basic params: `{name}`
|
|
3
|
+
*
|
|
4
|
+
* @param translation Translated text
|
|
5
|
+
* @param params Params provided to translation function
|
|
6
|
+
*/
|
|
7
|
+
export const simpleParamsHandler = (translation, params) => {
|
|
8
|
+
if (!params)
|
|
9
|
+
return translation;
|
|
10
|
+
for (const [key, value] of Object.entries(params)) {
|
|
11
|
+
translation = translation.replaceAll(`{${key}}`, simpleParamValueStringify(value));
|
|
12
|
+
}
|
|
13
|
+
return translation;
|
|
14
|
+
};
|
|
15
|
+
export const noParamsHandler = translation => translation;
|
|
16
|
+
export const simpleParamValueStringify = (paramValue) => {
|
|
17
|
+
if (typeof paramValue === 'string') {
|
|
18
|
+
return paramValue;
|
|
19
|
+
}
|
|
20
|
+
if (paramValue == null) {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
return paramValue.toString();
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=transignal-param-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transignal-param-handlers.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE;IACvE,IAAI,CAAC,MAAM;QAAE,OAAO,WAAW,CAAC;IAChC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,EAAE,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAiB,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC;AAExE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,UAAmB,EAAE,EAAE;IAC/D,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAQ,UAAkB,CAAC,QAAQ,EAAE,CAAC;AACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TranslateObj, TranslateParams } from './types';
|
|
2
|
+
import { StringKeys } from './utility-types';
|
|
3
|
+
/**
|
|
4
|
+
* Main transignal service, used to process and cache translations
|
|
5
|
+
* Can be injected directly or with use of transignal object created with {@link prepareTransignal} function (recommended)
|
|
6
|
+
*/
|
|
7
|
+
export declare class TransignalService<Languages extends string, Translations extends Record<string, Record<string, any>>, Scopes extends StringKeys<Translations>> {
|
|
8
|
+
private readonly injector;
|
|
9
|
+
private readonly config;
|
|
10
|
+
private readonly paramsHandler;
|
|
11
|
+
private readonly loadingFn;
|
|
12
|
+
private readonly errorHandler;
|
|
13
|
+
private readonly loadingCount;
|
|
14
|
+
private readonly scopeMap;
|
|
15
|
+
private readonly languageMap;
|
|
16
|
+
/**
|
|
17
|
+
* Use to set or get active language
|
|
18
|
+
*/
|
|
19
|
+
readonly activeLang: import("@angular/core").WritableSignal<Languages>;
|
|
20
|
+
/**
|
|
21
|
+
* Use to determine whether service is currently loading translation files
|
|
22
|
+
*/
|
|
23
|
+
readonly isLoading: import("@angular/core").Signal<boolean>;
|
|
24
|
+
t<Scope extends Scopes>(scope: Scope): TranslateObj<Translations[Scope]>;
|
|
25
|
+
private initT;
|
|
26
|
+
private preparePrefixFn;
|
|
27
|
+
private preparePluralFn;
|
|
28
|
+
private prepareSelectFn;
|
|
29
|
+
protected replaceParams<T>(translation: T, params?: TranslateParams): T;
|
|
30
|
+
private fetchLanguage;
|
|
31
|
+
private resolveObjectPath;
|
|
32
|
+
}
|