https://github.com/kanocomputing/web-i18n
Simple message DB with aggregation tools to handle i18n in the web
https://github.com/kanocomputing/web-i18n
Last synced: 11 months ago
JSON representation
Simple message DB with aggregation tools to handle i18n in the web
- Host: GitHub
- URL: https://github.com/kanocomputing/web-i18n
- Owner: KanoComputing
- Created: 2019-06-14T08:29:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-06T01:34:14.000Z (about 3 years ago)
- Last Synced: 2025-06-13T20:03:29.212Z (12 months ago)
- Language: TypeScript
- Size: 47.9 KB
- Stars: 1
- Watchers: 17
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Web i18n
Provide a simple message DB managment and localization function.
## Usage
Add to your project using `yarn add @kano/i18n`;
Im port and use as follow
```js
import { _, setDefaultLang, addSupportedLanguage } from '@kano/i18n/index.js';
// Add the supported langauges before using any other functions
addSupportedLanguage('de-DE');
// Set the default language, will be used if the browser is configured to use a non supported language
setDefaultLang('en-GB');
// Use the _ function to resolve all messages. Provide a fallback that will be used to generate
// the default language file
const message = _('UPDATE_NOW', 'Update now');
```
## Generating the language files
Once all the strings in your codebase has been tokenized using the `_` function, you can generate a language file using the provided tool.
Example:
```
i18n-generator ./code/**/*.js
```
Will print all keys and their default values from the codebase. Run `i18n-generator --help` to see all options