@shift72/core-template 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +49 -7
- package/kibble.json +107 -28
- package/package.json +25 -9
- package/scripts/core-template-version.js +30 -0
- package/scripts/css-local-get.js +34 -0
- package/scripts/css-local-put.js +110 -0
- package/scripts/language-file-to-csv/language-file-to-csv.js +2 -2
- package/scripts/language-file-validator.js +16 -2
- package/scripts/translate.mjs +43 -0
- package/site/ar_LB.all.json +1262 -593
- package/site/ca_ES.all.json +441 -440
- package/site/da_DK.all.json +308 -210
- package/site/de_DE.all.json +1122 -337
- package/site/ee_EE.all.json +1258 -532
- package/site/el_EL.all.json +1116 -394
- package/site/en_AU.all.json +1159 -466
- package/site/es_ES.all.json +1109 -333
- package/site/es_MX.all.json +1173 -332
- package/site/fi_FI.all.json +1127 -315
- package/site/fr_FR.all.json +1109 -332
- package/site/hr_HR.all.json +1173 -411
- package/site/hu_HU.all.json +1258 -531
- package/site/it_IT.all.json +1116 -340
- package/site/ja_JP.all.json +1127 -315
- package/site/lt_LT.all.json +1116 -425
- package/site/nl_BE.all.json +1116 -426
- package/site/no_NO.all.json +1249 -531
- package/site/pl_PL.all.json +1106 -306
- package/site/pt_BR.all.json +438 -446
- package/site/pt_PT.all.json +1249 -527
- package/site/ru_RU.all.json +1092 -386
- package/site/sr_SR.all.json +1254 -0
- package/site/styles/_awards.scss +11 -6
- package/site/styles/_bootstrap4.scss +90 -0
- package/site/styles/_buttons.scss +32 -8
- package/site/styles/_can-be-watched-button.scss +2 -0
- package/site/styles/_card.scss +2 -2
- package/site/styles/_carousel.scss +52 -29
- package/site/styles/_collections.scss +4 -4
- package/site/styles/_cookie-consent.scss +1 -1
- package/site/styles/_devices.scss +3 -3
- package/site/styles/_footer.scss +6 -6
- package/site/styles/_forms.scss +83 -16
- package/site/styles/_globals.scss +1 -1
- package/site/styles/_icons.scss +2 -2
- package/site/styles/_language-selector.scss +2 -2
- package/site/styles/_legacy.scss +3 -3
- package/site/styles/_meta-detail.scss +45 -25
- package/site/styles/_meta-item-tagline.scss +1 -1
- package/site/styles/_mixins.scss +2 -2
- package/site/styles/_nav.scss +40 -40
- package/site/styles/_pages.scss +12 -14
- package/site/styles/_pin-codes.scss +2 -2
- package/site/styles/_plans.scss +6 -1
- package/site/styles/_poster.scss +5 -4
- package/site/styles/_search.scss +1 -1
- package/site/styles/_shift72.scss +24 -24
- package/site/styles/_shopping.scss +9 -9
- package/site/styles/_skip-link.scss +19 -0
- package/site/styles/_slider.scss +4 -10
- package/site/styles/_social-media-buttons.scss +20 -20
- package/site/styles/_swiper.scss +2 -2
- package/site/styles/_variables.scss +112 -83
- package/site/styles/_wishlist.scss +20 -12
- package/site/styles/main.scss +2 -3
- package/site/templates/application/application.jet +24 -15
- package/site/templates/application/google.jet +26 -10
- package/site/templates/bundle/buttons.jet +2 -1
- package/site/templates/bundle/item.jet +1 -2
- package/site/templates/collection/carousel_item.jet +12 -13
- package/site/templates/common/awards/carousel.jet +7 -1
- package/site/templates/common/awards/item.jet +2 -2
- package/site/templates/film/item.jet +92 -61
- package/site/templates/page/curated.jet +1 -1
- package/site/templates/page/page-content.jet +1 -23
- package/site/templates/page/page-header.jet +25 -6
- package/site/templates/tv/detail.jet +7 -7
- package/site/tr_TR.all.json +1249 -535
- package/site/uk_UA.all.json +533 -443
- package/site/zh_TW.all.json +442 -443
- package/site/se_SE.all.json +0 -570
- package/site/styles/_functions.scss +0 -8
package/CHANGELOG.md
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [Unreleased](https://github.com/shift72/core-template/compare/0.
|
3
|
+
## [Unreleased](https://github.com/shift72/core-template/compare/0.5.0...HEAD)
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
## [0.5.0](https://github.com/shift72/core-template/compare/0.4.4...0.5.0)
|
7
|
+
### Changed
|
8
|
+
- Upgrade to kibble `0.16.6`.
|
9
|
+
- Moved references from `film.Images` to `film.ImageMap`.
|
10
|
+
- Removed minimum page height from content pages.
|
11
|
+
- Moved skip link above cookie consent banner
|
12
|
+
|
13
|
+
### Added
|
14
|
+
- Start the site with an admin build: `npm start --admin`.
|
15
|
+
- Added Core template version to `<head>` and `kibble.json`.
|
16
|
+
- Added styling for floating donate button to use button sass variables.
|
17
|
+
- A bunch of missing language keys across language files.
|
18
|
+
- Automated translation command
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
- Can now override the cookie consent styling.
|
22
|
+
- Can now send analytics data to both GA4 and UA Legacy google analytics (GA4 previously not supported)
|
23
|
+
|
24
|
+
|
25
|
+
## [0.4.4](https://github.com/shift72/core-template/compare/0.4.3...0.4.4)
|
26
|
+
### Fixed
|
27
|
+
- Fixed obsolete `$primary` var for trailer button.
|
6
28
|
|
7
29
|
### Added
|
8
|
-
-
|
9
|
-
|
30
|
+
- Awards categories.
|
31
|
+
|
32
|
+
## [0.4.3](https://github.com/shift72/core-template/compare/0.4.2...0.4.3)
|
33
|
+
|
34
|
+
### Added
|
35
|
+
- Awards categories.
|
36
|
+
- Floating donate button.
|
37
|
+
- External custom CSS link in head.
|
38
|
+
- Scripts for downloading/uploading custom CSS files for use with local development.
|
10
39
|
|
11
40
|
### Changed
|
12
|
-
-
|
41
|
+
- Replaced various Sass variables with CSS variables.
|
42
|
+
- Added workarounds for Sass and Bootstrap functions that don't understand CSS variables.
|
43
|
+
- Kibble `0.16.4`.
|
44
|
+
- Split CC and Subtitles.
|
45
|
+
- Moved engagement icons.
|
46
|
+
|
47
|
+
## [0.4.2](https://github.com/shift72/core-template/compare/0.4.1...0.4.2)
|
48
|
+
|
49
|
+
### Added
|
50
|
+
- Lang files updated with entries for purchasing one-off passes.
|
51
|
+
- Sponsor banner.
|
52
|
+
|
53
|
+
### Fixed
|
54
|
+
- Typo in English language file.
|
13
55
|
|
14
56
|
## [0.4.1](https://github.com/shift72/core-template/compare/0.4.0...0.4.1)
|
15
57
|
|
@@ -30,11 +72,11 @@ No changes from RC0.
|
|
30
72
|
|
31
73
|
### Changed
|
32
74
|
- Moved separator line from footer jet into app badge jet.
|
33
|
-
- Kibble upgraded to
|
75
|
+
- Kibble upgraded to `0.15.22`.
|
34
76
|
- Application templates moved to `/site/templates/application/`.
|
35
77
|
- Links (`<a>` tags) without a `class` attribute have `text-decoration: underline`.
|
36
78
|
|
37
|
-
|
79
|
+
### Fixed
|
38
80
|
- Curated pages with a collection no longer has a `min-height` that was forcing a gap before the collection.
|
39
81
|
|
40
82
|
## [0.3.8](https://github.com/shift72/core-template/compare/0.3.7...0.3.8)
|
package/kibble.json
CHANGED
@@ -2,35 +2,113 @@
|
|
2
2
|
"name": "core-template",
|
3
3
|
"version": "0.0.1",
|
4
4
|
"siteUrl": "https://abccinemas.screenplus.co",
|
5
|
-
"builderVersion": "0.
|
5
|
+
"builderVersion": "0.16.6",
|
6
6
|
"defaultLanguage": "en",
|
7
7
|
"languages": {
|
8
|
-
"ar": {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
"
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
"
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
"
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
"
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
"
|
33
|
-
|
8
|
+
"ar": {
|
9
|
+
"code": "ar_LB",
|
10
|
+
"name": "عربى"
|
11
|
+
},
|
12
|
+
"ca": {
|
13
|
+
"code": "ca_ES",
|
14
|
+
"name": "Català"
|
15
|
+
},
|
16
|
+
"da": {
|
17
|
+
"code": "da_DK",
|
18
|
+
"name": "Dansk"
|
19
|
+
},
|
20
|
+
"de": {
|
21
|
+
"code": "de_DE",
|
22
|
+
"name": "Deutsch"
|
23
|
+
},
|
24
|
+
"ee": {
|
25
|
+
"code": "ee_EE",
|
26
|
+
"name": "Eestlane"
|
27
|
+
},
|
28
|
+
"el": {
|
29
|
+
"code": "el_EL",
|
30
|
+
"name": "Ελληνικά"
|
31
|
+
},
|
32
|
+
"en": {
|
33
|
+
"code": "en_AU",
|
34
|
+
"name": "English"
|
35
|
+
},
|
36
|
+
"es": {
|
37
|
+
"code": "es_ES",
|
38
|
+
"name": "Español"
|
39
|
+
},
|
40
|
+
"es-mx": {
|
41
|
+
"code": "es_MX",
|
42
|
+
"name": "Español"
|
43
|
+
},
|
44
|
+
"fi": {
|
45
|
+
"code": "fi_FI",
|
46
|
+
"name": "Suomi"
|
47
|
+
},
|
48
|
+
"fr": {
|
49
|
+
"code": "fr_FR",
|
50
|
+
"name": "Français"
|
51
|
+
},
|
52
|
+
"hr": {
|
53
|
+
"code": "hr_HR",
|
54
|
+
"name": "Hrvatski"
|
55
|
+
},
|
56
|
+
"hu": {
|
57
|
+
"code": "hu_HU",
|
58
|
+
"name": "Magyar"
|
59
|
+
},
|
60
|
+
"it": {
|
61
|
+
"code": "it_IT",
|
62
|
+
"name": "Italiano"
|
63
|
+
},
|
64
|
+
"ja": {
|
65
|
+
"code": "ja_JP",
|
66
|
+
"name": "日本語"
|
67
|
+
},
|
68
|
+
"lt": {
|
69
|
+
"code": "lt_LT",
|
70
|
+
"name": "Lietuvių Kalba"
|
71
|
+
},
|
72
|
+
"nl": {
|
73
|
+
"code": "nl_BE",
|
74
|
+
"name": "Nederlands"
|
75
|
+
},
|
76
|
+
"no": {
|
77
|
+
"code": "no_NO",
|
78
|
+
"name": "Norsk"
|
79
|
+
},
|
80
|
+
"pl": {
|
81
|
+
"code": "pl_PL",
|
82
|
+
"name": "Polski"
|
83
|
+
},
|
84
|
+
"pt": {
|
85
|
+
"code": "pt_PT",
|
86
|
+
"name": "Português"
|
87
|
+
},
|
88
|
+
"pt-br": {
|
89
|
+
"code": "pt_BR",
|
90
|
+
"name": "Português do Brasil"
|
91
|
+
},
|
92
|
+
"ru": {
|
93
|
+
"code": "ru_RU",
|
94
|
+
"name": "Pусский"
|
95
|
+
},
|
96
|
+
"sr": {
|
97
|
+
"code": "sr_SR",
|
98
|
+
"name": "Српски"
|
99
|
+
},
|
100
|
+
"tr": {
|
101
|
+
"code": "tr_TR",
|
102
|
+
"name": "Türk"
|
103
|
+
},
|
104
|
+
"uk": {
|
105
|
+
"code": "uk_UA",
|
106
|
+
"name": "Український"
|
107
|
+
},
|
108
|
+
"zh-tw": {
|
109
|
+
"code": "zh_TW",
|
110
|
+
"name": "中文"
|
111
|
+
}
|
34
112
|
},
|
35
113
|
"siteRootPath": "site",
|
36
114
|
"liveReload": {
|
@@ -106,5 +184,6 @@
|
|
106
184
|
"datasource": "Collection",
|
107
185
|
"pageSize": 0
|
108
186
|
}
|
109
|
-
]
|
187
|
+
],
|
188
|
+
"coreTemplateVersion": "0.5.0"
|
110
189
|
}
|
package/package.json
CHANGED
@@ -1,25 +1,33 @@
|
|
1
1
|
{
|
2
2
|
"name": "@shift72/core-template",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.5.0",
|
4
4
|
"description": "Shift72 core template",
|
5
5
|
"license": "MIT",
|
6
6
|
"scripts": {
|
7
|
-
"start": "
|
8
|
-
"init": "
|
7
|
+
"start": "run-s -l init && run-p -l css:watch js:watch kibble:start",
|
8
|
+
"init": "run-p -l css css:local:get js",
|
9
9
|
"css": "sass ./site/styles/main.scss ./site/static/styles/main.css --load-path=node_modules",
|
10
10
|
"css:lint": "prettier 'site/styles/*.scss' --write && stylelint ./site/styles/*.scss --fix",
|
11
11
|
"css:watch": "npm run css -- --watch",
|
12
12
|
"css:build": "postcss ./site/static/styles/main.css --use autoprefixer --use cssnano -r",
|
13
|
+
"css:local:get": "node scripts/css-local-get.js",
|
14
|
+
"css:local:put": "node scripts/css-local-put.js",
|
13
15
|
"js": "rollup -c",
|
14
|
-
"js:lint": "prettier '{scripts,site/static/js}/**/!(modernizr-custom)
|
16
|
+
"js:lint": "prettier '{scripts,site/static/js}/**/!(modernizr-custom).*js' --write && eslint ./site/static/js/*.*js ./scripts --fix",
|
15
17
|
"js:watch": "rollup -c -w",
|
16
18
|
"js:build": "rollup -c",
|
17
19
|
"kibble": "kibble render",
|
20
|
+
"kibble:start": "mkdir -p .kibble && test -n \"$npm_config_admin\" && npm run kibble:watch -- --admin || npm run kibble:watch",
|
18
21
|
"kibble:watch": "kibble render --watch --port 8081",
|
19
22
|
"kibble:build": "kibble publish",
|
20
|
-
"build": "
|
23
|
+
"build": "run-s -l css js:build css:build kibble:build",
|
21
24
|
"language:csv": "node scripts/language-file-to-csv/language-file-to-csv.js site/en_AU.all.json",
|
22
|
-
"language:validate": "node scripts/language-file-validator.js"
|
25
|
+
"language:validate": "node scripts/language-file-validator.js",
|
26
|
+
"version": "node scripts/core-template-version.js",
|
27
|
+
"prestart": "npm run version",
|
28
|
+
"prebuild": "npm run version",
|
29
|
+
"prepare": "npm run version",
|
30
|
+
"translate": "node scripts/translate.mjs"
|
23
31
|
},
|
24
32
|
"repository": {
|
25
33
|
"type": "git",
|
@@ -34,7 +42,7 @@
|
|
34
42
|
"dependencies": {
|
35
43
|
"@rollup/plugin-buble": "^0.21.3",
|
36
44
|
"autoprefixer": "^7.1.2",
|
37
|
-
"bootstrap": "^4.
|
45
|
+
"bootstrap": "^4.6.1",
|
38
46
|
"concat": "^1.0.3",
|
39
47
|
"cssnano": "^5.0.8",
|
40
48
|
"del": "^6.0.0",
|
@@ -45,7 +53,7 @@
|
|
45
53
|
"postcss-cli": "^9.0.1",
|
46
54
|
"rollup": "^2.23.0",
|
47
55
|
"rollup-plugin-terser": "^6.1.0",
|
48
|
-
"s72-kibble": "^0.
|
56
|
+
"s72-kibble": "^0.16.6",
|
49
57
|
"sass": "^1.36.0"
|
50
58
|
},
|
51
59
|
"devDependencies": {
|
@@ -55,14 +63,22 @@
|
|
55
63
|
"eslint-plugin-compat": "^3.13.0",
|
56
64
|
"eslint-plugin-react": "^7.26.1",
|
57
65
|
"eslint-plugin-react-hooks": "^4.2.0",
|
66
|
+
"form-data": "^4.0.0",
|
58
67
|
"prettier": "^2.3.2",
|
59
68
|
"stylelint": "^13.13.1",
|
60
69
|
"stylelint-config-prettier": "^8.0.2",
|
61
70
|
"stylelint-config-sass-guidelines": "^8.0.0",
|
62
71
|
"stylelint-prettier": "^1.2.0",
|
63
|
-
"stylelint-scss": "^3.19.0"
|
72
|
+
"stylelint-scss": "^3.19.0",
|
73
|
+
"glob": "^7.2.0",
|
74
|
+
"node-fetch": "^3.2.3"
|
64
75
|
},
|
65
76
|
"eslintConfig": {
|
77
|
+
"settings": {
|
78
|
+
"jest": {
|
79
|
+
"version": 26
|
80
|
+
}
|
81
|
+
},
|
66
82
|
"env": {
|
67
83
|
"browser": true,
|
68
84
|
"es6": true
|
@@ -0,0 +1,30 @@
|
|
1
|
+
const fs = require('fs');
|
2
|
+
|
3
|
+
let version, kibbleJSON;
|
4
|
+
|
5
|
+
try {
|
6
|
+
version = JSON.parse(fs.readFileSync('package.json'))['version'];
|
7
|
+
} catch(e) {
|
8
|
+
exitWithError(`Failed to parse package.json: ${e}`);
|
9
|
+
}
|
10
|
+
|
11
|
+
try {
|
12
|
+
kibbleJSON = JSON.parse(fs.readFileSync('kibble.json'));
|
13
|
+
} catch(e) {
|
14
|
+
exitWithError(`Failed to parse kibble.json: ${e}`);
|
15
|
+
}
|
16
|
+
|
17
|
+
kibbleJSON['coreTemplateVersion'] = version;
|
18
|
+
|
19
|
+
try {
|
20
|
+
fs.writeFileSync('kibble.json', JSON.stringify(kibbleJSON, null, 2));
|
21
|
+
} catch(e) {
|
22
|
+
exitWithError(`Failed to write kibble.json: ${e}`);
|
23
|
+
}
|
24
|
+
|
25
|
+
console.log(`Core-Template Version ${version} written to kibble.json`);
|
26
|
+
|
27
|
+
function exitWithError(message) {
|
28
|
+
console.error(message);
|
29
|
+
process.exit();
|
30
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
const https = require('https');
|
2
|
+
const fs = require('fs');
|
3
|
+
|
4
|
+
const siteUrl = readJsonValueFromRawData('siteUrl', fs.readFileSync('kibble.json'));
|
5
|
+
const file = fs.createWriteStream('site/static/styles/local.css');
|
6
|
+
|
7
|
+
https.get(`${siteUrl}/services/users/v1/css`, handleFilenameResponse).on('error', handleError);
|
8
|
+
|
9
|
+
///////////////////////////////////////////////////////////////////////////////////////////////
|
10
|
+
|
11
|
+
function readJsonValueFromRawData(key, rawJson) {
|
12
|
+
let json = JSON.parse(rawJson);
|
13
|
+
return json[key];
|
14
|
+
}
|
15
|
+
|
16
|
+
function handleFilenameResponse(res) {
|
17
|
+
res.on('data', d => {
|
18
|
+
const filename = readJsonValueFromRawData('css_filename', d);
|
19
|
+
|
20
|
+
if (filename) {
|
21
|
+
https.get(`${siteUrl}/styles/${filename}`, handleFileResponse).on('error', handleError);
|
22
|
+
} else {
|
23
|
+
console.log('Custom CSS not found');
|
24
|
+
}
|
25
|
+
});
|
26
|
+
}
|
27
|
+
|
28
|
+
function handleFileResponse(res) {
|
29
|
+
res.pipe(file);
|
30
|
+
}
|
31
|
+
|
32
|
+
function handleError(e) {
|
33
|
+
console.error(e);
|
34
|
+
}
|
@@ -0,0 +1,110 @@
|
|
1
|
+
const https = require('https');
|
2
|
+
const fs = require('fs');
|
3
|
+
const FormData = require('form-data');
|
4
|
+
const rl = require('readline').createInterface({
|
5
|
+
input: process.stdin,
|
6
|
+
output: process.stdout,
|
7
|
+
});
|
8
|
+
|
9
|
+
const siteUrl = readJsonValueFromRawData('siteUrl', fs.readFileSync('kibble.json'));
|
10
|
+
const url = new URL(siteUrl);
|
11
|
+
|
12
|
+
rl.question(`Enter Username for ${siteUrl}: `, username => {
|
13
|
+
rl.question('Enter Password: ', password => {
|
14
|
+
rl.close();
|
15
|
+
|
16
|
+
return signin(username, password)
|
17
|
+
.then(authToken => {
|
18
|
+
return uploadCSS(authToken);
|
19
|
+
})
|
20
|
+
.then(filename => {
|
21
|
+
console.log(`CSS file upload success: https://${url.hostname}/styles/${filename}`);
|
22
|
+
})
|
23
|
+
.catch(handleError);
|
24
|
+
});
|
25
|
+
});
|
26
|
+
|
27
|
+
///////////////////////////////////////////////////////////////////////////////////////////////
|
28
|
+
|
29
|
+
function uploadCSS(authToken) {
|
30
|
+
return new Promise((resolve, reject) => {
|
31
|
+
let form = new FormData();
|
32
|
+
form.append('file', fs.createReadStream('site/static/styles/local.css'), {
|
33
|
+
filename: 'local.css',
|
34
|
+
contentType: 'text/css',
|
35
|
+
});
|
36
|
+
|
37
|
+
let headers = form.getHeaders();
|
38
|
+
headers['x-auth-token'] = authToken;
|
39
|
+
|
40
|
+
let options = {
|
41
|
+
hostname: url.hostname,
|
42
|
+
path: '/services/users/v1/css',
|
43
|
+
method: 'PUT',
|
44
|
+
headers,
|
45
|
+
};
|
46
|
+
|
47
|
+
const req = https.request(options);
|
48
|
+
|
49
|
+
form.pipe(req);
|
50
|
+
form.on('end', () => {
|
51
|
+
req.end();
|
52
|
+
});
|
53
|
+
|
54
|
+
req.on('response', res => {
|
55
|
+
if (res.statusCode < 200 || res.statusCode >= 300) {
|
56
|
+
return reject(new Error(`statusCode=${res.statusCode}`));
|
57
|
+
}
|
58
|
+
|
59
|
+
res.on('data', d => {
|
60
|
+
let filename = readJsonValueFromRawData('css_filename', d);
|
61
|
+
return resolve(filename);
|
62
|
+
});
|
63
|
+
});
|
64
|
+
|
65
|
+
req.on('error', e => {
|
66
|
+
return reject(e);
|
67
|
+
});
|
68
|
+
});
|
69
|
+
}
|
70
|
+
|
71
|
+
function signin(username, password) {
|
72
|
+
return new Promise((resolve, reject) => {
|
73
|
+
let options = {
|
74
|
+
hostname: url.hostname,
|
75
|
+
path: '/services/users/auth/sign_in',
|
76
|
+
method: 'POST',
|
77
|
+
headers: { 'Content-Type': 'application/json' },
|
78
|
+
};
|
79
|
+
|
80
|
+
const req = https.request(options);
|
81
|
+
|
82
|
+
req.on('response', res => {
|
83
|
+
if (res.statusCode < 200 || res.statusCode >= 300) {
|
84
|
+
return reject(new Error(`statusCode=${res.statusCode}`));
|
85
|
+
}
|
86
|
+
|
87
|
+
res.on('data', d => {
|
88
|
+
let authToken = readJsonValueFromRawData('auth_token', d);
|
89
|
+
return resolve(authToken);
|
90
|
+
});
|
91
|
+
});
|
92
|
+
|
93
|
+
req.on('error', e => {
|
94
|
+
return reject(e);
|
95
|
+
});
|
96
|
+
|
97
|
+
req.write(JSON.stringify({ user: { email: username, password } }));
|
98
|
+
|
99
|
+
req.end();
|
100
|
+
});
|
101
|
+
}
|
102
|
+
|
103
|
+
function readJsonValueFromRawData(key, rawJson) {
|
104
|
+
let json = JSON.parse(rawJson);
|
105
|
+
return json[key];
|
106
|
+
}
|
107
|
+
|
108
|
+
function handleError(e) {
|
109
|
+
console.error(e);
|
110
|
+
}
|
@@ -7,7 +7,7 @@ if (!fs.existsSync(outputDir)) {
|
|
7
7
|
|
8
8
|
if (process.argv.length < 3) {
|
9
9
|
console.error('ERROR - Language file path argument missing!');
|
10
|
-
|
10
|
+
process.exit();
|
11
11
|
}
|
12
12
|
|
13
13
|
let languageFilePath = process.argv[2];
|
@@ -15,7 +15,7 @@ let validLanguageFilePath = /site\/[a-z]{2}_[A-Z]{2}.all.json/;
|
|
15
15
|
|
16
16
|
if (!languageFilePath.match(validLanguageFilePath)) {
|
17
17
|
console.error(`ERROR - Language file path argument '${languageFilePath}' invalid!`);
|
18
|
-
|
18
|
+
process.exit();
|
19
19
|
}
|
20
20
|
|
21
21
|
let rawdata = fs.readFileSync(languageFilePath);
|
@@ -10,7 +10,6 @@ const languageFiles = openFiles(languageFilenames);
|
|
10
10
|
let errors = [];
|
11
11
|
|
12
12
|
const whitespacePaddedKeys = [
|
13
|
-
'accept_invite_page_header',
|
14
13
|
'shopping_info_release_date_title',
|
15
14
|
'shopping_info_available_until_date_title',
|
16
15
|
'shopping_info_rental_period_duration',
|
@@ -18,7 +17,7 @@ const whitespacePaddedKeys = [
|
|
18
17
|
'classification_intro',
|
19
18
|
'classification_divider',
|
20
19
|
];
|
21
|
-
const emptyKeys = ['classification_outro'
|
20
|
+
const emptyKeys = ['classification_outro'];
|
22
21
|
|
23
22
|
languageFilenames.forEach(language => {
|
24
23
|
console.log(`===== TESTING: ${language} =====`);
|
@@ -39,6 +38,7 @@ languageFilenames.forEach(language => {
|
|
39
38
|
|
40
39
|
if (keys.includes(key)) {
|
41
40
|
testKeyNotEnglish(masterFile[key], file[key], key);
|
41
|
+
testValueNotKey(file[key], key);
|
42
42
|
}
|
43
43
|
});
|
44
44
|
|
@@ -103,3 +103,17 @@ function testKeyNotEnglish(englishValue, translatedValue, key) {
|
|
103
103
|
errors.push(e);
|
104
104
|
}
|
105
105
|
}
|
106
|
+
|
107
|
+
function testValueNotKey(translation, key) {
|
108
|
+
try {
|
109
|
+
assert.ok(translation['zero'] != key);
|
110
|
+
assert.ok(translation['one'] != key);
|
111
|
+
assert.ok(translation['two'] != key);
|
112
|
+
assert.ok(translation['few'] != key);
|
113
|
+
assert.ok(translation['many'] != key);
|
114
|
+
assert.ok(translation['other'] != key);
|
115
|
+
} catch(e) {
|
116
|
+
console.error(`${key} - key is value.`);
|
117
|
+
errors.push(e);
|
118
|
+
}
|
119
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import fetch from 'node-fetch';
|
2
|
+
import glob from 'glob';
|
3
|
+
import * as fs from 'fs';
|
4
|
+
const key = process.argv[2];
|
5
|
+
const value = process.argv[3];
|
6
|
+
const nestedKey = process.argv[4];
|
7
|
+
|
8
|
+
if (!key || !value) {
|
9
|
+
console.log('Should be \'npm run translate key value\'');
|
10
|
+
process.exit(1);
|
11
|
+
}
|
12
|
+
glob('./site/*.json', {}, (err, files) => {
|
13
|
+
files.forEach(pathName => {
|
14
|
+
const file_content = fs.readFileSync(pathName);
|
15
|
+
const content = JSON.parse(file_content);
|
16
|
+
let languageCode = pathName.slice(7, 9);
|
17
|
+
if (languageCode == 'ee') languageCode = 'et';
|
18
|
+
fetch(
|
19
|
+
`https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=${languageCode}&dt=t&q=${encodeURI(
|
20
|
+
value
|
21
|
+
)}`
|
22
|
+
)
|
23
|
+
.then(res => {
|
24
|
+
const contentType = res.headers.get('content-type');
|
25
|
+
if (contentType && contentType.indexOf('application/json') !== -1) {
|
26
|
+
return res.json();
|
27
|
+
}
|
28
|
+
console.log(`translation failed for ${languageCode}`);
|
29
|
+
})
|
30
|
+
.then(translated => {
|
31
|
+
if (translated) {
|
32
|
+
const translatedValue = translated[0][0][0];
|
33
|
+
|
34
|
+
if (!content[key]) {
|
35
|
+
content[key] = {};
|
36
|
+
}
|
37
|
+
|
38
|
+
content[key][nestedKey ? nestedKey : 'other'] = translatedValue;
|
39
|
+
fs.writeFileSync(pathName, JSON.stringify(content, null, 2));
|
40
|
+
}
|
41
|
+
});
|
42
|
+
});
|
43
|
+
});
|