forked from inveniosoftware/react-invenio-deposit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18next-scanner.config.js
67 lines (60 loc) · 1.89 KB
/
i18next-scanner.config.js
1
2
3
4
5
6
7
8
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// This file is part of React-Invenio-Deposit
// Copyright (C) 2021 Graz University of Technology.
//
// React-Invenio-Deposit is free software; you can redistribute it and/or modify it
// under the terms of the MIT License; see LICENSE file for more details.
const { languages } = require("./package").config;
// list of func used to
// mark the strings for translation
const funcList = ["i18next.t"];
// list of extension to look for
const extensions = [".js", ".jsx"];
module.exports = {
options: {
debug: true,
removeUnusedKeys: true,
browserLanguageDetection: true,
func: {
list: funcList,
extensions: extensions,
},
//using Trans component
trans: {
component: "Trans",
extensions: extensions,
fallbackKey: function (ns, value) {
return value;
},
},
lngs: languages,
ns: [
// file name (.json)
"translations",
],
defaultLng: "en",
defaultNs: "translations",
// @param {string} lng The language currently used.
// @param {string} ns The namespace currently used.
// @param {string} key The translation key.
// @return {string} Returns a default value for the translation key.
defaultValue: function (lng, ns, key) {
if (lng === "en") {
// Return key as the default value for English language
return key;
}
return "";
},
resource: {
// The path where resources get loaded from. Relative to current working directory.
loadPath: "src/lib/translations/messages/{{lng}}/{{ns}}.json",
// The path to store resources.
savePath: "src/lib/translations/messages/{{lng}}/{{ns}}.json",
jsonIndent: 2,
lineEnding: "\n",
},
nsSeparator: false, // namespace separator
//Set to false to disable key separator
// if you prefer having keys as the fallback for translation (e.g. gettext).
keySeparator: false,
},
};