@yrpri/api 9.0.146 → 9.0.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yrpri/api",
3
- "version": "9.0.146",
3
+ "version": "9.0.148",
4
4
  "license": "MIT",
5
5
  "author": "Robert Bjarnason & Citizens Foundation",
6
6
  "repository": {
@@ -25,7 +25,7 @@
25
25
  "@google-cloud/vertexai": "^1.10.0",
26
26
  "@google-cloud/vision": "^5.1.0",
27
27
  "@node-saml/passport-saml": "^5.0.1",
28
- "@policysynth/agents": "^1.3.117",
28
+ "@policysynth/agents": "^1.3.119",
29
29
  "async": "^3.2.6",
30
30
  "authorized": "^1.0.0",
31
31
  "aws-sdk": "^2.1692.0",
@@ -258,7 +258,7 @@ i18n
258
258
  // this is the defaults
259
259
  backend: {
260
260
  // path where resources get loaded from
261
- loadPath: localesPath + '/{{lng}}/translation.json',
261
+ loadPath: i18n.buildLoadPath,
262
262
  // path to post missing resources
263
263
  addPath: localesPath + '/{{lng}}/translation.missing.json',
264
264
  // jsonIndent to use when storing json files
@@ -456,7 +456,7 @@ i18n
456
456
  // this is the defaults
457
457
  backend: {
458
458
  // path where resources get loaded from
459
- loadPath: localesPath + '/{{lng}}/translation.json',
459
+ loadPath: i18n.buildLoadPath,
460
460
  // path to post missing resources
461
461
  addPath: localesPath + '/{{lng}}/translation.missing.json',
462
462
  // jsonIndent to use when storing json files
@@ -30,7 +30,7 @@ i18n
30
30
  // this is the defaults
31
31
  backend: {
32
32
  // path where resources get loaded from
33
- loadPath: localesPath + '/{{lng}}/translation.json',
33
+ loadPath: i18n.buildLoadPath,
34
34
  // path to post missing resources
35
35
  addPath: localesPath + '/{{lng}}/translation.missing.json',
36
36
  // jsonIndent to use when storing json files
package/utils/i18n.cjs CHANGED
@@ -1,13 +1,29 @@
1
1
  "use strict";
2
2
  var i18n = require('i18next');
3
3
  var Backend = require('i18next-fs-backend');
4
+ var path = require('path');
5
+ var fs = require('fs');
6
+ function buildLoadPath(language, namespace) {
7
+ var localesDir = path.resolve(__dirname, '../services/locales');
8
+ var filePath = path.join(localesDir, language, 'translation.json');
9
+ if (!fs.existsSync(filePath)) {
10
+ var altLanguage = language.replace(/-/g, '_');
11
+ filePath = path.join(localesDir, altLanguage, 'translation.json');
12
+ if (!fs.existsSync(filePath)) {
13
+ filePath = path.join(localesDir, 'en', 'translation.json');
14
+ }
15
+ }
16
+ return filePath;
17
+ }
4
18
  i18n
5
19
  .use(Backend)
6
20
  .init({
21
+ fallbackLng: 'en',
22
+ lowerCaseLng: true,
7
23
  // this is the defaults
8
24
  backend: {
9
25
  // path where resources get loaded from
10
- loadPath: '../locales/{{lng}}/translation.json',
26
+ loadPath: buildLoadPath,
11
27
  // path to post missing resources
12
28
  addPath: '../locales/{{lng}}/translation.missing.json',
13
29
  // jsonIndent to use when storing json files
@@ -15,3 +31,4 @@ i18n
15
31
  }
16
32
  });
17
33
  module.exports = i18n;
34
+ module.exports.buildLoadPath = buildLoadPath;