# @memnrev/dict-loader

> Webpack loader for replacing dictionary entries with string literals

Latest version **0.2.0** (published 2022-05-16) · 0 weekly downloads

## Install

```sh
npm install @memnrev/dict-loader
pnpm add @memnrev/dict-loader
yarn add @memnrev/dict-loader
bun add @memnrev/dict-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-05-16 |
| First published | 2022-05-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | agorokhov |

## Links

- npm: https://www.npmjs.com/package/@memnrev/dict-loader
- npm.io page: https://npm.io/package/@memnrev/dict-loader

## Dependencies (1)

- [@memnrev/dict-builder](https://npm.io/package/@memnrev/dict-builder.md) ^0.1.0

## Recent versions

- 0.2.0 (latest) — 2022-05-16
- 0.1.0 — 2022-05-14

## README

# dict-loader

Webpack loader for replacing dictionary entries with string literals.

The loader replaces entries of the form `dict.dictName.entryKey` in the code with string literals
found in dictionaries.

## Usage Example

```javascript
// webpack.config.js

const path = require('path');

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: [
          {
            loader: '@gorsoft/dict-loader',
            options: {
              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`:

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

---
_Source: https://npm.io/package/@memnrev/dict-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
