pseudo-localization
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -0,1 +1,4 @@ | ||
##2.1.0 | ||
- Adding CLI interface | ||
##2.0.2 | ||
@@ -2,0 +5,0 @@ - Fix a bug where blacklisted nodes would get pseudo-localized when mutated in the DOM |
{ | ||
"name": "pseudo-localization", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Dynamic pseudo-localization in the browser and nodejs", | ||
@@ -9,6 +9,10 @@ "main": "lib/index.js", | ||
], | ||
"bin": "./bin/pseudo-localize", | ||
"scripts": { | ||
"start": "node devserver.js", | ||
"prepare": "babel src --out-dir lib --minified --no-comments --source-maps", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"prepare": "babel src --out-dir lib --minified --no-comments --source-maps --ignore '**/*.test.js'", | ||
"check-formatting": "prettier --list-different src/**/*.js", | ||
"lint": "eslint src/**/*.js", | ||
"test-js": "jest src/*", | ||
"test": "npm run test-js jest && npm run check-formatting && npm run lint" | ||
}, | ||
@@ -33,7 +37,14 @@ "author": "Tryggvi Gylfason (http://twitter.com/tryggvigy)", | ||
"devDependencies": { | ||
"@babel/cli": "7.2.3", | ||
"@babel/core": "7.3.3", | ||
"@babel/preset-env": "7.3.1" | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"babel-jest": "^24.8.0", | ||
"eslint": "^6.1.0", | ||
"jest-cli": "^24.8.0", | ||
"prettier": "^1.18.2" | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"get-stdin": "^7.0.0", | ||
"yargs": "^13.3.0" | ||
} | ||
} |
@@ -11,2 +11,4 @@ <sub>Inspired by pseudo-localization at [Netflix](https://medium.com/netflix-techblog/pseudo-localization-netflix-12fff76fbcbe) and [Firefox](https://reviewboard.mozilla.org/r/248606/diff/2#index_header)</sub> | ||
[![Edit pseudo-localization-react](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/1q7n08or4j) | ||
`pseudo-localization` is a script that performs [pseudolocalization](https://en.wikipedia.org/wiki/Pseudolocalization) against the DOM or individual strings. | ||
@@ -74,2 +76,30 @@ | ||
Using hooks? Here's an example: | ||
```jsx | ||
import React from 'react'; | ||
import pseudoLocalization from 'pseudo-localization'; | ||
function PseudoLocalization() { | ||
React.useEffect(() => { | ||
pseudoLocalization.start(); | ||
return () => { | ||
pseudoLocalization.stop() | ||
}; | ||
}, []); | ||
} | ||
// And use it | ||
function Page() { | ||
return ( | ||
<main> | ||
<PseudoLocalization /> | ||
<h1>I will get pseudo localized along with everything else under document.body!</h1> | ||
<main> | ||
); | ||
} | ||
``` | ||
You can also call the underlying `localize` function to pseudo-localize any string. This is useful for non-browser environments like nodejs. | ||
@@ -173,4 +203,44 @@ | ||
## CLI Interface | ||
For easy scripting a CLI interface is exposed. The interface supports raw input, JSON files, and CommonJS modules. | ||
```bash | ||
npx pseudo-localize ./path/to/file.json | ||
# pass in a JS transpiled ES module or an exported CJS module | ||
npx pseudo-localize ./path/to/file | ||
# pass in JSON files through STDIN | ||
cat ./path/to/file.json | npx pseudo-localize --strategy bidi | ||
# pass a string via a pipe | ||
echo hello world | npx pseudo-localize | ||
# direct input pseudo-localization | ||
npx pseudo-localize -i "hello world" | ||
``` | ||
CLI Options: | ||
``` | ||
pseudo-localize [src] [options] | ||
Pseudo localize a string, JSON file, or a JavaScript object | ||
Positionals: | ||
src The source as a path or from STDIN [string] | ||
Options: | ||
-o, --output Writes output to STDOUT by default. Optionally specify a JSON | ||
file to write the pseudo-localizations to [string] | ||
-i, --input Pass in direct input to pseudo-localize [string] | ||
--debug Print out all stack traces and other debug info [boolean] | ||
--pretty Pretty print JSON output [boolean] | ||
--strategy Set the strategy for localization | ||
[choices: "accented", "bidi"] [default: "accented"] | ||
--help Show help [boolean] | ||
--version Show version number [boolean] | ||
``` | ||
## Support | ||
Works in all evergreen browsers. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
43157
10
34
2
244
2
7
+ Addedget-stdin@^7.0.0
+ Addedyargs@^13.3.0
+ Addedansi-regex@4.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedcliui@5.0.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedemoji-regex@7.0.3(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedget-stdin@7.0.0(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequire-main-filename@2.0.0(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedstring-width@3.1.0(transitive)
+ Addedstrip-ansi@5.2.0(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedwrap-ansi@5.1.0(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyargs@13.3.2(transitive)
+ Addedyargs-parser@13.1.2(transitive)