tryggvigy / pseudo-localization

Dynamic pseudo-localization in the browser and nodejs
https://tryggvigy.github.io/pseudo-localization/hamlet.html
MIT License
140 stars 15 forks source link

[Request] Option to increase output size. #54

Open tabarra opened 2 years ago

tabarra commented 2 years ago

Duplicating vowels is good, but some locales are REALLY verbose, I would like an option to 3x or maybe even 4x any vowels.

tabarra commented 2 years ago

If you want, I can PR it, sounds easy enough to just replace the line below with opts.map[char].repeat(elongateLength) or something. https://github.com/tryggvigy/pseudo-localization/blob/2b952f0d09414c5dbea6a562b543d98c61bd28c1/src/localize.ts#L149

Just let me know how you want this to be reflected in the package options.

tryggvigy commented 2 years ago

Hey @tabarra! Sorry for the slow reply. I think this is reasonable to add :) Perhaps repeatCommonVowelsTimes is more descriptive? I think this option could replace the elongate boolean option. repeatCommonVowelsTimes: 0 would result in the same behavior as elongate: false

We can default repeatCommonVowelsTimes = 1 Probably would be good to add a jsdoc comment explaining what this option does so folks can see that through the language server, for example when hovering over the option in VSCode. Something like

/**
 * The number of times "a", "e" "o", and "u" should be repeated.
 * Default to `1` which results in ~30% longer English text.
 */
repeatCommonVowelsTimes = 1

Feel free to make a PR if you want! Otherwise, I'll get around to making this improvement eventually. I can't promise it will be soon though since I don't have a lot of time for open-source these days :)