open-index/open-npm huggingface dataset:
npm package: @peassoft/dict-builder
Description: Utility for building i18n dictionaries
Latest version: 0.1.0

# @peasoft/dict-builder

Utility for building dictionaries object from dictionary text files.


## Usage Example

```typescript
import path from 'node:path';
import { dictBuilder, type DictBuilderOptions } from '@oeasoft/dict-builder';

type Dictionary = Record<string, Record<string, string>>;

const dictBuilderOptions: DictBuilderOptions = {
  srcDir: path.resolve(import.meta.dirname, './path/to/dicts'),
  lang: 'en;,
};

const englishDictionary: Dictionary = dictBuilder(dictBuilderOptions);
```

## Creating Dictionaries

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

E.g., file `global.txt`:

```text
[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`.