@weglot/translate-react 0.0.0-stage → 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/LICENSE +202 -0
- package/NOTICE +6 -0
- package/README.md +199 -2
- package/build/_virtual/rolldown_runtime.cjs +29 -0
- package/build/_virtual/rolldown_runtime.mjs +7 -0
- package/build/index.cjs +0 -0
- package/build/index.d.cts +2 -0
- package/build/index.d.mts +2 -0
- package/build/index.mjs +1 -0
- package/build/locale.d.cts +6 -0
- package/build/locale.d.cts.map +1 -0
- package/build/locale.d.mts +6 -0
- package/build/locale.d.mts.map +1 -0
- package/build/metadata/manager.cjs +119 -0
- package/build/metadata/manager.mjs +114 -0
- package/build/metadata/manager.mjs.map +1 -0
- package/build/plugin/build-translator.cjs +210 -0
- package/build/plugin/build-translator.mjs +208 -0
- package/build/plugin/build-translator.mjs.map +1 -0
- package/build/plugin/cleanup.cjs +20 -0
- package/build/plugin/cleanup.mjs +20 -0
- package/build/plugin/cleanup.mjs.map +1 -0
- package/build/plugin/index.cjs +0 -0
- package/build/plugin/index.d.cts +2 -0
- package/build/plugin/index.d.mts +2 -0
- package/build/plugin/index.mjs +1 -0
- package/build/plugin/next-compiler-loader.cjs +40 -0
- package/build/plugin/next-compiler-loader.d.cts +12 -0
- package/build/plugin/next-compiler-loader.d.cts.map +1 -0
- package/build/plugin/next-compiler-loader.d.mts +13 -0
- package/build/plugin/next-compiler-loader.d.mts.map +1 -0
- package/build/plugin/next-compiler-loader.mjs +41 -0
- package/build/plugin/next-compiler-loader.mjs.map +1 -0
- package/build/plugin/next-config-loader.cjs +13 -0
- package/build/plugin/next-config-loader.d.cts +8 -0
- package/build/plugin/next-config-loader.d.cts.map +1 -0
- package/build/plugin/next-config-loader.d.mts +9 -0
- package/build/plugin/next-config-loader.d.mts.map +1 -0
- package/build/plugin/next-config-loader.mjs +14 -0
- package/build/plugin/next-config-loader.mjs.map +1 -0
- package/build/plugin/next-locale-client-loader.cjs +9 -0
- package/build/plugin/next-locale-client-loader.d.cts +8 -0
- package/build/plugin/next-locale-client-loader.d.cts.map +1 -0
- package/build/plugin/next-locale-client-loader.d.mts +9 -0
- package/build/plugin/next-locale-client-loader.d.mts.map +1 -0
- package/build/plugin/next-locale-client-loader.mjs +10 -0
- package/build/plugin/next-locale-client-loader.mjs.map +1 -0
- package/build/plugin/next-locale-server-loader.cjs +9 -0
- package/build/plugin/next-locale-server-loader.d.cts +8 -0
- package/build/plugin/next-locale-server-loader.d.cts.map +1 -0
- package/build/plugin/next-locale-server-loader.d.mts +9 -0
- package/build/plugin/next-locale-server-loader.d.mts.map +1 -0
- package/build/plugin/next-locale-server-loader.mjs +10 -0
- package/build/plugin/next-locale-server-loader.mjs.map +1 -0
- package/build/plugin/next.cjs +227 -0
- package/build/plugin/next.d.cts +9 -0
- package/build/plugin/next.d.cts.map +1 -0
- package/build/plugin/next.d.mts +9 -0
- package/build/plugin/next.d.mts.map +1 -0
- package/build/plugin/next.mjs +229 -0
- package/build/plugin/next.mjs.map +1 -0
- package/build/plugin/transform/babel-compat.cjs +13 -0
- package/build/plugin/transform/babel-compat.mjs +10 -0
- package/build/plugin/transform/babel-compat.mjs.map +1 -0
- package/build/plugin/transform/expression-strings.cjs +145 -0
- package/build/plugin/transform/expression-strings.mjs +140 -0
- package/build/plugin/transform/expression-strings.mjs.map +1 -0
- package/build/plugin/transform/index.cjs +45 -0
- package/build/plugin/transform/index.mjs +43 -0
- package/build/plugin/transform/index.mjs.map +1 -0
- package/build/plugin/transform/metadata.cjs +142 -0
- package/build/plugin/transform/metadata.mjs +141 -0
- package/build/plugin/transform/metadata.mjs.map +1 -0
- package/build/plugin/transform/process-file.cjs +525 -0
- package/build/plugin/transform/process-file.mjs +524 -0
- package/build/plugin/transform/process-file.mjs.map +1 -0
- package/build/plugin/transform/use-i18n.cjs +8 -0
- package/build/plugin/transform/use-i18n.mjs +7 -0
- package/build/plugin/transform/use-i18n.mjs.map +1 -0
- package/build/plugin/transform/utils.cjs +237 -0
- package/build/plugin/transform/utils.mjs +219 -0
- package/build/plugin/transform/utils.mjs.map +1 -0
- package/build/plugin/unplugin.cjs +188 -0
- package/build/plugin/unplugin.d.cts +8 -0
- package/build/plugin/unplugin.d.cts.map +1 -0
- package/build/plugin/unplugin.d.mts +8 -0
- package/build/plugin/unplugin.d.mts.map +1 -0
- package/build/plugin/unplugin.mjs +188 -0
- package/build/plugin/unplugin.mjs.map +1 -0
- package/build/plugin/vite.cjs +27 -0
- package/build/plugin/vite.d.cts +9 -0
- package/build/plugin/vite.d.cts.map +1 -0
- package/build/plugin/vite.d.mts +9 -0
- package/build/plugin/vite.d.mts.map +1 -0
- package/build/plugin/vite.mjs +28 -0
- package/build/plugin/vite.mjs.map +1 -0
- package/build/plugin/webpack.cjs +26 -0
- package/build/plugin/webpack.d.cts +8 -0
- package/build/plugin/webpack.d.cts.map +1 -0
- package/build/plugin/webpack.d.mts +8 -0
- package/build/plugin/webpack.d.mts.map +1 -0
- package/build/plugin/webpack.mjs +27 -0
- package/build/plugin/webpack.mjs.map +1 -0
- package/build/react/client/index.cjs +9 -0
- package/build/react/client/index.d.cts +5 -0
- package/build/react/client/index.d.mts +5 -0
- package/build/react/client/index.mjs +6 -0
- package/build/react/client/useTranslation.cjs +71 -0
- package/build/react/client/useTranslation.d.cts +42 -0
- package/build/react/client/useTranslation.d.cts.map +1 -0
- package/build/react/client/useTranslation.d.mts +42 -0
- package/build/react/client/useTranslation.d.mts.map +1 -0
- package/build/react/client/useTranslation.mjs +71 -0
- package/build/react/client/useTranslation.mjs.map +1 -0
- package/build/react/next/client.cjs +25 -0
- package/build/react/next/client.d.cts +9 -0
- package/build/react/next/client.d.cts.map +1 -0
- package/build/react/next/client.d.mts +9 -0
- package/build/react/next/client.d.mts.map +1 -0
- package/build/react/next/client.mjs +24 -0
- package/build/react/next/client.mjs.map +1 -0
- package/build/react/next/cookie-locale-resolver.cjs +29 -0
- package/build/react/next/cookie-locale-resolver.d.cts +33 -0
- package/build/react/next/cookie-locale-resolver.d.cts.map +1 -0
- package/build/react/next/cookie-locale-resolver.d.mts +33 -0
- package/build/react/next/cookie-locale-resolver.d.mts.map +1 -0
- package/build/react/next/cookie-locale-resolver.mjs +29 -0
- package/build/react/next/cookie-locale-resolver.mjs.map +1 -0
- package/build/react/next/server.cjs +21 -0
- package/build/react/next/server.d.cts +13 -0
- package/build/react/next/server.d.cts.map +1 -0
- package/build/react/next/server.d.mts +14 -0
- package/build/react/next/server.d.mts.map +1 -0
- package/build/react/next/server.mjs +20 -0
- package/build/react/next/server.mjs.map +1 -0
- package/build/react/server/ServerWeglotProvider.cjs +19 -0
- package/build/react/server/ServerWeglotProvider.d.cts +12 -0
- package/build/react/server/ServerWeglotProvider.d.cts.map +1 -0
- package/build/react/server/ServerWeglotProvider.d.mts +12 -0
- package/build/react/server/ServerWeglotProvider.d.mts.map +1 -0
- package/build/react/server/ServerWeglotProvider.mjs +19 -0
- package/build/react/server/ServerWeglotProvider.mjs.map +1 -0
- package/build/react/server/index.cjs +7 -0
- package/build/react/server/index.d.cts +4 -0
- package/build/react/server/index.d.mts +4 -0
- package/build/react/server/index.mjs +5 -0
- package/build/react/server/useTranslation.cjs +60 -0
- package/build/react/server/useTranslation.d.cts +36 -0
- package/build/react/server/useTranslation.d.cts.map +1 -0
- package/build/react/server/useTranslation.d.mts +36 -0
- package/build/react/server/useTranslation.d.mts.map +1 -0
- package/build/react/server/useTranslation.mjs +60 -0
- package/build/react/server/useTranslation.mjs.map +1 -0
- package/build/react/server-only/index.cjs +42 -0
- package/build/react/server-only/index.d.cts +38 -0
- package/build/react/server-only/index.d.cts.map +1 -0
- package/build/react/server-only/index.d.mts +38 -0
- package/build/react/server-only/index.d.mts.map +1 -0
- package/build/react/server-only/index.mjs +42 -0
- package/build/react/server-only/index.mjs.map +1 -0
- package/build/react/server-only/translations.cjs +86 -0
- package/build/react/server-only/translations.mjs +86 -0
- package/build/react/server-only/translations.mjs.map +1 -0
- package/build/react/shared/LocaleSwitcher.cjs +61 -0
- package/build/react/shared/LocaleSwitcher.d.cts +71 -0
- package/build/react/shared/LocaleSwitcher.d.cts.map +1 -0
- package/build/react/shared/LocaleSwitcher.d.mts +71 -0
- package/build/react/shared/LocaleSwitcher.d.mts.map +1 -0
- package/build/react/shared/LocaleSwitcher.mjs +61 -0
- package/build/react/shared/LocaleSwitcher.mjs.map +1 -0
- package/build/react/shared/WeglotContext.cjs +14 -0
- package/build/react/shared/WeglotContext.d.cts +34 -0
- package/build/react/shared/WeglotContext.d.cts.map +1 -0
- package/build/react/shared/WeglotContext.d.mts +34 -0
- package/build/react/shared/WeglotContext.d.mts.map +1 -0
- package/build/react/shared/WeglotContext.mjs +13 -0
- package/build/react/shared/WeglotContext.mjs.map +1 -0
- package/build/react/shared/WeglotProvider.cjs +250 -0
- package/build/react/shared/WeglotProvider.d.cts +60 -0
- package/build/react/shared/WeglotProvider.d.cts.map +1 -0
- package/build/react/shared/WeglotProvider.d.mts +60 -0
- package/build/react/shared/WeglotProvider.d.mts.map +1 -0
- package/build/react/shared/WeglotProvider.mjs +250 -0
- package/build/react/shared/WeglotProvider.mjs.map +1 -0
- package/build/react/shared/render-rich-text.cjs +56 -0
- package/build/react/shared/render-rich-text.d.cts +16 -0
- package/build/react/shared/render-rich-text.d.cts.map +1 -0
- package/build/react/shared/render-rich-text.d.mts +16 -0
- package/build/react/shared/render-rich-text.d.mts.map +1 -0
- package/build/react/shared/render-rich-text.mjs +55 -0
- package/build/react/shared/render-rich-text.mjs.map +1 -0
- package/build/react/shared/utils.cjs +34 -0
- package/build/react/shared/utils.mjs +35 -0
- package/build/react/shared/utils.mjs.map +1 -0
- package/build/react/types.d.cts +16 -0
- package/build/react/types.d.cts.map +1 -0
- package/build/react/types.d.mts +16 -0
- package/build/react/types.d.mts.map +1 -0
- package/build/runtime/html/segmenter.cjs +226 -0
- package/build/runtime/html/segmenter.mjs +225 -0
- package/build/runtime/html/segmenter.mjs.map +1 -0
- package/build/runtime/index.cjs +6 -0
- package/build/runtime/index.d.cts +2 -0
- package/build/runtime/index.d.mts +2 -0
- package/build/runtime/index.mjs +3 -0
- package/build/runtime/translate-dynamic.cjs +144 -0
- package/build/runtime/translate-dynamic.d.cts +29 -0
- package/build/runtime/translate-dynamic.d.cts.map +1 -0
- package/build/runtime/translate-dynamic.d.mts +29 -0
- package/build/runtime/translate-dynamic.d.mts.map +1 -0
- package/build/runtime/translate-dynamic.mjs +141 -0
- package/build/runtime/translate-dynamic.mjs.map +1 -0
- package/build/translation-server/logger.cjs +37 -0
- package/build/translation-server/logger.mjs +37 -0
- package/build/translation-server/logger.mjs.map +1 -0
- package/build/translation-server/translation-server.cjs +451 -0
- package/build/translation-server/translation-server.mjs +448 -0
- package/build/translation-server/translation-server.mjs.map +1 -0
- package/build/translators/api.cjs +12 -0
- package/build/translators/api.mjs +12 -0
- package/build/translators/api.mjs.map +1 -0
- package/build/translators/cache-factory.cjs +26 -0
- package/build/translators/cache-factory.mjs +27 -0
- package/build/translators/cache-factory.mjs.map +1 -0
- package/build/translators/local-cache.cjs +132 -0
- package/build/translators/local-cache.mjs +130 -0
- package/build/translators/local-cache.mjs.map +1 -0
- package/build/translators/translation-service.cjs +139 -0
- package/build/translators/translation-service.mjs +140 -0
- package/build/translators/translation-service.mjs.map +1 -0
- package/build/translators/weglot/api-client.cjs +131 -0
- package/build/translators/weglot/api-client.mjs +130 -0
- package/build/translators/weglot/api-client.mjs.map +1 -0
- package/build/translators/weglot/definitions/definitions.generated.cjs +53 -0
- package/build/translators/weglot/definitions/definitions.generated.mjs +52 -0
- package/build/translators/weglot/definitions/definitions.generated.mjs.map +1 -0
- package/build/translators/weglot/engine.cjs +43 -0
- package/build/translators/weglot/engine.mjs +40 -0
- package/build/translators/weglot/engine.mjs.map +1 -0
- package/build/translators/weglot/translator.cjs +67 -0
- package/build/translators/weglot/translator.mjs +68 -0
- package/build/translators/weglot/translator.mjs.map +1 -0
- package/build/translators/weglot/wire-format.cjs +128 -0
- package/build/translators/weglot/wire-format.mjs +129 -0
- package/build/translators/weglot/wire-format.mjs.map +1 -0
- package/build/types.d.cts +153 -0
- package/build/types.d.cts.map +1 -0
- package/build/types.d.mts +153 -0
- package/build/types.d.mts.map +1 -0
- package/build/utils/config-factory.cjs +100 -0
- package/build/utils/config-factory.mjs +97 -0
- package/build/utils/config-factory.mjs.map +1 -0
- package/build/utils/hash.cjs +17 -0
- package/build/utils/hash.mjs +16 -0
- package/build/utils/hash.mjs.map +1 -0
- package/build/utils/is-valid-locale.cjs +13 -0
- package/build/utils/is-valid-locale.mjs +13 -0
- package/build/utils/is-valid-locale.mjs.map +1 -0
- package/build/utils/logger.cjs +51 -0
- package/build/utils/logger.mjs +50 -0
- package/build/utils/logger.mjs.map +1 -0
- package/build/utils/path-helpers.cjs +49 -0
- package/build/utils/path-helpers.mjs +47 -0
- package/build/utils/path-helpers.mjs.map +1 -0
- package/build/utils/timeout.cjs +42 -0
- package/build/utils/timeout.mjs +41 -0
- package/build/utils/timeout.mjs.map +1 -0
- package/build/virtual/code-generator.cjs +58 -0
- package/build/virtual/code-generator.mjs +57 -0
- package/build/virtual/code-generator.mjs.map +1 -0
- package/build/virtual/config.cjs +19 -0
- package/build/virtual/config.d.cts +15 -0
- package/build/virtual/config.d.cts.map +1 -0
- package/build/virtual/config.d.mts +15 -0
- package/build/virtual/config.d.mts.map +1 -0
- package/build/virtual/config.mjs +14 -0
- package/build/virtual/config.mjs.map +1 -0
- package/build/virtual/locale/client.cjs +23 -0
- package/build/virtual/locale/client.d.cts +19 -0
- package/build/virtual/locale/client.d.cts.map +1 -0
- package/build/virtual/locale/client.d.mts +19 -0
- package/build/virtual/locale/client.d.mts.map +1 -0
- package/build/virtual/locale/client.mjs +22 -0
- package/build/virtual/locale/client.mjs.map +1 -0
- package/build/virtual/locale/server.cjs +13 -0
- package/build/virtual/locale/server.d.cts +13 -0
- package/build/virtual/locale/server.d.cts.map +1 -0
- package/build/virtual/locale/server.d.mts +13 -0
- package/build/virtual/locale/server.d.mts.map +1 -0
- package/build/virtual/locale/server.mjs +13 -0
- package/build/virtual/locale/server.mjs.map +1 -0
- package/package.json +260 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/virtual/config.ts"],"sourcesContent":[],"mappings":";;;cAEa,SAAA;cACA,QAAA;AADA,cAEA,YAFS,EAE6B,UAF7B;AACtB;AACa,cAGA,UAHsC,EAG1B,MAH0B,CAAA,MAAU,EAGrB,UAHqB,CAAA;AAG7D;AAGa,cAAA,iBAA6B,EAAA,MAAA;AAG1C;cAAa"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LocaleCode } from "../locale.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/virtual/config.d.ts
|
|
4
|
+
declare const serverUrl = "__SERVER_URL__";
|
|
5
|
+
declare const cacheDir = "__CACHE_DIR__";
|
|
6
|
+
declare const sourceLocale: LocaleCode;
|
|
7
|
+
/** Public locale to the language code the translate API expects. */
|
|
8
|
+
declare const apiLocales: Record<string, LocaleCode>;
|
|
9
|
+
/** Which inline elements the project's engine permits inside a segment. */
|
|
10
|
+
declare const translationEngine: number;
|
|
11
|
+
/** The project's regional API host. */
|
|
12
|
+
declare const apiBaseUrl: string;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { apiBaseUrl, apiLocales, cacheDir, serverUrl, sourceLocale, translationEngine };
|
|
15
|
+
//# sourceMappingURL=config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/virtual/config.ts"],"sourcesContent":[],"mappings":";;;cAEa,SAAA;cACA,QAAA;AADA,cAEA,YAFS,EAE6B,UAF7B;AACtB;AACa,cAGA,UAHsC,EAG1B,MAH0B,CAAA,MAAU,EAGrB,UAHqB,CAAA;AAG7D;AAGa,cAAA,iBAA6B,EAAA,MAAA;AAG1C;cAAa"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/virtual/config.ts
|
|
2
|
+
const serverUrl = "__SERVER_URL__";
|
|
3
|
+
const cacheDir = "__CACHE_DIR__";
|
|
4
|
+
const sourceLocale = "__SOURCE_LOCALE__";
|
|
5
|
+
/** Public locale to the language code the translate API expects. */
|
|
6
|
+
const apiLocales = {};
|
|
7
|
+
/** Which inline elements the project's engine permits inside a segment. */
|
|
8
|
+
const translationEngine = 3;
|
|
9
|
+
/** The project's regional API host. */
|
|
10
|
+
const apiBaseUrl = "https://api.weglot.com";
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { apiBaseUrl, apiLocales, cacheDir, serverUrl, sourceLocale, translationEngine };
|
|
14
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","names":["apiLocales: Record<string, LocaleCode>","translationEngine: number","apiBaseUrl: string"],"sources":["../../src/virtual/config.ts"],"sourcesContent":["import type { LocaleCode } from \"../locale\";\n\nexport const serverUrl = \"__SERVER_URL__\";\nexport const cacheDir = \"__CACHE_DIR__\";\nexport const sourceLocale = \"__SOURCE_LOCALE__\" as LocaleCode;\n\n/** Public locale to the language code the translate API expects. */\nexport const apiLocales: Record<string, LocaleCode> = {};\n\n/** Which inline elements the project's engine permits inside a segment. */\nexport const translationEngine: number = 3;\n\n/** The project's regional API host. */\nexport const apiBaseUrl: string = \"https://api.weglot.com\";\n"],"mappings":";AAEA,MAAa,YAAY;AACzB,MAAa,WAAW;AACxB,MAAa,eAAe;;AAG5B,MAAaA,aAAyC,EAAE;;AAGxD,MAAaC,oBAA4B;;AAGzC,MAAaC,aAAqB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/virtual/locale/client.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get the current locale on the client
|
|
5
|
+
* Reads from cookie
|
|
6
|
+
* @returns Resolved locale code
|
|
7
|
+
*/
|
|
8
|
+
function getClientLocale() {
|
|
9
|
+
return "en";
|
|
10
|
+
}
|
|
11
|
+
const __NOOP_PERSIST_LOCALE__ = () => {};
|
|
12
|
+
/**
|
|
13
|
+
* Persist the locale on the client
|
|
14
|
+
* Writes to cookie
|
|
15
|
+
* @param locale - Locale code to persist
|
|
16
|
+
*/
|
|
17
|
+
function persistLocale(locale) {
|
|
18
|
+
return __NOOP_PERSIST_LOCALE__();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.getClientLocale = getClientLocale;
|
|
23
|
+
exports.persistLocale = persistLocale;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LocaleCode } from "../../locale.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/virtual/locale/client.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get the current locale on the client
|
|
7
|
+
* Reads from cookie
|
|
8
|
+
* @returns Resolved locale code
|
|
9
|
+
*/
|
|
10
|
+
declare function getClientLocale(): LocaleCode;
|
|
11
|
+
/**
|
|
12
|
+
* Persist the locale on the client
|
|
13
|
+
* Writes to cookie
|
|
14
|
+
* @param locale - Locale code to persist
|
|
15
|
+
*/
|
|
16
|
+
declare function persistLocale(locale: LocaleCode): void;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getClientLocale, persistLocale };
|
|
19
|
+
//# sourceMappingURL=client.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.cts","names":[],"sources":["../../../src/virtual/locale/client.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;AAWA;;iBAXgB,eAAA,CAAA,GAAmB;;;;;;iBAWnB,aAAA,SAAsB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LocaleCode } from "../../locale.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/virtual/locale/client.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get the current locale on the client
|
|
7
|
+
* Reads from cookie
|
|
8
|
+
* @returns Resolved locale code
|
|
9
|
+
*/
|
|
10
|
+
declare function getClientLocale(): LocaleCode;
|
|
11
|
+
/**
|
|
12
|
+
* Persist the locale on the client
|
|
13
|
+
* Writes to cookie
|
|
14
|
+
* @param locale - Locale code to persist
|
|
15
|
+
*/
|
|
16
|
+
declare function persistLocale(locale: LocaleCode): void;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getClientLocale, persistLocale };
|
|
19
|
+
//# sourceMappingURL=client.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../../../src/virtual/locale/client.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;AAWA;;iBAXgB,eAAA,CAAA,GAAmB;;;;;;iBAWnB,aAAA,SAAsB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/virtual/locale/client.ts
|
|
2
|
+
/**
|
|
3
|
+
* Get the current locale on the client
|
|
4
|
+
* Reads from cookie
|
|
5
|
+
* @returns Resolved locale code
|
|
6
|
+
*/
|
|
7
|
+
function getClientLocale() {
|
|
8
|
+
return "en";
|
|
9
|
+
}
|
|
10
|
+
const __NOOP_PERSIST_LOCALE__ = () => {};
|
|
11
|
+
/**
|
|
12
|
+
* Persist the locale on the client
|
|
13
|
+
* Writes to cookie
|
|
14
|
+
* @param locale - Locale code to persist
|
|
15
|
+
*/
|
|
16
|
+
function persistLocale(locale) {
|
|
17
|
+
return __NOOP_PERSIST_LOCALE__();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getClientLocale, persistLocale };
|
|
22
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../../../src/virtual/locale/client.ts"],"sourcesContent":["import type { LocaleCode } from \"../../locale\";\n\n/**\n * Get the current locale on the client\n * Reads from cookie\n * @returns Resolved locale code\n */\nexport function getClientLocale(): LocaleCode {\n return \"en\";\n}\n\nconst __NOOP_PERSIST_LOCALE__ = () => {};\n\n/**\n * Persist the locale on the client\n * Writes to cookie\n * @param locale - Locale code to persist\n */\nexport function persistLocale(locale: LocaleCode): void {\n return __NOOP_PERSIST_LOCALE__();\n}\n"],"mappings":";;;;;;AAOA,SAAgB,kBAA8B;AAC5C,QAAO;;AAGT,MAAM,gCAAgC;;;;;;AAOtC,SAAgB,cAAc,QAA0B;AACtD,QAAO,yBAAyB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/virtual/locale/server.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get the current locale on the server
|
|
5
|
+
* Uses cookies, headers, or other server-side mechanisms
|
|
6
|
+
* @returns Resolved locale code
|
|
7
|
+
*/
|
|
8
|
+
async function getServerLocale() {
|
|
9
|
+
return "en";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.getServerLocale = getServerLocale;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LocaleCode } from "../../locale.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/virtual/locale/server.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get the current locale on the server
|
|
7
|
+
* Uses cookies, headers, or other server-side mechanisms
|
|
8
|
+
* @returns Resolved locale code
|
|
9
|
+
*/
|
|
10
|
+
declare function getServerLocale(): Promise<LocaleCode>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getServerLocale };
|
|
13
|
+
//# sourceMappingURL=server.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.cts","names":[],"sources":["../../../src/virtual/locale/server.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;iBAAsB,eAAA,CAAA,GAAmB,QAAQ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LocaleCode } from "../../locale.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/virtual/locale/server.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get the current locale on the server
|
|
7
|
+
* Uses cookies, headers, or other server-side mechanisms
|
|
8
|
+
* @returns Resolved locale code
|
|
9
|
+
*/
|
|
10
|
+
declare function getServerLocale(): Promise<LocaleCode>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getServerLocale };
|
|
13
|
+
//# sourceMappingURL=server.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.mts","names":[],"sources":["../../../src/virtual/locale/server.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;iBAAsB,eAAA,CAAA,GAAmB,QAAQ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/virtual/locale/server.ts
|
|
2
|
+
/**
|
|
3
|
+
* Get the current locale on the server
|
|
4
|
+
* Uses cookies, headers, or other server-side mechanisms
|
|
5
|
+
* @returns Resolved locale code
|
|
6
|
+
*/
|
|
7
|
+
async function getServerLocale() {
|
|
8
|
+
return "en";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getServerLocale };
|
|
13
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","names":[],"sources":["../../../src/virtual/locale/server.ts"],"sourcesContent":["import type { LocaleCode } from \"../../locale\";\n\n/**\n * Get the current locale on the server\n * Uses cookies, headers, or other server-side mechanisms\n * @returns Resolved locale code\n */\nexport async function getServerLocale(): Promise<LocaleCode> {\n return \"en\";\n}\n"],"mappings":";;;;;;AAOA,eAAsB,kBAAuC;AAC3D,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,262 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weglot/translate-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Automatic Weglot translation for React and Next.js apps, detected from your JSX at build time",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "build/index.cjs",
|
|
8
|
+
"types": "build/index.d.cts",
|
|
9
|
+
"module": "build/index.mjs",
|
|
10
|
+
"exports": {
|
|
11
|
+
"./dynamic": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./build/runtime/index.d.mts",
|
|
14
|
+
"default": "./build/runtime/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./build/runtime/index.d.cts",
|
|
18
|
+
"default": "./build/runtime/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
".": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./build/plugin/index.d.mts",
|
|
24
|
+
"default": "./build/plugin/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./build/plugin/index.d.cts",
|
|
28
|
+
"default": "./build/plugin/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"./react": {
|
|
32
|
+
"react-server": {
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./build/react/server/index.d.mts",
|
|
35
|
+
"default": "./build/react/server/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"default": {
|
|
38
|
+
"types": "./build/react/server/index.d.cts",
|
|
39
|
+
"default": "./build/react/server/index.cjs"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"default": {
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./build/react/client/index.d.mts",
|
|
45
|
+
"default": "./build/react/client/index.mjs"
|
|
46
|
+
},
|
|
47
|
+
"default": {
|
|
48
|
+
"types": "./build/react/client/index.d.cts",
|
|
49
|
+
"default": "./build/react/client/index.cjs"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"./virtual/config": {
|
|
54
|
+
"import": {
|
|
55
|
+
"types": "./build/virtual/config.d.mts",
|
|
56
|
+
"default": "./build/virtual/config.mjs"
|
|
57
|
+
},
|
|
58
|
+
"require": {
|
|
59
|
+
"types": "./build/virtual/config.d.cts",
|
|
60
|
+
"default": "./build/virtual/config.cjs"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"./virtual/locale/server": {
|
|
64
|
+
"import": {
|
|
65
|
+
"types": "./build/virtual/locale/server.d.mts",
|
|
66
|
+
"default": "./build/virtual/locale/server.mjs"
|
|
67
|
+
},
|
|
68
|
+
"require": {
|
|
69
|
+
"types": "./build/virtual/locale/server.d.cts",
|
|
70
|
+
"default": "./build/virtual/locale/server.cjs"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"./virtual/locale/client": {
|
|
74
|
+
"import": {
|
|
75
|
+
"types": "./build/virtual/locale/client.d.mts",
|
|
76
|
+
"default": "./build/virtual/locale/client.mjs"
|
|
77
|
+
},
|
|
78
|
+
"require": {
|
|
79
|
+
"types": "./build/virtual/locale/client.d.cts",
|
|
80
|
+
"default": "./build/virtual/locale/client.cjs"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"./react/next": {
|
|
84
|
+
"react-server": {
|
|
85
|
+
"import": {
|
|
86
|
+
"types": "./build/react/next/server.d.mts",
|
|
87
|
+
"default": "./build/react/next/server.mjs"
|
|
88
|
+
},
|
|
89
|
+
"default": {
|
|
90
|
+
"types": "./build/react/next/server.d.cts",
|
|
91
|
+
"default": "./build/react/next/server.cjs"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"default": {
|
|
95
|
+
"import": {
|
|
96
|
+
"types": "./build/react/next/client.d.mts",
|
|
97
|
+
"default": "./build/react/next/client.mjs"
|
|
98
|
+
},
|
|
99
|
+
"default": {
|
|
100
|
+
"types": "./build/react/next/client.d.cts",
|
|
101
|
+
"default": "./build/react/next/client.cjs"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"./react/server": {
|
|
106
|
+
"import": {
|
|
107
|
+
"types": "./build/react/server-only/index.d.mts",
|
|
108
|
+
"default": "./build/react/server-only/index.mjs"
|
|
109
|
+
},
|
|
110
|
+
"require": {
|
|
111
|
+
"types": "./build/react/server-only/index.d.cts",
|
|
112
|
+
"default": "./build/react/server-only/index.cjs"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"./next": {
|
|
116
|
+
"import": {
|
|
117
|
+
"types": "./build/plugin/next.d.mts",
|
|
118
|
+
"default": "./build/plugin/next.mjs"
|
|
119
|
+
},
|
|
120
|
+
"require": {
|
|
121
|
+
"types": "./build/plugin/next.d.cts",
|
|
122
|
+
"default": "./build/plugin/next.cjs"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"./vite": {
|
|
126
|
+
"import": {
|
|
127
|
+
"types": "./build/plugin/vite.d.mts",
|
|
128
|
+
"default": "./build/plugin/vite.mjs"
|
|
129
|
+
},
|
|
130
|
+
"require": {
|
|
131
|
+
"types": "./build/plugin/vite.d.cts",
|
|
132
|
+
"default": "./build/plugin/vite.cjs"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"./webpack": {
|
|
136
|
+
"import": {
|
|
137
|
+
"types": "./build/plugin/webpack.d.mts",
|
|
138
|
+
"default": "./build/plugin/webpack.mjs"
|
|
139
|
+
},
|
|
140
|
+
"require": {
|
|
141
|
+
"types": "./build/plugin/webpack.d.cts",
|
|
142
|
+
"default": "./build/plugin/webpack.cjs"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"./next-compiler-loader": {
|
|
146
|
+
"import": {
|
|
147
|
+
"types": "./build/plugin/next-compiler-loader.d.mts",
|
|
148
|
+
"default": "./build/plugin/next-compiler-loader.mjs"
|
|
149
|
+
},
|
|
150
|
+
"require": {
|
|
151
|
+
"types": "./build/plugin/next-compiler-loader.d.cts",
|
|
152
|
+
"default": "./build/plugin/next-compiler-loader.cjs"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"./next-config-loader": {
|
|
156
|
+
"import": {
|
|
157
|
+
"types": "./build/plugin/next-config-loader.d.mts",
|
|
158
|
+
"default": "./build/plugin/next-config-loader.mjs"
|
|
159
|
+
},
|
|
160
|
+
"require": {
|
|
161
|
+
"types": "./build/plugin/next-config-loader.d.cts",
|
|
162
|
+
"default": "./build/plugin/next-config-loader.cjs"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"./next-locale-server-loader": {
|
|
166
|
+
"import": {
|
|
167
|
+
"types": "./build/plugin/next-locale-server-loader.d.mts",
|
|
168
|
+
"default": "./build/plugin/next-locale-server-loader.mjs"
|
|
169
|
+
},
|
|
170
|
+
"require": {
|
|
171
|
+
"types": "./build/plugin/next-locale-server-loader.d.cts",
|
|
172
|
+
"default": "./build/plugin/next-locale-server-loader.cjs"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"./next-locale-client-loader": {
|
|
176
|
+
"import": {
|
|
177
|
+
"types": "./build/plugin/next-locale-client-loader.d.mts",
|
|
178
|
+
"default": "./build/plugin/next-locale-client-loader.mjs"
|
|
179
|
+
},
|
|
180
|
+
"require": {
|
|
181
|
+
"types": "./build/plugin/next-locale-client-loader.d.cts",
|
|
182
|
+
"default": "./build/plugin/next-locale-client-loader.cjs"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"files": [
|
|
187
|
+
"build",
|
|
188
|
+
"NOTICE"
|
|
189
|
+
],
|
|
190
|
+
"scripts": {
|
|
191
|
+
"dev": "tsdown --watch",
|
|
192
|
+
"build": "pnpm typecheck && tsdown",
|
|
193
|
+
"typecheck": "tsc --noEmit",
|
|
194
|
+
"clean": "rm -rf build",
|
|
195
|
+
"test": "vitest --run",
|
|
196
|
+
"sync-definitions": "node scripts/sync-definitions.ts",
|
|
197
|
+
"check-definitions": "node scripts/sync-definitions.ts --check",
|
|
198
|
+
"test:watch": "vitest -w",
|
|
199
|
+
"prepublishOnly": "pnpm build"
|
|
200
|
+
},
|
|
201
|
+
"keywords": [
|
|
202
|
+
"weglot",
|
|
203
|
+
"i18n",
|
|
204
|
+
"translation",
|
|
205
|
+
"react",
|
|
206
|
+
"nextjs",
|
|
207
|
+
"vite",
|
|
208
|
+
"compiler"
|
|
209
|
+
],
|
|
210
|
+
"author": "Weglot",
|
|
211
|
+
"license": "Apache-2.0",
|
|
212
|
+
"repository": {
|
|
213
|
+
"type": "git",
|
|
214
|
+
"url": "git+https://github.com/weglot/translate-jsx.git"
|
|
215
|
+
},
|
|
216
|
+
"homepage": "https://github.com/weglot/translate-jsx#readme",
|
|
217
|
+
"bugs": {
|
|
218
|
+
"url": "https://github.com/weglot/translate-jsx/issues"
|
|
219
|
+
},
|
|
220
|
+
"engines": {
|
|
221
|
+
"node": ">=20.9.0"
|
|
222
|
+
},
|
|
223
|
+
"publishConfig": {
|
|
224
|
+
"access": "public"
|
|
225
|
+
},
|
|
226
|
+
"devDependencies": {
|
|
227
|
+
"@types/babel__core": "7.20.5",
|
|
228
|
+
"@types/babel__generator": "7.27.0",
|
|
229
|
+
"@types/babel__traverse": "7.28.0",
|
|
230
|
+
"@types/node": "25.0.3",
|
|
231
|
+
"@types/react": "19.2.7",
|
|
232
|
+
"@types/react-dom": "19.2.3",
|
|
233
|
+
"jsdom": "30.0.1",
|
|
234
|
+
"next": "16.2.9",
|
|
235
|
+
"tsdown": "0.18.2",
|
|
236
|
+
"typescript": "5.9.3",
|
|
237
|
+
"vitest": "4.1.0"
|
|
238
|
+
},
|
|
239
|
+
"dependencies": {
|
|
240
|
+
"@babel/generator": "^7.28.5",
|
|
241
|
+
"@babel/parser": "^7.28.5",
|
|
242
|
+
"@babel/traverse": "^7.28.5",
|
|
243
|
+
"@babel/types": "^7.28.5",
|
|
244
|
+
"dom-serializer": "^2.0.0",
|
|
245
|
+
"domhandler": "^5.0.3",
|
|
246
|
+
"dotenv": "^17.2.3",
|
|
247
|
+
"htmlparser2": "^10.1.0",
|
|
248
|
+
"intl-messageformat": "^11.0.6",
|
|
249
|
+
"lmdb": "^3.2.6",
|
|
250
|
+
"unplugin": "^2.3.11"
|
|
251
|
+
},
|
|
252
|
+
"peerDependencies": {
|
|
253
|
+
"next": "^15.0.0 || ^16.0.4",
|
|
254
|
+
"react": "^19.0.0",
|
|
255
|
+
"react-dom": "^19.0.0"
|
|
256
|
+
},
|
|
257
|
+
"peerDependenciesMeta": {
|
|
258
|
+
"next": {
|
|
259
|
+
"optional": true
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|