pseudo-localization
Version:
pseudo-localization for internationalization testing
29 lines (28 loc) • 1.28 kB
TypeScript
export type Strategy = 'accented' | 'bidi';
export type PseudoLocalizeStringOptions = {
/**
* The strategy to employ.
* - `accented`:
* In Accented English all Latin letters are replaced by accented
* Unicode counterparts which don't impair the readability of the content.
* This allows developers to quickly test if any given string is being
* correctly displayed in its 'translated' form. Additionally, simple
* heuristics are used to make certain words longer to better simulate the
* experience of international users.
* - `bidi`:
* Bidi English is a fake [RTL](https://developer.mozilla.org/en-US/docs/Glossary/rtl) locale.
* All words are surrounded by
* Unicode formatting marks forcing the RTL directionality of characters.
* In addition, to make the reversed text easier to read, individual
* letters are flipped.
*/
strategy?: Strategy;
};
/**
* Pseudo-localizes a string using a specified strategy.
*
* @example
* pseudoLocalizeString('orange'); // 'ǿǿřȧȧƞɠḗḗ'
* pseudoLocalizeString('orange', {strategy: 'bidi'}); // 'ǝƃuɐɹo'
*/
export declare const pseudoLocalizeString: (string: string, { strategy }?: PseudoLocalizeStringOptions) => string;