elliptical-translate
Multiple language support for elliptical
Phrases may specify a translations
array in addition to a describe
function.
An ordered array of language tags should be supplied to createProcessor
.
At compilation, the most specific language from the translations will be
selected. Otherwise, the default describe
will be used.
const MyPhrase = translations: langs: 'en' <literal text='truck' /> langs: 'en-GB' 'en-ZA' 'en-IE' 'en-IN' <literal text='lorry' /> lang: 'es' <literal text='camión' /> <literal text='truck' />
Installation
npm install elliptical-translate
Guidelines
Any strings will work, but in practice, you should use
IETF RFC 5646 language tags.
Tags passed to createProcess
should be from most specific to most general,
such as ['zh-Hans-CH', 'zh-Hans', 'zh-CN', 'zh']
, meaning:
prefer Simplified Chinese as used in mainland China, then Simplified Chinese,
then Chinese as used in mainland China, then Chinese. This allows
elliptical-translate to always pick the best available translation.
Usage
/** @jsx createElement */ let parse process // pick the most specific lang availableprocess = parse = // => lorry // fall back to less specific langs if possibleprocess = parse = // => truck process = parse = // => camión // if no langs exist, select the defaultprocess = parse = // => truck