MCPcopy Index your code
hub / github.com/formatjs/formatjs / transformString

Function transformString

packages/cli-lib/pseudo_locale.ts:102–122  ·  view source on GitHub ↗

* Based on: https://hg.mozilla.org/mozilla-central/file/a1f74e8c8fb72390d22054d6b00c28b1a32f6c43/intl/l10n/L10nRegistry.jsm#l425

(
  map: PseudoLocaleTransformMap,
  elongate = false,
  msg: string
)

Source from the content-addressed store, hash-verified

100 * Based on: https://hg.mozilla.org/mozilla-central/file/a1f74e8c8fb72390d22054d6b00c28b1a32f6c43/intl/l10n/L10nRegistry.jsm#l425
101 */
102function transformString(
103 map: PseudoLocaleTransformMap,
104 elongate = false,
105 msg: string
106) {
107 return msg.replace(/[a-z]/gi, ch => {
108 const cc = ch.charCodeAt(0)
109 if (cc >= 97 && cc <= 122) {
110 const newChar = String.fromCodePoint(map.small[cc - 97])
111 // duplicate "a", "e", "o" and "u" to emulate ~30% longer text
112 if (elongate && (cc === 97 || cc === 101 || cc === 111 || cc === 117)) {
113 return newChar + newChar
114 }
115 return newChar
116 }
117 if (cc >= 65 && cc <= 90) {
118 return String.fromCodePoint(map.caps[cc - 65])
119 }
120 return ch
121 })
122}
123
124/**
125 * accented - Ȧȧƈƈḗḗƞŧḗḗḓ Ḗḗƞɠŀīīşħ

Callers 2

generateENXAFunction · 0.85
generateENXBFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected