Skip to content

Commit dbd35b3

Browse files
Add a way to configure more translation funcs per project in package.json (#3)
See matrix-org/matrix-react-sdk#7377 (comment) `package.json`: ```json { // ... "matrix_i18n_extra_translation_funcs": [ "newTranslatableError" ] // ... } ```
1 parent a8a0180 commit dbd35b3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/gen-i18n.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ const walk = require('walk');
3232
const parser = require("@babel/parser");
3333
const traverse = require("@babel/traverse");
3434

35-
const TRANSLATIONS_FUNCS = ['_t', '_td', '_tDom'];
35+
// Find the package.json for the project we're running gen-18n against
36+
const projectPackageJsonPath = path.join(process.cwd(), 'package.json');
37+
const projectPackageJson = require(projectPackageJsonPath);
38+
39+
const TRANSLATIONS_FUNCS = ['_t', '_td', '_tDom']
40+
// Add some addition translation functions to look out that are specified
41+
// per project in package.json under the
42+
// "matrix_i18n_extra_translation_funcs" key
43+
.concat(projectPackageJson.matrix_i18n_extra_translation_funcs || []);
3644

3745
const INPUT_TRANSLATIONS_FILE = 'src/i18n/strings/en_EN.json';
3846
const OUTPUT_FILE = 'src/i18n/strings/en_EN.json';

0 commit comments

Comments
 (0)