This tool converts messages written in the ICU message format into messages written with pseudo-localized content. As detailed by Netflix, using pseudo-localization on our strings will bring in several benefits such as:
- Allowing developers to easily find strings that have not been localized.
- Expose rendering errors when handling non-traditional alphabets.
- Allowing developers to test how their text will be displayed in right-to-left languages.
- Allowing developers to expand the length of strings, helping them catch any layout issues with lengthy strings.
This tool is an extension of 1stdibs icu-pseudo-translate utility implementation. Whereas the original tool only replaced strings from the English alphabet, this fork uses Tryggvi Gylfason's pseudo-localization engine, allowing us more configuration options for generating the pseudo-localized strings.
npm install icu-pseudo-translate-extended
yarn add icu-pseudo-translate-extended
Import or require the module:
import translate from 'icu-pseudo-translate-extended';
or
const translate = require('icu-pseudo-translate-extended');
Then, you can just use the translate function by passing the string to translate, and optionally a flag which determines if the content should be displayed bi-directionally:
const strintToTranslate = 'On {takenDate, date, short} {name} took {numPhotos, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}';
const defaultTranslation = translate(stringToTranslate); // same as translate(stringToTranslate, false);
const bidirectionalTranslation = translate(stringToTranslate, true);
- Cesar Zapata - Initial work - Ceszare
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details
- Tim Whidden and 1stdibs for their icu-pseudo-translate utility
- Tryggvi Gylfason for his amazing pseudo-localization engine.