Giter Site home page Giter Site logo

azz / pseudo-localization Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tryggvigy/pseudo-localization

0.0 3.0 0.0 352 KB

Dynamic pseudo-localization in the browser

Home Page: https://codesandbox.io/s/03oq05816v

License: MIT License

HTML 98.72% JavaScript 1.28%

pseudo-localization's Introduction

Inspired by pseudo-localization at Netflix and Firefox

pseudo-localization

English Pseudo Language
screen shot 2018-08-12 at 1 23 18 pm after

pseudo-localization is a script that performs pseudolocalization against the DOM.

Demo here. 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.

Installation

Through npm

npm install pseudo-localization

Raw script (without npm)

Copy paste the script in it's entirty from here and use as you wish.

Usage

import or require the npm module

pseudo-localization is just a script and can be invoked like so:

const pseudoLocalization = require('pseudo-localization'); 

pseudoLocalization.start();

// Later, if needed
pseudoLocalization.stop();

To use pseudo-localization in React, Vue, Ember or anything else, hook the start and stop methods into your libraries component lifecycles. In React for example:

import React from 'react';
import pseudoLocalization from 'pseudo-localization';

class PseudoLocalization extends React.Component {
  componentDidMount() {
    pseudoLocalization.start();
  }
  componentWillUnmount() {
    pseudoLocalization.stop();
  }
}

// And use it

class Page extends React.Component {
  render() {
    return (
      <main>
       <PseudoLocalization />
       <h1>I will get pseudo localized along with everything else under document.body!</h1>
      <main>
    );
  }
}

Strategies

pseudo-localization supports two strategies:

  1. accented
  2. bidi

accented - Ȧȧƈƈḗḗƞŧḗḗḓ Ḗḗƞɠŀīīşħ

Usage: pseudoLocalization.start({ strategy: 'accented' }); or simply pseudoLocalization.start();.

In Accented English all Latin letters are replaced by accented Unicode counterparts which don't impair the readability of the content. This allows developers to quickly test if any given string is being correctly displayed in its 'translated' form. Additionally, simple heuristics are used to make certain words longer to better simulate the experience of international users.

screen shot 2018-08-19 at 18 48 29

bidi - ɥsıʅƃuƎ ıpıԐ

Usage: pseudoLocalization.start({ strategy: 'bidi' });.

Bidi English is a fake RTL locale. All words are surrounded by Unicode formatting marks forcing the RTL directionality of characters. In addition, to make the reversed text easier to read, individual letters are flipped.

screen shot 2018-08-19 at 18 45 49

Why?

To catch localization problems like:

  • Translated text that is significantly longer than the source language, and does not fit within the UI constraints, or which causes text breaks at awkward positions.
  • Font glyphs that are significantly larger than, or possess diacritic marks not found in, the source language, and which may be cut off vertically.
  • Languages for which the reading order is not left-to-right, which is especially problematic for user input.
  • Application code that assumes all characters fit into a limited character set, such as ASCII or ANSI, which can produce actual logic bugs if left uncaught.

Support

Works in all evergreen browsers.

pseudo-localization's People

Contributors

tryggvigy avatar fannargauti avatar

Watchers

James Cloos avatar Lucas Azzola avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.