Socket
Socket
Sign inDemoInstall

pseudolocale

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

dist/cli.cjs

56

package.json
{
"name": "pseudolocale",
"version": "1.2.0",
"version": "1.3.0",
"description": "Simple pseudolocale (psuedolocalization) for strings",

@@ -14,16 +14,52 @@ "keywords": [

},
"main": "index.js",
"dependencies": {
"commander": "*"
"bin": "./dist/cli.mjs",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"engines": {
"node": ">=16.0.0"
},
"devDependencies": {
"mocha": "*",
"should": ">=0.6.3",
"jslint": "*",
"uglify-js": "*"
"exports": {
".": {
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
},
"./package.json": "./package.json"
},
"license": "MIT",
"scripts": {
"test": "./node_modules/.bin/mocha test/**/*-test.js"
"build": "unbuild",
"prepublishOnly": "yarn build",
"test": "jest",
"lint:types": "tsc",
"prettier:check": "prettier --check '**/*.{ts,tsx}'",
"lint": "eslint 'src/**/*.{js,ts,tsx}' && prettier -c {src,.}/**/*.ts --write && yarn lint:types"
},
"dependencies": {
"commander": "^10.0.0"
},
"files": [
"Readme.md",
"dist/"
],
"devDependencies": {
"@types/jest": "^29.5.0",
"@types/node": "16.18.18",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"jest": "^29.5.0",
"prettier": "^2.1.2",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5",
"unbuild": "^1.1.2"
}
}

162

Readme.md
# Pseudolocale
_Pseudolocale_ is a small library for quickly pseudolocalizing strings. [Pseudolocalization](http://en.wikipedia.org/wiki/Pseudolocalealization) 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.
[![npm](https://img.shields.io/npm/v/pseudolocale?logo=npm&cacheSeconds=1800)](https://www.npmjs.com/package/pseudolocale)
![NPM downloads](https://img.shields.io/npm/dm/pseudolocale.svg?link=https://www.npmjs.com/package/pseudolocale&link=https://www.npmjs.com/package/pseudolocale)
[![CI](https://github.com/MartinCerny-awin/pseudolocale/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/MartinCerny-awin/pseudolocale/actions/workflows/ci.yml)
[![GitHub contributors](https://img.shields.io/github/contributors/MartinCerny-awin/pseudolocale?cacheSeconds=1000)](https://github.com/MartinCerny-awin/pseudolocale/graphs/contributors)
[![npm](https://img.shields.io/codecov/c/github/MartinCerny-awin/pseudolocale/main.svg)](https://codecov.io/gh/MartinCerny-awin/pseudolocale)
## Using with Node.js
_Pseudolocale_ is a small library for quickly pseudolocalizing strings. [Pseudolocalization](http://en.wikipedia.org/wiki/Pseudolocalealization) 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. This library is idempotent eg. it always creates the same string.
var pseudolocale = require('pseudolocale');
## Installation
pseudolocale.str('A test string with a %token%.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.!!]
```bash
npm install pseudolocale
```
## Using in a browser
## Using with Node.js
<script src="../pseudolocale.js" type="text/javascript"></script>
<script type="text/javascript">
```js
var pseudolocale = require('pseudolocale');
pseudolocale.str('A test string with a %token%.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.!!]
pseudolocale('This is going to be pseudolocalized %token%.');
// [!!Ţĥĩś ĩś ĝōĩńĝ ţō ƀē ƥśēũďōĺōćàĺĩźēď %token%.!!]
```
</script>
## Using from the command line

@@ -28,29 +32,38 @@

./bin/pseudolocale --string 'A test string with a %token%.'
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.!!]
```bash
./dist/cli.mjs --string 'This is going to be pseudolocalized %token%.'
# [!!Ţĥĩś ĩś ĝōĩńĝ ţō ƀē ƥśēũďōĺōćàĺĩźēď %token%.!!]
```
```json
// example.json
{
"string1": "this is the first string",
"string2": "a string with a %token%",
"string3": "a string with a %couple% of %tokens%"
}
```
// example.json
{
"string1": "this is the first string",
"string2": "a string with a %token%",
"string3": "a string with a %couple% of %tokens%"
}
```bash
./bin/pseudolocale --readFile example.json --writeFile example-pseudo.json
```
./bin/pseudolocale --readFile example.json --writeFile example-pseudo.json
```json
// example-pseudo.json
{
"string1": "[!!ţĥĩş ĭś ťĥě ƒĩŗśŧ şţřįƞĝ!!]",
"string2": "[!!ȁ ŝťŗĩňğ ŵįťĥ ã %token%!!]",
"string3": "[!!ȃ şťřīňğ ŵĩťħ ä %couple% ŏƒ %tokens%!!]"
}
```
// 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
```bash
./bin/pseudolocale --help
```
## Options
#### Prepend
### Prepend

@@ -61,7 +74,10 @@ 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.

pseudolocale.option.prepend = '[##';
pseudolocale.str('A test string with a %token%.')
// [##Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.!!]
```js
pseudolocale('This is going to be pseudolocalized %token%.', {
prepend: '[##',
});
// [##Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.!!]
```
#### Append
### Append

@@ -72,7 +88,8 @@ 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.

pseudolocale.option.append = '##]';
pseudolocale.str('A test string with a %token%.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.##]
```js
pseudolocale('This is going to be pseudolocalized %token%.', { append: '##]' });
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą %token%.##]
```
#### Delimiter, StartDelimiter, EndDelimiter
### Delimiter, StartDelimiter, EndDelimiter

@@ -83,12 +100,14 @@ 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.

pseudolocale.option.delimiter = '$$';
pseudolocale.str('A test string with a $$token$$.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą $$token$$.!!]
```js
pseudolocale('A test string with a $$token$$.', { delimiter: '$$' });
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą $$token$$.!!]
pseudolocale.option.startDelimiter = '{{';
pseudolocale.option.endDelimiter = '}}';
pseudolocale.str('A test string with a {{token}}.')
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą {{token}}.!!]
pseudolocale('A test string with a {{token}}.', {
startDelimiter: '{{',
endDelimiter: '}}',
});
// [!!Á ţȇšŧ śťřīņğ ŵıţħ ą {{token}}.!!]
```
#### Extend
### Extend

@@ -99,9 +118,9 @@ 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.

pseudolocale.option.extend = 0.3; //30%
pseudolocale.str('A test string with a %token%.')
// [!!Ȃ ťēšť ŝťŕĩʼnğ ŵĩťħ â %token%. !!]
```js
pseudolocale('This is going to be pseudolocalized %token%.', { extend: 0.3 }); // 30%
// [!!Ȃ ťēšť ŝťŕĩʼnğ ŵĩťħ â %token%. !!]
```
### Override
#### 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 pseudolocalealization.

@@ -111,27 +130,38 @@

pseudolocale.option.override = '_';
pseudolocale.str('A test string with a %token%.')
// [!!_____________________%token%_!!]
```js
pseudolocale('This is going to be pseudolocalized %token%.', { override: '_' });
// [!!_____________________%token%_!!]
```
## Installation
## Contribution
### Installation
Using npm:
$ npm install pseudolocale
```bash
npm i
```
## Building
### Building
To build the minified javascript files for _pseudolocale_, run `npm install` to install dependencies and then:
To build javascript files for _pseudolocale_, run `npm i` to install dependencies and then:
$ make build
```bash
npx tsc
```
## Running tests
### Running tests
To run the tests for _pseudolocale_, run `npm install` to install dependencies and then:
To run the tests for _pseudolocale_, run `npm i` to install dependencies and then:
$ make test
```bash
npm test
```
## Running benchmarks
### Improvements
To run the benchmarks for _pseudolocale_, run `npm install` to install dependencies and then:
$ make benchmark
- add changelog
- improve documentation
- minify the code
- improve commander
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc