@designcrowd/library.brand-page 5.10.39 → 5.10.40
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/lib/src/composables/useTranslate.d.ts +1 -1
- package/lib/src/composables/useTranslate.js +9 -4
- package/lib/src/index.mjs +15589 -15586
- package/package.json +1 -1
- package/src/composables/useTranslate.ts +16 -4
package/package.json
CHANGED
|
@@ -2,6 +2,8 @@ import i18next from 'i18next';
|
|
|
2
2
|
import { setSharedLibLocaleAsync } from '@designcrowd/fe-shared-lib';
|
|
3
3
|
import { getCurrentInstance } from 'vue';
|
|
4
4
|
|
|
5
|
+
const nameSpace = 'bp';
|
|
6
|
+
|
|
5
7
|
const fallbackLocale = 'en-US';
|
|
6
8
|
|
|
7
9
|
export type LocaleTypes = 'de-DE' | 'en-US' | 'fr-FR' | 'es-ES' | 'pt-PT';
|
|
@@ -57,13 +59,23 @@ const setLocaleAsync = async (locale?: LocaleTypes) => {
|
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
await i18.addResourceBundle(localeToUse,
|
|
62
|
+
await i18.addResourceBundle(localeToUse, nameSpace, { ...languageFile });
|
|
61
63
|
|
|
62
64
|
await setSharedLibLocaleAsync(localeToUse);
|
|
63
65
|
};
|
|
64
66
|
|
|
65
|
-
const tr = (
|
|
66
|
-
|
|
67
|
+
const tr = (
|
|
68
|
+
key: string,
|
|
69
|
+
valuesToInterpolate = {},
|
|
70
|
+
returnEmptyIfNotExist = false,
|
|
71
|
+
) => {
|
|
72
|
+
const instance = getI18NextInstance();
|
|
73
|
+
|
|
74
|
+
if (returnEmptyIfNotExist && !instance.exists(key, { ns: nameSpace })) {
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const translated = instance.t(key, {
|
|
67
79
|
ns: nameSpace,
|
|
68
80
|
...valuesToInterpolate,
|
|
69
81
|
});
|
|
@@ -136,7 +148,7 @@ const publishBrandPageModalWithStateTr = (key, valuesToInterpolate = {}) =>
|
|
|
136
148
|
tr(`publishBrandPageModalWithState.${key}`, valuesToInterpolate);
|
|
137
149
|
const existingDomainModalTr = (key) => tr(`existingDomainModal.${key}`);
|
|
138
150
|
const sensitiveContentModalTr = (key, valuesToInterpolate = {}) =>
|
|
139
|
-
tr(`sensitiveContentModal.${key}`, valuesToInterpolate);
|
|
151
|
+
tr(`sensitiveContentModal.${key}`, valuesToInterpolate, true);
|
|
140
152
|
const quickLinkBarTr = (key) => tr(`quickLinkBar.${key}`);
|
|
141
153
|
|
|
142
154
|
export {
|