@ayinza_dev/i18n-config 1.5.0 → 1.5.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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/parser-hooks.d.ts +24 -1
- package/dist/parser-hooks.js +26 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { I18nConfig, I18nInitOptions, FormattersConfig, LocaleMapping, Pars
|
|
|
3
3
|
export { I18nFormatters } from "./formatters.js";
|
|
4
4
|
export { useFormatting, useI18n } from "./hooks.js";
|
|
5
5
|
export { createI18nextParserConfig } from "./parser-config.js";
|
|
6
|
-
export { createTranslationSnapshot, collectNewTranslationKeys, handleNewTranslationKeys, publishTranslationOverrides, } from "./parser-hooks.js";
|
|
6
|
+
export { createTranslationSnapshot, collectNewTranslationKeys, handleNewTranslationKeys, publishTranslationOverrides, resolveSourcePushUrl, resolveOverridePushUrl, TRANSLATE_SEND_PATH, ADMIN_TRANSLATIONS_PATH, } from "./parser-hooks.js";
|
|
7
7
|
export type { PublishTranslationOverridesOptions } from "./parser-hooks.js";
|
|
8
8
|
export { useTranslation, Trans, Translation } from "react-i18next";
|
|
9
9
|
export { type TFunction } from "i18next";
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,6 @@ export { initializeI18n, getI18nInstance, getFormatters, defaultConfig, createI1
|
|
|
2
2
|
export { I18nFormatters } from "./formatters.js";
|
|
3
3
|
export { useFormatting, useI18n } from "./hooks.js";
|
|
4
4
|
export { createI18nextParserConfig } from "./parser-config.js";
|
|
5
|
-
export { createTranslationSnapshot, collectNewTranslationKeys, handleNewTranslationKeys, publishTranslationOverrides, } from "./parser-hooks.js";
|
|
5
|
+
export { createTranslationSnapshot, collectNewTranslationKeys, handleNewTranslationKeys, publishTranslationOverrides, resolveSourcePushUrl, resolveOverridePushUrl, TRANSLATE_SEND_PATH, ADMIN_TRANSLATIONS_PATH, } from "./parser-hooks.js";
|
|
6
6
|
// Re-export commonly used utilities from react-i18next
|
|
7
7
|
export { useTranslation, Trans, Translation } from "react-i18next";
|
package/dist/parser-hooks.d.ts
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import type { NewKeyPayload, ParserPushConfig, TranslationSnapshot } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Localization-service endpoint paths, appended to the API base URL
|
|
4
|
+
* (`VITE_LOCALIZATION_API_BASE_URL`, e.g. `https://…/api/v1`). Owning them here is
|
|
5
|
+
* the single source of truth so no consumer hardcodes (and mis-types) the paths —
|
|
6
|
+
* the override route in particular lives under `/l10n/admin/translations`, NOT the
|
|
7
|
+
* bare `/admin/translations`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TRANSLATE_SEND_PATH = "/l10n/translate/send";
|
|
10
|
+
export declare const ADMIN_TRANSLATIONS_PATH = "/l10n/admin/translations";
|
|
11
|
+
/**
|
|
12
|
+
* Build the source-key registration URL (POST) from an API base URL — the
|
|
13
|
+
* `pushUrl` for {@link handleNewTranslationKeys}.
|
|
14
|
+
*
|
|
15
|
+
* @example resolveSourcePushUrl("https://loc/api/v1") // ".../api/v1/l10n/translate/send"
|
|
16
|
+
*/
|
|
17
|
+
export declare const resolveSourcePushUrl: (apiBaseUrl: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Build the human-override collection URL from an API base URL — the `pushUrl`
|
|
20
|
+
* for {@link publishTranslationOverrides}, which appends `/{locale}` per request.
|
|
21
|
+
*
|
|
22
|
+
* @example resolveOverridePushUrl("https://loc/api/v1") // ".../api/v1/l10n/admin/translations"
|
|
23
|
+
*/
|
|
24
|
+
export declare const resolveOverridePushUrl: (apiBaseUrl: string) => string;
|
|
2
25
|
export interface CreateTranslationSnapshotOptions {
|
|
3
26
|
locale: string;
|
|
4
27
|
namespaces: Record<string, Record<string, unknown>>;
|
|
@@ -36,7 +59,7 @@ export interface PublishTranslationOverridesOptions {
|
|
|
36
59
|
}
|
|
37
60
|
/**
|
|
38
61
|
* Publish curated translation overrides for a locale to the localization
|
|
39
|
-
* service's upsert endpoint (`PUT /admin/translations/{locale}`). Any Ayinza
|
|
62
|
+
* service's upsert endpoint (`PUT /l10n/admin/translations/{locale}`). Any Ayinza
|
|
40
63
|
* product uses this to correct its own catalog (e.g. replacing garbled machine
|
|
41
64
|
* translations); the service marks the rows human-authoritative so the MT
|
|
42
65
|
* sweep never re-manufactures them.
|
package/dist/parser-hooks.js
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Localization-service endpoint paths, appended to the API base URL
|
|
3
|
+
* (`VITE_LOCALIZATION_API_BASE_URL`, e.g. `https://…/api/v1`). Owning them here is
|
|
4
|
+
* the single source of truth so no consumer hardcodes (and mis-types) the paths —
|
|
5
|
+
* the override route in particular lives under `/l10n/admin/translations`, NOT the
|
|
6
|
+
* bare `/admin/translations`.
|
|
7
|
+
*/
|
|
8
|
+
export const TRANSLATE_SEND_PATH = "/l10n/translate/send";
|
|
9
|
+
export const ADMIN_TRANSLATIONS_PATH = "/l10n/admin/translations";
|
|
10
|
+
const stripTrailingSlashes = (url) => url.replace(/\/+$/, "");
|
|
11
|
+
/**
|
|
12
|
+
* Build the source-key registration URL (POST) from an API base URL — the
|
|
13
|
+
* `pushUrl` for {@link handleNewTranslationKeys}.
|
|
14
|
+
*
|
|
15
|
+
* @example resolveSourcePushUrl("https://loc/api/v1") // ".../api/v1/l10n/translate/send"
|
|
16
|
+
*/
|
|
17
|
+
export const resolveSourcePushUrl = (apiBaseUrl) => `${stripTrailingSlashes(apiBaseUrl)}${TRANSLATE_SEND_PATH}`;
|
|
18
|
+
/**
|
|
19
|
+
* Build the human-override collection URL from an API base URL — the `pushUrl`
|
|
20
|
+
* for {@link publishTranslationOverrides}, which appends `/{locale}` per request.
|
|
21
|
+
*
|
|
22
|
+
* @example resolveOverridePushUrl("https://loc/api/v1") // ".../api/v1/l10n/admin/translations"
|
|
23
|
+
*/
|
|
24
|
+
export const resolveOverridePushUrl = (apiBaseUrl) => `${stripTrailingSlashes(apiBaseUrl)}${ADMIN_TRANSLATIONS_PATH}`;
|
|
1
25
|
const formatValue = (value) => {
|
|
2
26
|
if (value === undefined || value === null) {
|
|
3
27
|
return "";
|
|
@@ -79,7 +103,7 @@ const headersToRecord = (headers) => {
|
|
|
79
103
|
/**
|
|
80
104
|
* Send a `{ data: { translations, category? } }` catalog payload to the
|
|
81
105
|
* localization-service. Shared by the source-key push (POST /translate/send)
|
|
82
|
-
* and the override publish (PUT /admin/translations/{locale}).
|
|
106
|
+
* and the override publish (PUT /l10n/admin/translations/{locale}).
|
|
83
107
|
*/
|
|
84
108
|
const sendCatalogPayload = async (options) => {
|
|
85
109
|
const { url, method, translations, pushConfig, requestInit } = options;
|
|
@@ -143,7 +167,7 @@ export const handleNewTranslationKeys = async (options) => {
|
|
|
143
167
|
};
|
|
144
168
|
/**
|
|
145
169
|
* Publish curated translation overrides for a locale to the localization
|
|
146
|
-
* service's upsert endpoint (`PUT /admin/translations/{locale}`). Any Ayinza
|
|
170
|
+
* service's upsert endpoint (`PUT /l10n/admin/translations/{locale}`). Any Ayinza
|
|
147
171
|
* product uses this to correct its own catalog (e.g. replacing garbled machine
|
|
148
172
|
* translations); the service marks the rows human-authoritative so the MT
|
|
149
173
|
* sweep never re-manufactures them.
|