Skip to content

Commit

Permalink
Add a way to configure more translation funcs per project in package.…
Browse files Browse the repository at this point in the history
…json (#3)

See matrix-org/matrix-react-sdk#7377 (comment)

`package.json`:
```json
{
  // ...
  "matrix_i18n_extra_translation_funcs": [
    "newTranslatableError"
  ]
  // ...
}
```
  • Loading branch information
MadLittleMods committed Jan 11, 2022
1 parent a8a0180 commit dbd35b3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/gen-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ const walk = require('walk');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse");

const TRANSLATIONS_FUNCS = ['_t', '_td', '_tDom'];
// Find the package.json for the project we're running gen-18n against
const projectPackageJsonPath = path.join(process.cwd(), 'package.json');
const projectPackageJson = require(projectPackageJsonPath);

const TRANSLATIONS_FUNCS = ['_t', '_td', '_tDom']
// Add some addition translation functions to look out that are specified
// per project in package.json under the
// "matrix_i18n_extra_translation_funcs" key
.concat(projectPackageJson.matrix_i18n_extra_translation_funcs || []);

const INPUT_TRANSLATIONS_FILE = 'src/i18n/strings/en_EN.json';
const OUTPUT_FILE = 'src/i18n/strings/en_EN.json';
Expand Down

0 comments on commit dbd35b3

Please sign in to comment.