0.1.0 • Published 2 years ago

@memnrev/dict-builder v0.1.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

@memnrev/dict-builder

Utility for building dictionaries object from dictionary text files.

Usage Example

const path = require('node:path');
const dictBuilder = require('@memnrev/dict-builder');

type Dictionary = {
  [dictName: string]: {
    [dictEntry: string]: string;
  };
};

const englishDictionary: Dictionary = dictBuilder({
  dictsFolder: path.resolve(__dirname, './src/dicts'),
  currLang: 'en',
});

Creating Dictinaries

Create text files in a folder. File names (without extension) will become dictionary names.

E.g., file global.txt:

[heading]
en: Hello, World!
ru: Привет!

[subHeading]
en: This is sub-heading.
ru: Это подзаголовок.

Text withing square brackets will become an entry key.

Use a dictionary entry in your code like this: dict.global.heading, dict.global.subHeading.