Simple pseudoloc (psuedolocalization) for strings, forked from github.com/bunkat/pseudoloc
npm install pseudoloc-jsJSON document. Each of the value in the file that is a string will then be pseudolocalized.
[!!.
!!].
%.
delimiters option.
delimiters option takes an array of objects. Set properties on the objects as follows:
{ start, end }: specifies a pair of start and end delimiters, just like using startDelimiter and endDelimiter:
{ start: '<', end: '>' }
`
* { both }: specifies a marker to use as both the start and end delimiters, just like using delimiter
`
{ both: '$$' }
`
* { full }: specifies the entire pattern for the delimiter. This is useful for cases where the token doesn't have a start marker, name, and end marker, for example with printf-style placeholders %s, %d, etc.
`
{ full: '%d' }
`
Under the hood these strings are combined into a pattern that eventually is compiled into a RegExp. That can affect you in a couple of ways:
1. You can use regular expression matchers in your delimiters
2. If your delimiter includes any characters that are special characters in regular expressions, they will need to be escaped
For example, to match named sprintf-style placeholders (such as %(name)s), you need to escape the parentheses:
// Note the double-backslash, which becomes a \( in the string
pseudoloc.option.startDelimiter = '%\\(';
// Note the square brackets, so it matches )s or )d
pseudoloc.option.endDelimiter = '\\)[sd]';
pseudoloc.str('A test string with a %(token)s.');
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %(token)s.!!]
#### Extend
Extends the width of the string by the specified percentage. Useful if you will be localizing into languages such as German which can be 30% longer than English.
We extend the string by randomly selecting characters from a predefined array of non-ASCII characters.
Default is 0.
pseudoloc.option.extend = 0.3; //30%
pseudoloc.str('A test string with a %token%.')
// [!!Ȃ ťēšť ŝťŕĩʼnğ ŵĩťħ â %token%. öఛฒそ!!]
New update: Extends the width of the string by the specified percentage will be filled with predefined array of non-ASCII characters.
#### Override
Specifies an override character that all characters in the string will be replaced with. Used to easily spot unlocalized strings. Set to undefined to go back to regular pseudolocalization.
Default is undefined.
pseudoloc.option.override = '_';
pseudoloc.str('A test string with a %token%.')
// [!!_____________________%token%_!!]
Installation
Using npm:
$ npm install pseudoloc-js
Building
To build the javascript files for _pseudoloc_, run npm install to install dependencies and then:
$ npm run build
Making minified build
To build the minified javascript files for _pseudoloc_, run npm install to install dependencies and then:
$ npm run minify
Running tests
To run the tests for _pseudoloc_, run npm install to install dependencies and then:
$ npm run test
Running benchmarks
To run the benchmarks for _pseudoloc_, run npm install` to install dependencies and then: