Skip to content

Translate ICU message strings into pseduo-translated ICU message strings.

License

Notifications You must be signed in to change notification settings

ceszare/icu-pseudo-translate-extended

 
 

Repository files navigation

icu-pseudo-translate-extended

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.

Example

Installing

NPM

npm install icu-pseudo-translate-extended

Yarn

yarn add icu-pseudo-translate-extended

Using the utility

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);

Authors

  • Cesar Zapata - Initial work - Ceszare

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

About

Translate ICU message strings into pseduo-translated ICU message strings.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.2%
  • JavaScript 2.8%