Skip to content

Commit 1f838d6

Browse files
committed
refactor: generate translations at build time from .po files
1 parent dc00538 commit 1f838d6

File tree

17 files changed

+6
-619
lines changed

17 files changed

+6
-619
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"homepage": "https://speed.measurementlab.net",
77
"license": "Apache-2.0",
88
"scripts": {
9-
"build": "node scripts/build.js",
10-
"convert-translations": "node scripts/po-to-json.js"
9+
"build": "node scripts/build.js"
1110
},
1211
"dependencies": {
1312
"@m-lab/msak": "0.3.1",

scripts/build.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ function build() {
6464
console.log('Copying fonts for font-awesome compatibility...');
6565
copyDir(path.join(SRC, 'assets', 'fonts'), path.join(DIST, 'fonts'));
6666

67+
// Convert .po translations to JSON
68+
console.log('Converting translations...');
69+
require('./po-to-json');
70+
6771
// Copy M-Lab libraries from node_modules
6872
console.log('Copying M-Lab libraries...');
6973
const libDest = path.join(DIST, 'libraries');

scripts/po-to-json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const path = require('path');
99
const gettextParser = require('gettext-parser');
1010

1111
const LANGUAGES_DIR = path.join(__dirname, '..', 'translations', 'languages');
12-
const OUTPUT_DIR = path.join(__dirname, '..', 'src', 'translations');
12+
const OUTPUT_DIR = process.argv[2] || path.join(__dirname, '..', 'dist', 'translations');
1313

1414
// Language code mapping (e.g., de_DE.po -> de.json)
1515
const LANG_MAP = {

src/translations/az.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/translations/br.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/translations/de.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)