# fluent-translation-parser

> parses fluent translations to AST

Latest version **1.0.0** (published 2019-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install fluent-translation-parser
pnpm add fluent-translation-parser
yarn add fluent-translation-parser
bun add fluent-translation-parser
```

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-10-11 |
| First published | 2018-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Jan Mühlemann |
| Maintainers | jamuhl |
| Keywords | fluent |

## Links

- npm: https://www.npmjs.com/package/fluent-translation-parser
- Repository: https://github.com/locize/fluent-translation-parser
- Issues: https://github.com/locize/fluent-translation-parser/issues
- npm.io page: https://npm.io/package/fluent-translation-parser

## Dependencies (1)

- [html-parse-stringify2](https://npm.io/package/html-parse-stringify2.md) github:locize/html-parse-stringify2

## Recent versions

- 1.0.0 (latest) — 2019-10-11
- 0.0.2 — 2018-09-19
- 0.0.1 — 2018-09-19

## README

# Introduction

[![Travis](https://img.shields.io/travis/locize/fluent-translation-parser/master.svg?style=flat-square)](https://travis-ci.org/i18next-translation-parser)
[![Coveralls](https://img.shields.io/coveralls/locize/fluent-translation-parser/master.svg?style=flat-square)](https://coveralls.io/github/locize/fluent-translation-parser)
[![npm version](https://img.shields.io/npm/v/i18next-translation-parser.svg?style=flat-square)](https://www.npmjs.com/package/i18next-translation-parser)
[![David](https://img.shields.io/david/locize/fluent-translation-parser.svg?style=flat-square)](https://david-dm.org/locize/fluent-translation-parser)

This is a module to parse an i18next translation string into an AST and back to a string.

# Getting started

Source can be loaded via [npm](https://www.npmjs.com/package/fluent-translation-parser) or [downloaded](https://github.com/locize/fluent-chained-backend/blob/master/fluentTranslationParser.min.js) from this repo.

```
# npm package
$ npm install fluent-translation-parser
```

# Sample

```js
import { parse, stringify } from "fluent-translation-parser";

const AST = parse(`
    { $unreadEmails ->
        [one] You have one unread email.
       *[other] You have { $unreadEmails } unread emails.
    }
`);
// will return
/*
[
  {
    "type": "text",
    "content": "    { $unreadEmails ->\n        [one] You have one unread email.\n       *[other] You have { $unreadEmails } unread emails.\n    }",
    "children": [
      {
        "type": "text",
        "content": "    "
      },
      {
        "type": "selector",
        "raw": "{ $unreadEmails ->",
        "prefix": "{",
        "suffix": "->",
        "content": " $unreadEmails ",
        "variable": "unreadEmails"
      },
      {
        "type": "text",
        "content": "\n        "
      },
      {
        "type": "variant",
        "isDefault": false,
        "raw": "[one]",
        "prefix": "[",
        "suffix": "]",
        "content": "one",
        "variable": "one"
      },
      {
        "type": "text",
        "content": " You have one unread email.\n       "
      },
      {
        "type": "variant",
        "isDefault": true,
        "raw": "*[other]",
        "prefix": "*[",
        "suffix": "]",
        "content": "other",
        "variable": "other"
      },
      {
        "type": "text",
        "content": " You have "
      },
      {
        "type": "variable",
        "raw": "{ $unreadEmails }",
        "prefix": "{",
        "suffix": "}",
        "content": " $unreadEmails ",
        "variable": "unreadEmails"
      },
      {
        "type": "text",
        "content": " unread emails.\n    "
      },
      {
        "type": "closingBracket",
        "raw": "}",
        "prefix": "",
        "suffix": "}",
        "content": ""
      },
      {
        "type": "text",
        "content": ""
      }
    ]
  }
]
*/
stringify(AST);
```

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