# insert-i18n

> Insert i18n data from json files into html

Latest version **1.0.0** (published 2014-11-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install insert-i18n
pnpm add insert-i18n
yarn add insert-i18n
bun add insert-i18n
```

Provides the command `insert-i18n`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2014-11-02 |
| First published | 2014-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Finn Pauls |
| Maintainers | finnpauls |
| Keywords | i18n, internationalisation, inline, internationalization |

## Links

- npm: https://www.npmjs.com/package/insert-i18n
- Repository: https://github.com/finnp/insert-i18n
- Issues: https://github.com/finnp/insert-i18n/issues
- npm.io page: https://npm.io/package/insert-i18n

## Dependencies (2)

- [glob](https://npm.io/package/glob.md) ^4.0.6
- [cheerio](https://npm.io/package/cheerio.md) ^0.17.0

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-11-02

## README

# insert-i18n
![insert-i18n](https://nodei.co/npm/insert-i18n.png)

Utility for inlining i18n data into HTML files from json files. You can use it
programmatically or as CLI. 

It is inspired by [this html](https://github.com/jsconfcn/jingjs/blob/gh-pages/index.html#L225-L402) 
and initially written for the [NodeSchool website](https://github.com/nodeschool/nodeschool.github.io/issues/141).

```
Usage: insert-i18n <html-files-glob> <languages-dir>
```

Every html file has to include a tag with the id `i18n` like this
```html
  <span id="i18n" style="display:none; visibility:hidden;">
```

That is where the translations are going to be inserted.

The script will look in the given `languages-dir` for a `languages.json` file.
For every key in that JSON file it will look for a `<key>.json` file. This key/value
data is going to be inserted like this:

1. The script looks for all `data-18n` attributes in each html file from the glob
2. For every one of these attributes it will look for the key in all the given languages
3. It will add a span `<span lang="<lang>" data-i18n="<key>"><value></span>` like this to the `#i18n` element.

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