Skip to content

Commit

Permalink
Update i18n configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
devcshort committed Jun 8, 2024
1 parent 4be56ec commit 546d3fd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app.defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,9 @@
"logoUrl": "/logo.png",
"href": "https://connect211.com"
}
]
],
"i18n": {
"defaultLocale": "en",
"locales": ["en", "es"]
}
}
9 changes: 9 additions & 0 deletions docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ This accepts an `array` of `data provider` shaped like below
| `logoUrl` | The relative or absolute URL of the data provider's logo | `optional` |
| `href` | The URL for the link | `optional` |

### i18n

Internationalization has the following values

| Key | Value | Info |
| :-------------- | :--------------------------------------------------- | :--------- |
| `defaultLocale` | The default locale for your application (ie. en, es) | `required` |
| `locales` | An array of supported locales in your application | `required` |

## Suggestions

Suggestions are displayed as the initial list of suggestions a user will see when they focus the `search` input
Expand Down
23 changes: 21 additions & 2 deletions next-i18next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
// This file is REQUIRED by react-i18next/next-i18next. DO NOT DELETE
const path = require('path');
const fs = require('fs');

let appConfig;
try {
fs.statSync(path.resolve('./app.config.json'));
const _appConfig = fs.readFileSync('./app.config.json');
appConfig = JSON.parse(_appConfig.toString());
} catch (err) {}

if (!appConfig) {
try {
fs.statSync(path.resolve('./app.defaults.json'));
const _appConfig = fs.readFileSync('./app.defaults.json');
appConfig = JSON.parse(_appConfig.toString());
} catch (err) {}
}

if (!appConfig)
throw new Error('Unable to load app.config.json or app.defaults.json');

module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'es'],
defaultLocale: appConfig?.i18n?.defaultLocale ?? 'en',
locales: appConfig?.i18n?.locales ?? ['en', 'es'],
localePath: path.resolve('./public/locales'),
},
};

0 comments on commit 546d3fd

Please sign in to comment.