0.2.2 • Published 8 years ago
i18n-xlsx v0.2.2
i18n-xlsx
Typesafe i18n
This module tries to solve problem of managing i18n data via transpiling excel files with i18n data into other typesafe formats. Currently supported formats are:
- Typescript
- Go
Installation
npm install -g i18n-xlsxTutorial (Typescript)
- Create excel file with i18n data:
Header should contain code column and list of supported languages (in this case hr and en).
Library also supports multiple sheets.
- Use
i18n-xlsxto create typescript file
i18n-xlsx -i translations.xlsx -o i18n.tsCheck i18n.ts file. It will have following output.
interface ISheet1 {
testKey1: string;
testKey2: string;
}
interface ISheets {
sheet1: ISheet1;
}
enum Language {
hr = 'hr',
en = 'en',
}
const all: { [key in string]: ISheets } = {
hr: {
sheet1: {
testKey1: 'vrijednost 1',
testKey2: 'vrijednost 2',
},
},
en: {
sheet1: {
testKey1: 'value 1',
testKey2: 'value 2',
},
},
};
export default all;- Use generated code
import i18n from './path/to/i18n.ts';
console.log(i18n.en.sheet1.testKey1); // typesafe + intellisenseLicense
MIT