# pseudo-translate

> A compact and flexible utility for pseudo-translating i18n resources.

Latest version **1.0.0** (published 2020-05-11) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install pseudo-translate
pnpm add pseudo-translate
yarn add pseudo-translate
bun add pseudo-translate
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-05-11 |
| First published | 2020-05-11 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 47.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Rob Orsini |
| Maintainers | rorsini |
| Keywords | pseudo-translation, translation, internationalization, localization, globalization, i18n, l10n, gettext, intl-messageformat, i18next |

## Links

- npm: https://www.npmjs.com/package/pseudo-translate
- Repository: https://github.com/rorsini/pseudo-translate
- Homepage: https://github.com/rorsini/pseudo-translate#readme
- Issues: https://github.com/rorsini/pseudo-translate/issues
- npm.io page: https://npm.io/package/pseudo-translate

## Dependencies (3)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [acorn](https://npm.io/package/acorn.md) ^7.1.1
- [jsonfile](https://npm.io/package/jsonfile.md) ^6.0.1

## 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) — 2020-05-11

## README

# pseudo-translate

[![Node.js CI](https://github.com/rorsini/pseudo-translate-json/workflows/Node.js%20CI/badge.svg)](https://github.com/rorsini/pseudo-translate-json/actions?query=workflow%3A%22Node.js+CI%22)

A compact and flexible utility for **pseudo-translating** i18n resources.
> → «Ä çömpäçt äñd fléxïblé ütïlïty föř pséüdö-třäñslätïñg ï18ñ řésöüřçés.»

**Pseudo-translation** is the process of mimicking the actual translation of a
string into another language. It's a **readable**, dummy translation used to test if an
application will function correctly in another language.

Use it to:
* Verify that all UI text has been extracted into i18n resources.
  Pseudo-translation makes it easy to spot the strings you missed.
* Test that your UI can handle translations of varying length to avoid unintended
  word wrapping or truncation issues.
* Detect string concatenation issues in your UI before they break real
  translations. Leave language structure and word declension details to the
  translation experts.

Integrate this utility into your development process for quick feedback on
string-extractions while globalizing your software, or for periodic smoke
testing your localization workflow.

## Installation

Install using `npm`:
```bash
$ npm -i pseudo-translate
```

Then include `ptify` with:
```javascript
const ptify = require('pseudo-translate');
```

### Objects

Pseudo-translate a JSON object containing your i18n resource strings. Such as:
```javascript
const obj = {
    "USERS": {
        "MSG": "Welcome {{FNAME}} {{LNAME}}, nice to see you!"
    }
};
const pt = ptify(obj);
```
which results in `pt` containing:
```
{
    "USERS": {
        "MSG": "«Wélçömé {{FNAME}} {{LNAME}}, ñïçé tö séé yöü!»"
    }
}
```
Notice that the string interpolation place-holders `FNAME` and `LNAME` are left
un-touched so that your i18n extraction library's variable substitutions will
still work as expected. See:
https://www.i18next.com/translation-function/interpolation for details on the
default supported syntax.

### Files

Pseudo-translate an entire file by passing in the path to your i18n resource JSON file:
```javascript
const pt = ptify('./locales/en-US.json');
```
It returns a object who's text values have been pseudo-translated.

## Configuration

Options include:

* Translations vary in length and your UI should be able to accommodate these
  variations. To increase the pseudo-translation length by approximately 30%,
  pass in the following `options` object:
  ```javascript
  const enu_obj = { MSG: 'Welcome {{ USER }}, please click {{HERE}}' };
  const options = {
      increase_lengh_30_pct: true
  };
  const pt = ptify(enu_obj, options);
  ```
  which results in:
  ```
  { MSG: '«Wélçömé {{ USER }}, pléäsé çlïçk {{HERE}} ω ä Ý Ä ñ ï»' }
  ```

* Unicode "bookends", e.g. `«` and `»`, are included by default to help
  identify string concatenation issues. For example:
  ```
  { "SUBMIT": "«Sübmït»" }
  ```
  To **disable** bookends, pass in the following option:
  ```javascript
  const enu_obj = { "SUBMIT": "Submit" };
  const options = {
      include_unicode_bookends: false
  };
  const pt = ptify(enu_obj, options);
  ```
  resulting in:
  ```
  { "SUBMIT": "Sübmït" }
  ```

## Issues

If you have any feature requests or bugs to report please add them here:
https://github.com/rorsini/pseudo-translate/issues

Thanks for your support!

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