0.16.0 • Published 8 months ago
ftl-tx v0.16.0
ftl-tx
Simple library that converts .ftl to/from structured JSON with ICU Messages that Transifex can understand.
It has many limitations (see below).
Usage
import { ftlToJSON, JSONToFtl } from 'ftl-tx';
const ftl = `message = Hello, { $user }!`;
console.assert(JSONToFtl(ftlToJSON(ftl)).trim() === ftl);
console.log(ftlToJSON(ftl));
See tests/translate.test.js
for various use cases.
Limitations
A limited set of features is supported, specifically:
- attributes are translated into new messages, with the attribute name concatenated with the message key to create a new message key
- fluent functions (including built-in functions) will be correctly transcoded to ICU and back, including when used as selectors, but obviously won't work in ICU format.
- message referencing is not supported
- terms are converted to variables, prefixed with
FTLREF_
and with "-" replaced as "_" - All comments are ignored, except for message-bound comments prefixed
tx:
- Message nesting level is limited to 10 levels (using a variable/reference inside a variant value "costs" 0.5 level). This value is configurable and can be increased at a slight performance cost
Configuration
addTermsToFTL
, whether to include terms in produced FTL file, defaults totrue
commentPrefix
, prefix used for comments, defaults totx:
nestLimit
, maximum message nesting level, defaults to 10skipRefOnly
, whether to exclude from JSON output messages that only include a reference (to another message or to a term/variable)skipTerms
, whether to exclude terms from JSON output
Examples
See tests/translate.test.js
for examples.
0.16.0
8 months ago
0.15.0
8 months ago
0.15.1
8 months ago
0.14.0
10 months ago
0.12.0
10 months ago
0.13.0
10 months ago
0.10.0
12 months ago
0.11.0
12 months ago
0.9.0
1 year ago
0.8.0
1 year ago
0.7.0
1 year ago
0.3.0
2 years ago
0.5.0
2 years ago
0.4.1
2 years ago
0.4.0
2 years ago
0.6.0
2 years ago
0.5.1
2 years ago
0.2.1
2 years ago
0.2.0
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago