Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pseudo-localization

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pseudo-localization - npm Package Compare versions

Comparing version 1.3.0 to 2.0.0

lib/index.js

18

CHANGELOG.md

@@ -0,1 +1,17 @@

##2.0.0
- Safeguard childlist mutations and empty strings https://github.com/tryggvigy/pseudo-localization/pull/12
- Fixes https://github.com/tryggvigy/pseudo-localization/issues/6 and https://github.com/tryggvigy/pseudo-localization/issues/11
- Fix a bug where DOM mutation localizations did not respect the strategy specified https://github.com/tryggvigy/pseudo-localization/pull/16
- Refactor internals to use import/export ES modules https://github.com/tryggvigy/pseudo-localization/pull/16
- **BREAKING** `require` usage will have to change from
```js
const pseudoLocalization = require('pseudo-localization');
```
to
```js
const pseudoLocalization = require('pseudo-localization').default;
```
- Transform to "not dead" browsers through babel https://github.com/tryggvigy/pseudo-localization/pull/16
- Fixes https://github.com/tryggvigy/pseudo-localization/issues/8
##1.3.0

@@ -20,3 +36,3 @@ - Allow blacklisting nodes ([#9](https://github.com/tryggvigy/pseudo-localization/pull/9))

- Stop using `one two three ...` to elongagate the string by ~30-40% and instead duplicate letters withing the string itself.
- Tidy up psuedo language symbols maps to contain more legibile symbols
- Tidy up pseudo language symbols maps to contain more legibile symbols
- Make pseudo language deterministic. Always use the same pseudo symbol for the same english letter.

22

package.json
{
"name": "pseudo-localization",
"version": "1.3.0",
"version": "2.0.0",
"description": "Dynamic pseudo-localization in the browser",
"main": "index.js",
"main": "lib/index.js",
"files": [
"lib"
],
"scripts": {
"start": "node devserver.js",
"prepare": "babel src --out-dir lib --minified --no-comments --source-maps",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -13,8 +18,9 @@ },

"localization",
"pseudo-localization",
"l10n",
"i18n",
"psuedo",
"pseudo",
"language",
"translation",
"psuedo-localize"
"pseudo-localize"
],

@@ -25,3 +31,9 @@ "repository": {

},
"license": "MIT"
"license": "MIT",
"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.3.3",
"@babel/preset-env": "7.3.1"
},
"dependencies": {}
}

@@ -11,3 +11,3 @@ <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>

`pseudo-localization` is a script that performs [pseudolocalization](https://en.wikipedia.org/wiki/Pseudolocalization) against the DOM.
`pseudo-localization` is a script that performs [pseudolocalization](https://en.wikipedia.org/wiki/Pseudolocalization) against the DOM or individual strings.

@@ -24,3 +24,3 @@ [Demo here](https://tryggvigy.github.io/pseudo-localization/hamlet.html). Changing text nodes and adding or removing trees of elements will trigger a pseudolocalization run on all the new text added to the DOM. Try it using the devtools.

### Raw script (without npm)
Copy paste the script in it's entirty from [here](https://github.com/tryggvigy/pseudo-localization/blob/master/hamlet.html#L8873-L9029) and use as you wish.
Copy paste the files in [`src`](https://github.com/tryggvigy/pseudo-localization/blob/master/src) and use as you wish. It's not a lot of code.

@@ -32,6 +32,8 @@

`pseudo-localization` is just a script and can be invoked like so:
`pseudo-localization` can be used like so:
```js
const pseudoLocalization = require('pseudo-localization');
import pseudoLocalization from 'pseudo-localization';
// Or using CommonJS
// const pseudoLocalization = require('pseudo-localization').default;

@@ -74,3 +76,3 @@ pseudoLocalization.start();

You can also call the underlying `localize` function to pseudo-localize any string.
You can also call the underlying `localize` function to pseudo-localize any string. This is useful for non-browser environments like nodejs.

@@ -80,4 +82,4 @@

import { localize } from 'pseudo-localization';
// OR
import localize from 'pseudo-localization/localize';
// Or using CommonJS
// const { localize } = require('pseudo-localization');

@@ -88,3 +90,3 @@ console.log(localize('hello')); // --> ħḗḗŀŀǿǿ

A good use-case for `localize` is testing that strings are _actually_ being localized and not hard coded.
A good use-case for `localize` is testing that strings are _actually_ being localized and not hard coded.

@@ -129,3 +131,3 @@ ```js

Bidi English is a fake RTL locale. All words are surrounded by
Bidi English is a fake [RTL](https://developer.mozilla.org/en-US/docs/Glossary/rtl) locale. All words are surrounded by
Unicode formatting marks forcing the RTL directionality of characters.

@@ -147,4 +149,33 @@ In addition, to make the reversed text easier to read, individual

## Docs
`pseudo-localization` exports three functions.
- `pseudoLocalization.start(options)`
- `pseudoLocalization.stop()`
- `pseudoLocalization.localize(string, options)`
### `pseudoLocalization.start(options)`
Pseudo localizes the page and watched the DOM for additions/updates to continuously pseudo localize new content.
Accepts an `options` object as an argument. Here are the keys in the `options` object.
#### `strategy` - default (`'accented'`)
The pseudo localization strategy to use when transforming strings. Accepted values are `accented` or `bidi`.
#### `blacklistedNodeNames` - default (`['STYLE']`)
An array of [Node.nodeName](https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName) strings that will be ignored when localizing. This is useful for skipping `<style>`, `<text>` svg nodes or other nodes that potentially doesn't make sense to apply pseudo localization to. `<style>` is skipped by default when `blacklistedNodeNames` is not provided.
### `pseudoLocalization.stop()`
Stops watching the DOM for additions/updates to continuously pseudo localize new content.
### `pseudoLocalization.localize(string, options)`
Accepts a string to apply pseudo localization to. Returns the pseudo localized version on the string.
This function is used by `pseudoLocalization.start` internally.
Accepts an `options` object as an argument. Here are the keys in the `options` object.
#### `strategy` - default (`'accented'`)
The pseudo localization strategy to use when transforming strings. Accepted values are `accented` or `bidi`.
## Support
Works in all evergreen browsers.
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc