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

Commit

Permalink
Elongate even numbers only
Browse files Browse the repository at this point in the history
  • Loading branch information
jopdeklein committed Feb 19, 2019
1 parent c91ce03 commit 0676878
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions localize.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,12 @@ const BIDI_MAP = {
Z: "Z"
};

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

const strategies = {
Expand Down Expand Up @@ -146,12 +144,13 @@ const psuedoLocalizeString = (string, options = { strategy: "accented" }) => {
if (
options.elongateNumbers &&
!isNaN(characterAsInt) &&
NUMBER_MAP[character]
EVEN_NUMBER_MAP[character]
) {
pseudoLocalizedText += character + NUMBER_MAP[character];
// Duplicate even numbers with superscript variations
pseudoLocalizedText += character + EVEN_NUMBER_MAP[character];
} else if (convertedCharacter) {
const cl = character.toLowerCase();
// duplicate "a", "e", "o" and "u" to emulate ~30% longer text
// Duplicate "a", "e", "o" and "u" to emulate ~30% longer text
if (
strategyOptions.elongate &&
(cl === "a" || cl === "e" || cl === "o" || cl === "u")
Expand Down

0 comments on commit 0676878

Please sign in to comment.