@thunderid/javascript 1.0.5 → 1.0.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/dist/cjs/index.cjs +51 -36
- package/dist/edge/index.js +51 -36
- package/dist/index.js +51 -36
- package/dist/utils/getBaseLanguage.d.ts +0 -17
- package/dist/utils/getBaseLanguage.d.ts.map +1 -1
- package/dist/utils/normalizeLocaleTag.d.ts +0 -17
- package/dist/utils/normalizeLocaleTag.d.ts.map +1 -1
- package/dist/utils/resolveFlowTemplateLiterals.d.ts +3 -0
- package/dist/utils/resolveFlowTemplateLiterals.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -4359,6 +4359,38 @@ function resolveMeta(path, meta) {
|
|
|
4359
4359
|
return value != null ? String(value) : "";
|
|
4360
4360
|
}
|
|
4361
4361
|
|
|
4362
|
+
//#endregion
|
|
4363
|
+
//#region src/utils/isTranslationFlowTemplateLiteral.ts
|
|
4364
|
+
/**
|
|
4365
|
+
* Regular expression to match a translation flow template literal `{{t(key)}}` (exact, full-string match).
|
|
4366
|
+
* Optional whitespace around `{{` / `}}` is allowed.
|
|
4367
|
+
*/
|
|
4368
|
+
const TRANSLATION_FLOW_TEMPLATE_LITERAL_PATTERN = /^\{\{\s*t\([^)]+\)\s*\}\}$/;
|
|
4369
|
+
/**
|
|
4370
|
+
* Regular expression to extract the key from a translation flow template literal `{{t(key)}}`.
|
|
4371
|
+
*/
|
|
4372
|
+
const TRANSLATION_FLOW_TEMPLATE_LITERAL_KEY_PATTERN = /^\{\{\s*t\(([^)]+)\)\s*\}\}$/;
|
|
4373
|
+
/**
|
|
4374
|
+
* Check if a string is exactly a translation flow template literal (`{{ t(key) }}`).
|
|
4375
|
+
*
|
|
4376
|
+
* This checks that the **entire** string is the template pattern. Use
|
|
4377
|
+
* {@link FLOW_TEMPLATE_LITERAL_REGEX} from `parseFlowTemplateLiteral` to detect
|
|
4378
|
+
* templates embedded inside a larger string.
|
|
4379
|
+
*
|
|
4380
|
+
* @param value - The string to test.
|
|
4381
|
+
* @returns `true` if the trimmed value matches the pattern, `false` otherwise.
|
|
4382
|
+
*
|
|
4383
|
+
* @example
|
|
4384
|
+
* ```typescript
|
|
4385
|
+
* isTranslationFlowTemplateLiteral('{{ t(signin:heading) }}') // true
|
|
4386
|
+
* isTranslationFlowTemplateLiteral('hello world') // false
|
|
4387
|
+
* isTranslationFlowTemplateLiteral('Login via {{ t(key) }}') // false — embedded, not exact
|
|
4388
|
+
* ```
|
|
4389
|
+
*/
|
|
4390
|
+
function isTranslationFlowTemplateLiteral(value) {
|
|
4391
|
+
return TRANSLATION_FLOW_TEMPLATE_LITERAL_PATTERN.test(value.trim());
|
|
4392
|
+
}
|
|
4393
|
+
|
|
4362
4394
|
//#endregion
|
|
4363
4395
|
//#region src/utils/parseFlowTemplateLiteral.ts
|
|
4364
4396
|
/**
|
|
@@ -4445,6 +4477,13 @@ function parseFlowTemplateLiteral(content) {
|
|
|
4445
4477
|
*/
|
|
4446
4478
|
const FLOW_TEMPLATE_LITERAL_REGEX_GLOBAL = new RegExp(FLOW_TEMPLATE_LITERAL_REGEX.source, "g");
|
|
4447
4479
|
/**
|
|
4480
|
+
* Resolves a `{{ t(key) }}` translation key, converting its colon-separated namespace to dots
|
|
4481
|
+
* e.g. "signin:fields.password.label" → "signin.fields.password.label".
|
|
4482
|
+
*/
|
|
4483
|
+
function resolveTranslation(key, t) {
|
|
4484
|
+
return t(key.replace(/:/g, "."));
|
|
4485
|
+
}
|
|
4486
|
+
/**
|
|
4448
4487
|
* Resolves all flow template literal expressions in a string.
|
|
4449
4488
|
*
|
|
4450
4489
|
* Supported patterns:
|
|
@@ -4457,6 +4496,9 @@ const FLOW_TEMPLATE_LITERAL_REGEX_GLOBAL = new RegExp(FLOW_TEMPLATE_LITERAL_REGE
|
|
|
4457
4496
|
* Flow template literals can be embedded inside larger strings:
|
|
4458
4497
|
* `"Login using {{ meta(application.name) }}"` → `"Login using My App"`
|
|
4459
4498
|
*
|
|
4499
|
+
* A meta field can itself hold a translation reference instead of final display text — that case is
|
|
4500
|
+
* detected and resolved via `t()` too, so the raw template never reaches the screen.
|
|
4501
|
+
*
|
|
4460
4502
|
* Unrecognized expressions are left unchanged.
|
|
4461
4503
|
*
|
|
4462
4504
|
* @template TFn - The concrete translation function type.
|
|
@@ -4469,8 +4511,15 @@ function resolveFlowTemplateLiterals(text, { t, meta }) {
|
|
|
4469
4511
|
if (!text) return "";
|
|
4470
4512
|
return text.replace(FLOW_TEMPLATE_LITERAL_REGEX_GLOBAL, (match, content) => {
|
|
4471
4513
|
const parsed = parseFlowTemplateLiteral(content.trim());
|
|
4472
|
-
if (parsed.type === FlowTemplateLiteralType.TRANSLATION && parsed.key) return
|
|
4473
|
-
if (parsed.type === FlowTemplateLiteralType.META && parsed.key && meta)
|
|
4514
|
+
if (parsed.type === FlowTemplateLiteralType.TRANSLATION && parsed.key) return resolveTranslation(parsed.key, t);
|
|
4515
|
+
if (parsed.type === FlowTemplateLiteralType.META && parsed.key && meta) {
|
|
4516
|
+
const value = resolveMeta(parsed.key, meta);
|
|
4517
|
+
if (isTranslationFlowTemplateLiteral(value)) {
|
|
4518
|
+
const innerKey = value.trim().match(TRANSLATION_FLOW_TEMPLATE_LITERAL_KEY_PATTERN)[1];
|
|
4519
|
+
return resolveTranslation(innerKey, t);
|
|
4520
|
+
}
|
|
4521
|
+
return value;
|
|
4522
|
+
}
|
|
4474
4523
|
return match;
|
|
4475
4524
|
});
|
|
4476
4525
|
}
|
|
@@ -4578,23 +4627,6 @@ var resolveLocaleEmoji_default = resolveLocaleEmoji;
|
|
|
4578
4627
|
//#endregion
|
|
4579
4628
|
//#region src/utils/getBaseLanguage.ts
|
|
4580
4629
|
/**
|
|
4581
|
-
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
4582
|
-
*
|
|
4583
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
4584
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
4585
|
-
* in compliance with the License.
|
|
4586
|
-
* You may obtain a copy of the License at
|
|
4587
|
-
*
|
|
4588
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4589
|
-
*
|
|
4590
|
-
* Unless required by applicable law or agreed to in writing,
|
|
4591
|
-
* software distributed under the License is distributed on an
|
|
4592
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
4593
|
-
* KIND, either express or implied. See the License for the
|
|
4594
|
-
* specific language governing permissions and limitations
|
|
4595
|
-
* under the License.
|
|
4596
|
-
*/
|
|
4597
|
-
/**
|
|
4598
4630
|
* Resolves a BCP 47 locale tag to its base (primary) language subtag, so that
|
|
4599
4631
|
* region-qualified tags compare equal to their bare form (e.g. "en-US" and "en"
|
|
4600
4632
|
* both resolve to "en"). Uses `Intl.Locale` when available, falling back to a
|
|
@@ -4621,23 +4653,6 @@ function getBaseLanguage(tag) {
|
|
|
4621
4653
|
//#endregion
|
|
4622
4654
|
//#region src/utils/normalizeLocaleTag.ts
|
|
4623
4655
|
/**
|
|
4624
|
-
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
4625
|
-
*
|
|
4626
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
4627
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
4628
|
-
* in compliance with the License.
|
|
4629
|
-
* You may obtain a copy of the License at
|
|
4630
|
-
*
|
|
4631
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4632
|
-
*
|
|
4633
|
-
* Unless required by applicable law or agreed to in writing,
|
|
4634
|
-
* software distributed under the License is distributed on an
|
|
4635
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
4636
|
-
* KIND, either express or implied. See the License for the
|
|
4637
|
-
* specific language governing permissions and limitations
|
|
4638
|
-
* under the License.
|
|
4639
|
-
*/
|
|
4640
|
-
/**
|
|
4641
4656
|
* Lowercases the language subtag and uppercases a 2-letter region subtag (the common
|
|
4642
4657
|
* `language-REGION` shape), leaving everything else as-is. Not a full BCP 47 canonicalizer,
|
|
4643
4658
|
* but deterministic and dependency-free, so case-only differences still compare equal without
|
package/dist/edge/index.js
CHANGED
|
@@ -4339,6 +4339,38 @@ function resolveMeta(path, meta) {
|
|
|
4339
4339
|
return value != null ? String(value) : "";
|
|
4340
4340
|
}
|
|
4341
4341
|
|
|
4342
|
+
//#endregion
|
|
4343
|
+
//#region src/utils/isTranslationFlowTemplateLiteral.ts
|
|
4344
|
+
/**
|
|
4345
|
+
* Regular expression to match a translation flow template literal `{{t(key)}}` (exact, full-string match).
|
|
4346
|
+
* Optional whitespace around `{{` / `}}` is allowed.
|
|
4347
|
+
*/
|
|
4348
|
+
const TRANSLATION_FLOW_TEMPLATE_LITERAL_PATTERN = /^\{\{\s*t\([^)]+\)\s*\}\}$/;
|
|
4349
|
+
/**
|
|
4350
|
+
* Regular expression to extract the key from a translation flow template literal `{{t(key)}}`.
|
|
4351
|
+
*/
|
|
4352
|
+
const TRANSLATION_FLOW_TEMPLATE_LITERAL_KEY_PATTERN = /^\{\{\s*t\(([^)]+)\)\s*\}\}$/;
|
|
4353
|
+
/**
|
|
4354
|
+
* Check if a string is exactly a translation flow template literal (`{{ t(key) }}`).
|
|
4355
|
+
*
|
|
4356
|
+
* This checks that the **entire** string is the template pattern. Use
|
|
4357
|
+
* {@link FLOW_TEMPLATE_LITERAL_REGEX} from `parseFlowTemplateLiteral` to detect
|
|
4358
|
+
* templates embedded inside a larger string.
|
|
4359
|
+
*
|
|
4360
|
+
* @param value - The string to test.
|
|
4361
|
+
* @returns `true` if the trimmed value matches the pattern, `false` otherwise.
|
|
4362
|
+
*
|
|
4363
|
+
* @example
|
|
4364
|
+
* ```typescript
|
|
4365
|
+
* isTranslationFlowTemplateLiteral('{{ t(signin:heading) }}') // true
|
|
4366
|
+
* isTranslationFlowTemplateLiteral('hello world') // false
|
|
4367
|
+
* isTranslationFlowTemplateLiteral('Login via {{ t(key) }}') // false — embedded, not exact
|
|
4368
|
+
* ```
|
|
4369
|
+
*/
|
|
4370
|
+
function isTranslationFlowTemplateLiteral(value) {
|
|
4371
|
+
return TRANSLATION_FLOW_TEMPLATE_LITERAL_PATTERN.test(value.trim());
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4342
4374
|
//#endregion
|
|
4343
4375
|
//#region src/utils/parseFlowTemplateLiteral.ts
|
|
4344
4376
|
/**
|
|
@@ -4425,6 +4457,13 @@ function parseFlowTemplateLiteral(content) {
|
|
|
4425
4457
|
*/
|
|
4426
4458
|
const FLOW_TEMPLATE_LITERAL_REGEX_GLOBAL = new RegExp(FLOW_TEMPLATE_LITERAL_REGEX.source, "g");
|
|
4427
4459
|
/**
|
|
4460
|
+
* Resolves a `{{ t(key) }}` translation key, converting its colon-separated namespace to dots
|
|
4461
|
+
* e.g. "signin:fields.password.label" → "signin.fields.password.label".
|
|
4462
|
+
*/
|
|
4463
|
+
function resolveTranslation(key, t) {
|
|
4464
|
+
return t(key.replace(/:/g, "."));
|
|
4465
|
+
}
|
|
4466
|
+
/**
|
|
4428
4467
|
* Resolves all flow template literal expressions in a string.
|
|
4429
4468
|
*
|
|
4430
4469
|
* Supported patterns:
|
|
@@ -4437,6 +4476,9 @@ const FLOW_TEMPLATE_LITERAL_REGEX_GLOBAL = new RegExp(FLOW_TEMPLATE_LITERAL_REGE
|
|
|
4437
4476
|
* Flow template literals can be embedded inside larger strings:
|
|
4438
4477
|
* `"Login using {{ meta(application.name) }}"` → `"Login using My App"`
|
|
4439
4478
|
*
|
|
4479
|
+
* A meta field can itself hold a translation reference instead of final display text — that case is
|
|
4480
|
+
* detected and resolved via `t()` too, so the raw template never reaches the screen.
|
|
4481
|
+
*
|
|
4440
4482
|
* Unrecognized expressions are left unchanged.
|
|
4441
4483
|
*
|
|
4442
4484
|
* @template TFn - The concrete translation function type.
|
|
@@ -4449,8 +4491,15 @@ function resolveFlowTemplateLiterals(text, { t, meta }) {
|
|
|
4449
4491
|
if (!text) return "";
|
|
4450
4492
|
return text.replace(FLOW_TEMPLATE_LITERAL_REGEX_GLOBAL, (match, content) => {
|
|
4451
4493
|
const parsed = parseFlowTemplateLiteral(content.trim());
|
|
4452
|
-
if (parsed.type === FlowTemplateLiteralType.TRANSLATION && parsed.key) return
|
|
4453
|
-
if (parsed.type === FlowTemplateLiteralType.META && parsed.key && meta)
|
|
4494
|
+
if (parsed.type === FlowTemplateLiteralType.TRANSLATION && parsed.key) return resolveTranslation(parsed.key, t);
|
|
4495
|
+
if (parsed.type === FlowTemplateLiteralType.META && parsed.key && meta) {
|
|
4496
|
+
const value = resolveMeta(parsed.key, meta);
|
|
4497
|
+
if (isTranslationFlowTemplateLiteral(value)) {
|
|
4498
|
+
const innerKey = value.trim().match(TRANSLATION_FLOW_TEMPLATE_LITERAL_KEY_PATTERN)[1];
|
|
4499
|
+
return resolveTranslation(innerKey, t);
|
|
4500
|
+
}
|
|
4501
|
+
return value;
|
|
4502
|
+
}
|
|
4454
4503
|
return match;
|
|
4455
4504
|
});
|
|
4456
4505
|
}
|
|
@@ -4558,23 +4607,6 @@ var resolveLocaleEmoji_default = resolveLocaleEmoji;
|
|
|
4558
4607
|
//#endregion
|
|
4559
4608
|
//#region src/utils/getBaseLanguage.ts
|
|
4560
4609
|
/**
|
|
4561
|
-
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
4562
|
-
*
|
|
4563
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
4564
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
4565
|
-
* in compliance with the License.
|
|
4566
|
-
* You may obtain a copy of the License at
|
|
4567
|
-
*
|
|
4568
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4569
|
-
*
|
|
4570
|
-
* Unless required by applicable law or agreed to in writing,
|
|
4571
|
-
* software distributed under the License is distributed on an
|
|
4572
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
4573
|
-
* KIND, either express or implied. See the License for the
|
|
4574
|
-
* specific language governing permissions and limitations
|
|
4575
|
-
* under the License.
|
|
4576
|
-
*/
|
|
4577
|
-
/**
|
|
4578
4610
|
* Resolves a BCP 47 locale tag to its base (primary) language subtag, so that
|
|
4579
4611
|
* region-qualified tags compare equal to their bare form (e.g. "en-US" and "en"
|
|
4580
4612
|
* both resolve to "en"). Uses `Intl.Locale` when available, falling back to a
|
|
@@ -4601,23 +4633,6 @@ function getBaseLanguage(tag) {
|
|
|
4601
4633
|
//#endregion
|
|
4602
4634
|
//#region src/utils/normalizeLocaleTag.ts
|
|
4603
4635
|
/**
|
|
4604
|
-
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
4605
|
-
*
|
|
4606
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
4607
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
4608
|
-
* in compliance with the License.
|
|
4609
|
-
* You may obtain a copy of the License at
|
|
4610
|
-
*
|
|
4611
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4612
|
-
*
|
|
4613
|
-
* Unless required by applicable law or agreed to in writing,
|
|
4614
|
-
* software distributed under the License is distributed on an
|
|
4615
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
4616
|
-
* KIND, either express or implied. See the License for the
|
|
4617
|
-
* specific language governing permissions and limitations
|
|
4618
|
-
* under the License.
|
|
4619
|
-
*/
|
|
4620
|
-
/**
|
|
4621
4636
|
* Lowercases the language subtag and uppercases a 2-letter region subtag (the common
|
|
4622
4637
|
* `language-REGION` shape), leaving everything else as-is. Not a full BCP 47 canonicalizer,
|
|
4623
4638
|
* but deterministic and dependency-free, so case-only differences still compare equal without
|
package/dist/index.js
CHANGED
|
@@ -4339,6 +4339,38 @@ function resolveMeta(path, meta) {
|
|
|
4339
4339
|
return value != null ? String(value) : "";
|
|
4340
4340
|
}
|
|
4341
4341
|
|
|
4342
|
+
//#endregion
|
|
4343
|
+
//#region src/utils/isTranslationFlowTemplateLiteral.ts
|
|
4344
|
+
/**
|
|
4345
|
+
* Regular expression to match a translation flow template literal `{{t(key)}}` (exact, full-string match).
|
|
4346
|
+
* Optional whitespace around `{{` / `}}` is allowed.
|
|
4347
|
+
*/
|
|
4348
|
+
const TRANSLATION_FLOW_TEMPLATE_LITERAL_PATTERN = /^\{\{\s*t\([^)]+\)\s*\}\}$/;
|
|
4349
|
+
/**
|
|
4350
|
+
* Regular expression to extract the key from a translation flow template literal `{{t(key)}}`.
|
|
4351
|
+
*/
|
|
4352
|
+
const TRANSLATION_FLOW_TEMPLATE_LITERAL_KEY_PATTERN = /^\{\{\s*t\(([^)]+)\)\s*\}\}$/;
|
|
4353
|
+
/**
|
|
4354
|
+
* Check if a string is exactly a translation flow template literal (`{{ t(key) }}`).
|
|
4355
|
+
*
|
|
4356
|
+
* This checks that the **entire** string is the template pattern. Use
|
|
4357
|
+
* {@link FLOW_TEMPLATE_LITERAL_REGEX} from `parseFlowTemplateLiteral` to detect
|
|
4358
|
+
* templates embedded inside a larger string.
|
|
4359
|
+
*
|
|
4360
|
+
* @param value - The string to test.
|
|
4361
|
+
* @returns `true` if the trimmed value matches the pattern, `false` otherwise.
|
|
4362
|
+
*
|
|
4363
|
+
* @example
|
|
4364
|
+
* ```typescript
|
|
4365
|
+
* isTranslationFlowTemplateLiteral('{{ t(signin:heading) }}') // true
|
|
4366
|
+
* isTranslationFlowTemplateLiteral('hello world') // false
|
|
4367
|
+
* isTranslationFlowTemplateLiteral('Login via {{ t(key) }}') // false — embedded, not exact
|
|
4368
|
+
* ```
|
|
4369
|
+
*/
|
|
4370
|
+
function isTranslationFlowTemplateLiteral(value) {
|
|
4371
|
+
return TRANSLATION_FLOW_TEMPLATE_LITERAL_PATTERN.test(value.trim());
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4342
4374
|
//#endregion
|
|
4343
4375
|
//#region src/utils/parseFlowTemplateLiteral.ts
|
|
4344
4376
|
/**
|
|
@@ -4425,6 +4457,13 @@ function parseFlowTemplateLiteral(content) {
|
|
|
4425
4457
|
*/
|
|
4426
4458
|
const FLOW_TEMPLATE_LITERAL_REGEX_GLOBAL = new RegExp(FLOW_TEMPLATE_LITERAL_REGEX.source, "g");
|
|
4427
4459
|
/**
|
|
4460
|
+
* Resolves a `{{ t(key) }}` translation key, converting its colon-separated namespace to dots
|
|
4461
|
+
* e.g. "signin:fields.password.label" → "signin.fields.password.label".
|
|
4462
|
+
*/
|
|
4463
|
+
function resolveTranslation(key, t) {
|
|
4464
|
+
return t(key.replace(/:/g, "."));
|
|
4465
|
+
}
|
|
4466
|
+
/**
|
|
4428
4467
|
* Resolves all flow template literal expressions in a string.
|
|
4429
4468
|
*
|
|
4430
4469
|
* Supported patterns:
|
|
@@ -4437,6 +4476,9 @@ const FLOW_TEMPLATE_LITERAL_REGEX_GLOBAL = new RegExp(FLOW_TEMPLATE_LITERAL_REGE
|
|
|
4437
4476
|
* Flow template literals can be embedded inside larger strings:
|
|
4438
4477
|
* `"Login using {{ meta(application.name) }}"` → `"Login using My App"`
|
|
4439
4478
|
*
|
|
4479
|
+
* A meta field can itself hold a translation reference instead of final display text — that case is
|
|
4480
|
+
* detected and resolved via `t()` too, so the raw template never reaches the screen.
|
|
4481
|
+
*
|
|
4440
4482
|
* Unrecognized expressions are left unchanged.
|
|
4441
4483
|
*
|
|
4442
4484
|
* @template TFn - The concrete translation function type.
|
|
@@ -4449,8 +4491,15 @@ function resolveFlowTemplateLiterals(text, { t, meta }) {
|
|
|
4449
4491
|
if (!text) return "";
|
|
4450
4492
|
return text.replace(FLOW_TEMPLATE_LITERAL_REGEX_GLOBAL, (match, content) => {
|
|
4451
4493
|
const parsed = parseFlowTemplateLiteral(content.trim());
|
|
4452
|
-
if (parsed.type === FlowTemplateLiteralType.TRANSLATION && parsed.key) return
|
|
4453
|
-
if (parsed.type === FlowTemplateLiteralType.META && parsed.key && meta)
|
|
4494
|
+
if (parsed.type === FlowTemplateLiteralType.TRANSLATION && parsed.key) return resolveTranslation(parsed.key, t);
|
|
4495
|
+
if (parsed.type === FlowTemplateLiteralType.META && parsed.key && meta) {
|
|
4496
|
+
const value = resolveMeta(parsed.key, meta);
|
|
4497
|
+
if (isTranslationFlowTemplateLiteral(value)) {
|
|
4498
|
+
const innerKey = value.trim().match(TRANSLATION_FLOW_TEMPLATE_LITERAL_KEY_PATTERN)[1];
|
|
4499
|
+
return resolveTranslation(innerKey, t);
|
|
4500
|
+
}
|
|
4501
|
+
return value;
|
|
4502
|
+
}
|
|
4454
4503
|
return match;
|
|
4455
4504
|
});
|
|
4456
4505
|
}
|
|
@@ -4558,23 +4607,6 @@ var resolveLocaleEmoji_default = resolveLocaleEmoji;
|
|
|
4558
4607
|
//#endregion
|
|
4559
4608
|
//#region src/utils/getBaseLanguage.ts
|
|
4560
4609
|
/**
|
|
4561
|
-
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
4562
|
-
*
|
|
4563
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
4564
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
4565
|
-
* in compliance with the License.
|
|
4566
|
-
* You may obtain a copy of the License at
|
|
4567
|
-
*
|
|
4568
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4569
|
-
*
|
|
4570
|
-
* Unless required by applicable law or agreed to in writing,
|
|
4571
|
-
* software distributed under the License is distributed on an
|
|
4572
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
4573
|
-
* KIND, either express or implied. See the License for the
|
|
4574
|
-
* specific language governing permissions and limitations
|
|
4575
|
-
* under the License.
|
|
4576
|
-
*/
|
|
4577
|
-
/**
|
|
4578
4610
|
* Resolves a BCP 47 locale tag to its base (primary) language subtag, so that
|
|
4579
4611
|
* region-qualified tags compare equal to their bare form (e.g. "en-US" and "en"
|
|
4580
4612
|
* both resolve to "en"). Uses `Intl.Locale` when available, falling back to a
|
|
@@ -4601,23 +4633,6 @@ function getBaseLanguage(tag) {
|
|
|
4601
4633
|
//#endregion
|
|
4602
4634
|
//#region src/utils/normalizeLocaleTag.ts
|
|
4603
4635
|
/**
|
|
4604
|
-
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
4605
|
-
*
|
|
4606
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
4607
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
4608
|
-
* in compliance with the License.
|
|
4609
|
-
* You may obtain a copy of the License at
|
|
4610
|
-
*
|
|
4611
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4612
|
-
*
|
|
4613
|
-
* Unless required by applicable law or agreed to in writing,
|
|
4614
|
-
* software distributed under the License is distributed on an
|
|
4615
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
4616
|
-
* KIND, either express or implied. See the License for the
|
|
4617
|
-
* specific language governing permissions and limitations
|
|
4618
|
-
* under the License.
|
|
4619
|
-
*/
|
|
4620
|
-
/**
|
|
4621
4636
|
* Lowercases the language subtag and uppercases a 2-letter region subtag (the common
|
|
4622
4637
|
* `language-REGION` shape), leaving everything else as-is. Not a full BCP 47 canonicalizer,
|
|
4623
4638
|
* but deterministic and dependency-free, so case-only differences still compare equal without
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
-
*
|
|
4
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
-
* in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing,
|
|
12
|
-
* software distributed under the License is distributed on an
|
|
13
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
* KIND, either express or implied. See the License for the
|
|
15
|
-
* specific language governing permissions and limitations
|
|
16
|
-
* under the License.
|
|
17
|
-
*/
|
|
18
1
|
/**
|
|
19
2
|
* Resolves a BCP 47 locale tag to its base (primary) language subtag, so that
|
|
20
3
|
* region-qualified tags compare equal to their bare form (e.g. "en-US" and "en"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBaseLanguage.d.ts","sourceRoot":"","sources":["../../src/utils/getBaseLanguage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBaseLanguage.d.ts","sourceRoot":"","sources":["../../src/utils/getBaseLanguage.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM3D"}
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
-
*
|
|
4
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
-
* in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing,
|
|
12
|
-
* software distributed under the License is distributed on an
|
|
13
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
* KIND, either express or implied. See the License for the
|
|
15
|
-
* specific language governing permissions and limitations
|
|
16
|
-
* under the License.
|
|
17
|
-
*/
|
|
18
1
|
/**
|
|
19
2
|
* Resolves a BCP 47 locale tag to its canonical form, so tags that differ only in casing or
|
|
20
3
|
* separator style compare equal (e.g. "en-us" and "en-US"). Uses `Intl.Locale` when available;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeLocaleTag.d.ts","sourceRoot":"","sources":["../../src/utils/normalizeLocaleTag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalizeLocaleTag.d.ts","sourceRoot":"","sources":["../../src/utils/normalizeLocaleTag.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM9D"}
|
|
@@ -13,6 +13,9 @@ import { ResolveFlowTemplateLiteralsOptions } from '../models/vars';
|
|
|
13
13
|
* Flow template literals can be embedded inside larger strings:
|
|
14
14
|
* `"Login using {{ meta(application.name) }}"` → `"Login using My App"`
|
|
15
15
|
*
|
|
16
|
+
* A meta field can itself hold a translation reference instead of final display text — that case is
|
|
17
|
+
* detected and resolved via `t()` too, so the raw template never reaches the screen.
|
|
18
|
+
*
|
|
16
19
|
* Unrecognized expressions are left unchanged.
|
|
17
20
|
*
|
|
18
21
|
* @template TFn - The concrete translation function type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveFlowTemplateLiterals.d.ts","sourceRoot":"","sources":["../../src/utils/resolveFlowTemplateLiterals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveFlowTemplateLiterals.d.ts","sourceRoot":"","sources":["../../src/utils/resolveFlowTemplateLiterals.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,kCAAkC,EAAC,MAAM,gBAAgB,CAAC;AAelE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,OAAO,UAAU,2BAA2B,CAAC,GAAG,SAAS,aAAa,GAAG,aAAa,EAC3F,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,EAAC,CAAC,EAAE,IAAI,EAAC,EAAE,kCAAkC,CAAC,GAAG,CAAC,GACjD,MAAM,CAyBR"}
|