GithubHelp home page GithubHelp logo

classicvalues / pseudolocalization Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shopify/pseudolocalization

0.0 0.0 0.0 129 KB

Small utility to generate fake pseudotranslations on all I18n.translate calls.

License: MIT License

Ruby 98.47% Shell 1.53%

pseudolocalization's Introduction

Pseudolocalization

Version Build Status

About this repo | How to use this repo | Contribute to this repo

About this repo

Why?

Internationalization is a hard and tedious process. Different character sets, different average word length, different pluralization rules... There's a lot going on and it's impossible to test against all possible scenarios. As a side effect, most of us will simply test against one or two known languages and hope for the best. Unfortunately, this often leads to broken UI elements, texts going out of bounds, or forgotten non-translated strings making their way into a final release.

As an example, let's examine the string "Set the power switch to 0.";

Language String Characters Percentage
English Set the power switch to 0. 26 chars -
French Placez l'interrupteur de tension à 0. 37 chars 42% more
Spanish Ponga el interruptor de alimentación de corriente en 0. 55 chars 112% more

It's easy to see that any hardcoded widths would likely break giving such a string. IBM suggests that on average, we should expect any English string to inflate by 30% when translating in another language.

In an attempt to ease this whole process, we created a small tool that gives you the ability to preview your product with pseudo-translations in a way that will;

  1. Identify untranslated strings
  2. Expand words by doubling all vowels
  3. Use English lookalike UTF8 characters for readability

How to use this repo

Installation

Add these lines to your application's Gemfile:

group :development do
  gem 'pseudolocalization', require: false
end

Execute:

$ bundle

Finally, in an initializer, add the following lines:

if Rails.env.development? && ENV["I18N_BACKEND"]
  case ENV["I18N_BACKEND"]
  when 'pseudolocalization'
    require 'pseudolocalization'
    I18n.backend = Pseudolocalization::I18n::Backend.new(I18n.backend)
  end
end

Usage

When working on internationalization, you can boot your server with the pseudolocalization backend to quickly identify content that doesn't go through the I18n framework.

I18N_BACKEND=pseudolocalization bundle exec rails server

Ignoring specific keys

You may wish to have the backend ignore specific keys. These may be configured via an array, ignores, on the backend. The array can contain a mix of strings (with globbing allowed) and/or Regexes.

I18n.backend = Pseudolocalization::I18n::Backend.new(I18n.backend)
I18n.backend.ignores = ['ignored*', /Waldo.$/]

How to run tests

bundle exec rake test

Other Resources

Contribute to this repo

Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/pseudolocalization.

pseudolocalization's People

Contributors

brendo avatar christianblais avatar colinross avatar dependabot-preview[bot] avatar haydenholligan avatar larouxn avatar lukashlavacka avatar movermeyer avatar plentz avatar shopify-admins avatar shopify-services avatar siddhantbajaj avatar tayre avatar tjoyal 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.