@designcrowd/fe-shared-lib 1.2.0-tr-2 → 1.2.0-tr-3
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/Dockerfile +2 -0
- package/nodemon.translation.json +7 -0
- package/package.json +6 -2
- package/src/bundleTranslation.js +79 -0
- package/src/bundles/bundled-translations.json +3 -0
- package/src/bundles/bundled-translations_de-DE.json +3 -0
- package/src/bundles/bundled-translations_es-ES.json +3 -0
- package/src/bundles/bundled-translations_fr-FR.json +3 -0
- package/src/bundles/bundled-translations_pt-PT.json +3 -0
- package/src/experiences/components/PublishBrandPageModal/PublishBrandPageModal.vue +0 -8
- package/src/experiences/components/PublishBrandPageModal/i18n/publish-translation.json +3 -0
- package/src/experiences/components/PublishBrandPageModal/i18n/publish-translation_de-DE.json +3 -0
- package/src/experiences/components/PublishBrandPageModal/i18n/publish-translation_es-ES.json +3 -0
- package/src/experiences/components/PublishBrandPageModal/i18n/publish-translation_fr-FR.json +3 -0
- package/src/experiences/components/PublishBrandPageModal/i18n/publish-translation_pt-PT.json +3 -0
- package/src/useSharedLibTranslate.js +12 -4
package/Dockerfile
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designcrowd/fe-shared-lib",
|
|
3
|
-
"version": "1.2.0-tr-
|
|
3
|
+
"version": "1.2.0-tr-3",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"start": "
|
|
5
|
+
"start": "run-p storybook watch:translation",
|
|
6
6
|
"build": "npm run build:css --production",
|
|
7
7
|
"storybook": "export NODE_ENV=development && npm run storybook:css && npm run storybook:themes && storybook dev -p 6006 public",
|
|
8
8
|
"build:css": "node ./tailwind.build.js",
|
|
9
9
|
"build:storybook": "mkdir -p public && mkdir -p public/css && npm run storybook:css && storybook build -c .storybook -o .storybook-static && cp -R ./public/css .storybook-static/",
|
|
10
|
+
"bundle-translation": "node ./src/bundleTranslation.js",
|
|
11
|
+
"watch:translation": "nodemon --config nodemon.translation.json",
|
|
10
12
|
"storybook:themes": "node ./tailwind.themes.js",
|
|
11
13
|
"storybook:css": "node ./tailwind.build.js --storybook",
|
|
12
14
|
"lint": "NODE_ENV=production eslint ./src/ --ext .ts,.js,.vue",
|
|
@@ -63,6 +65,8 @@
|
|
|
63
65
|
"eslint-plugin-vue": "9.21.1",
|
|
64
66
|
"husky": "9.0.10",
|
|
65
67
|
"lint-staged": "15.2.1",
|
|
68
|
+
"nodemon": "3.0.3",
|
|
69
|
+
"npm-run-all": "4.1.5",
|
|
66
70
|
"postcss": "8.4.33",
|
|
67
71
|
"postcss-cli": "11.0.0",
|
|
68
72
|
"postcss-import": "16.0.0",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
|
|
4
|
+
const localeSuffixes = ['_de-DE', '_fr-FR', '_es-ES', '_pt-PT', ''];
|
|
5
|
+
|
|
6
|
+
const findTranslationFiles = (dir, localeString) => {
|
|
7
|
+
const files = [];
|
|
8
|
+
const entries = fs.readdirSync(dir);
|
|
9
|
+
|
|
10
|
+
entries.forEach((entry) => {
|
|
11
|
+
const fullPath = path.join(dir, entry);
|
|
12
|
+
|
|
13
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
14
|
+
if (entry === 'i18n') {
|
|
15
|
+
files.push(
|
|
16
|
+
...fs
|
|
17
|
+
.readdirSync(fullPath)
|
|
18
|
+
.filter((file) => file.endsWith(`translation${localeString}.json`))
|
|
19
|
+
.map((file) => path.join(fullPath, file)),
|
|
20
|
+
);
|
|
21
|
+
} else {
|
|
22
|
+
// Recursively find translation files in nested folders
|
|
23
|
+
files.push(...findTranslationFiles(fullPath, localeString));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return files;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const bundle = () => {
|
|
32
|
+
console.log('Bundling translations...', __dirname);
|
|
33
|
+
|
|
34
|
+
const bundlesDir = path.resolve(__dirname, './bundles');
|
|
35
|
+
|
|
36
|
+
console.log('bundlesDir', bundlesDir);
|
|
37
|
+
|
|
38
|
+
if (!fs.existsSync(bundlesDir)) {
|
|
39
|
+
console.log('Creating bundles dir');
|
|
40
|
+
fs.mkdirSync(bundlesDir);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const rootDir = path.resolve(__dirname, '../src');
|
|
44
|
+
|
|
45
|
+
localeSuffixes.forEach((locale) => {
|
|
46
|
+
const outputFile = path.resolve(bundlesDir, `bundled-translations${locale}.json`);
|
|
47
|
+
|
|
48
|
+
const translationFiles = findTranslationFiles(rootDir, locale);
|
|
49
|
+
|
|
50
|
+
console.log(
|
|
51
|
+
`Found ${translationFiles.length} translation files in BrandPage for file prefix: ${`bundled-translations${locale}.json`}`,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const translations = {};
|
|
55
|
+
|
|
56
|
+
translationFiles.forEach((file) => {
|
|
57
|
+
const fileContent = fs.readFileSync(file, 'utf-8');
|
|
58
|
+
|
|
59
|
+
Object.assign(translations, JSON.parse(fileContent));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
console.log(`Writing bundled translations to: ${outputFile}`);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const potentiallyExistingFile = fs.readFileSync(outputFile, 'utf-8');
|
|
66
|
+
|
|
67
|
+
if (potentiallyExistingFile === JSON.stringify(translations, null, 2)) {
|
|
68
|
+
console.log('Current translations are the same as the existing file - skipping write');
|
|
69
|
+
} else {
|
|
70
|
+
fs.writeFileSync(outputFile, JSON.stringify(translations, null, 2));
|
|
71
|
+
}
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.log("Translation file doesn't exist, creating new one");
|
|
74
|
+
fs.writeFileSync(outputFile, JSON.stringify(translations, null, 2));
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
bundle();
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
@close-modal="onCloseModal"
|
|
11
11
|
>
|
|
12
12
|
<template #header>
|
|
13
|
-
Here: {{ tr('testmessage') }}
|
|
14
13
|
<div v-if="isNotPublished || isSlugEditMode" class="tw-text-center tw-font-bold tw-mb-8 tw-mt-8 tw-text-4xl">
|
|
15
14
|
<span>Set the URL for your {{ brandPageDisplayName }}</span>
|
|
16
15
|
</div>
|
|
@@ -259,7 +258,6 @@ import SellDomainNameListModal from '../SellDomainNameListModal/SellDomainNameLi
|
|
|
259
258
|
import brandCrowdApiClient from '../../clients/brand-crowd-api.client';
|
|
260
259
|
import Events, { sitePublishedModal } from '../../constants/event-constants';
|
|
261
260
|
import mediaQueryMixin from '../../mixins/mediaQueryMixin';
|
|
262
|
-
import { tr } from '../../../useSharedLibTranslate';
|
|
263
261
|
|
|
264
262
|
const headerSubtitle = 'Buy matching domain name for your brand';
|
|
265
263
|
|
|
@@ -414,12 +412,6 @@ export default {
|
|
|
414
412
|
'on-view-more-domains',
|
|
415
413
|
'on-slug-changed',
|
|
416
414
|
],
|
|
417
|
-
setup() {
|
|
418
|
-
console.log('tttr', tr, tr('testmessage'));
|
|
419
|
-
return {
|
|
420
|
-
tr,
|
|
421
|
-
};
|
|
422
|
-
},
|
|
423
415
|
data() {
|
|
424
416
|
return {
|
|
425
417
|
DOMAIN_TYPES,
|
|
@@ -3,7 +3,15 @@ import i18next from 'i18next';
|
|
|
3
3
|
|
|
4
4
|
const fallbackLocale = 'en-US';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const relativePathsToTranslationFiles = {
|
|
7
|
+
'en-US': () => import('./bundles/bundled-translations.json'),
|
|
8
|
+
'de-DE': () => import('./bundles/bundled-translations_de-DE.json'),
|
|
9
|
+
'fr-FR': () => import('./bundles/bundled-translations_fr-FR.json'),
|
|
10
|
+
'es-ES': () => import('./bundles/bundled-translations_es-ES.json'),
|
|
11
|
+
'pt-PT': () => import('./bundles/bundled-translations_pt-PT.json'),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const setLocaleAsync = async (locale = 'en-US') => {
|
|
7
15
|
const localeToUse = locale;
|
|
8
16
|
|
|
9
17
|
if (!i18next.isInitialized) {
|
|
@@ -14,10 +22,10 @@ const setLocaleAsync = async (locale) => {
|
|
|
14
22
|
});
|
|
15
23
|
}
|
|
16
24
|
|
|
25
|
+
const languageFile = (await relativePathsToTranslationFiles[localeToUse]()).default;
|
|
26
|
+
|
|
17
27
|
await i18next.addResourceBundle(localeToUse, 'fe-shared-lib', {
|
|
18
|
-
...
|
|
19
|
-
testmessage: 'This is a test message from i18',
|
|
20
|
-
},
|
|
28
|
+
...languageFile,
|
|
21
29
|
});
|
|
22
30
|
};
|
|
23
31
|
|