Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
pseudolocale
Advanced tools
Readme
Pseudolocale is a small library for quickly pseudolocalizing strings. Pseudolocalization is a method for testing the internationalization aspects of your application by replacing your strings with altered versions that maintains string readability while including the most problematic characteristics including text length and character length. It also makes hard coded strings and improperly concatenated strings easy to spot so that they can be properly localized.
var pseudolocale = require('pseudolocale');
pseudolocale.str('A test string with a %token%.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.!!]
<script src="../pseudolocale.js" type="text/javascript"></script>
<script type="text/javascript">
pseudolocale.str('A test string with a %token%.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.!!]
</script>
Pseudolocale includes a command line interface to make it easy to incorporate it into your build process. Currently it supports passing in individual strings (great for trying things out) or passing in a valid JSON
document that contains a set of keys and strings. Each of the strings in the file will then be pseudolocalized.
Note: Nodejs must be installed to use the command line interface.
./bin/pseudolocale --string 'A test string with a %token%.'
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.!!]
// example.json
{
"string1": "this is the first string",
"string2": "a string with a %token%",
"string3": "a string with a %couple% of %tokens%"
}
./bin/pseudolocale --readFile example.json --writeFile example-pseudo.json
// example-pseudo.json
{
"string1": "[!!ţĥĩş ĭś ťĥě ƒĩŗśŧ şţřįƞĝ!!]",
"string2": "[!!ȁ ŝťŗĩňğ ŵįťĥ ã %token%!!]",
"string3": "[!!ȃ şťřīňğ ŵĩťħ ä %couple% ŏƒ %tokens%!!]"
}
The command line tool uses the same options as the library. For additional help and more examples:
./bin/pseudolocale --help
Specifies the string that should be prepended to the beginning of pseudolocalized strings. The prepended and appended strings help to locate strings that have been cut off or improperly concatenated together - localized strings should use tokens for data since different languages have different word orders.
Default is [!!
.
pseudolocale.option.prepend = '[##';
pseudolocale.str('A test string with a %token%.')
// [##Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.!!]
Specifies the string that should be appended to the end of pseudolocalized strings. The prepended and appended strings help to locate strings that have been cut off or improperly concatenated together - localized strings should use tokens for data since different languages have different word orders.
Default is !!]
.
pseudolocale.option.append = '##]';
pseudolocale.str('A test string with a %token%.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.##]
Specifies the token delimiter. Any characters between token delimiters will not be pseudolocalized. Tokens are used to replace data within localized strings. You can either specify a single delimiter or use startDelimiter and endDelimiter to specify the delimiters seperately.
Default is %
.
pseudolocale.option.delimiter = '$$';
pseudolocale.str('A test string with a $$token$$.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą $$token$$.!!]
pseudolocale.option.startDelimiter = '{{';
pseudolocale.option.endDelimiter = '}}';
pseudolocale.str('A test string with a {{token}}.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą {{token}}.!!]
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.
Default is 0
.
pseudolocale.option.extend = 0.3; //30%
pseudolocale.str('A test string with a %token%.')
// [!!Ȃ ťēšť ŝťŕĩʼnğ ŵĩťħ â %token%. !!]
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 pseudolocalealization.
Default is undefined
.
pseudolocale.option.override = '_';
pseudolocale.str('A test string with a %token%.')
// [!!_____________________%token%_!!]
Using npm:
$ npm install pseudolocale
To build the minified javascript files for pseudolocale, run npm install
to install dependencies and then:
$ make build
To run the tests for pseudolocale, run npm install
to install dependencies and then:
$ make test
To run the benchmarks for pseudolocale, run npm install
to install dependencies and then:
$ make benchmark
FAQs
Simple pseudolocale (psuedolocalization) for strings
The npm package pseudolocale receives a total of 116,729 weekly downloads. As such, pseudolocale popularity was classified as popular.
We found that pseudolocale demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.