Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Use character map for numbers up to 7
Browse files Browse the repository at this point in the history
  • Loading branch information
jopdeklein committed Feb 18, 2019
1 parent ff41d79 commit a2f6030
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions localize.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ const BIDI_MAP = {
Z: "Z"
};

const NUMBER_MAP = {
0: '⁰',
1: 'ⁱ',
2: '²',
3: '³',
4: '⁴',
5: '⁵',
6: '⁶'
};

const strategies = {
accented: {
prefix: "",
Expand Down Expand Up @@ -136,9 +146,9 @@ const psuedoLocalizeString = (string, options = { strategy: "accented" }) => {
if (
options.elongateNumbers &&
!isNaN(characterAsInt) &&
characterAsInt >= 3
NUMBER_MAP[character]
) {
pseudoLocalizedText += character.repeat(2);
pseudoLocalizedText += character + NUMBER_MAP[character];
} else if (convertedCharacter) {
const cl = character.toLowerCase();
// duplicate "a", "e", "o" and "u" to emulate ~30% longer text
Expand Down

0 comments on commit a2f6030

Please sign in to comment.