npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pseudo-translate

v1.0.0

Published

A compact and flexible utility for pseudo-translating i18n resources.

Downloads

5

Readme

pseudo-translate

Node.js CI

A compact and flexible utility for pseudo-translating i18n resources.

→ «Ä çömpäçt äñd fléxïblé ütïlïty föř pséüdö-třäñslätïñg ï18ñ řésöüřçés.»

Pseudo-translation is the process of mimicking the actual translation of a string into another language. It's a readable, dummy translation used to test if an application will function correctly in another language.

Use it to:

  • Verify that all UI text has been extracted into i18n resources. Pseudo-translation makes it easy to spot the strings you missed.
  • Test that your UI can handle translations of varying length to avoid unintended word wrapping or truncation issues.
  • Detect string concatenation issues in your UI before they break real translations. Leave language structure and word declension details to the translation experts.

Integrate this utility into your development process for quick feedback on string-extractions while globalizing your software, or for periodic smoke testing your localization workflow.

Installation

Install using npm:

$ npm -i pseudo-translate

Then include ptify with:

const ptify = require('pseudo-translate');

Objects

Pseudo-translate a JSON object containing your i18n resource strings. Such as:

const obj = {
    "USERS": {
        "MSG": "Welcome {{FNAME}} {{LNAME}}, nice to see you!"
    }
};
const pt = ptify(obj);

which results in pt containing:

{
    "USERS": {
        "MSG": "«Wélçömé {{FNAME}} {{LNAME}}, ñïçé tö séé yöü!»"
    }
}

Notice that the string interpolation place-holders FNAME and LNAME are left un-touched so that your i18n extraction library's variable substitutions will still work as expected. See: https://www.i18next.com/translation-function/interpolation for details on the default supported syntax.

Files

Pseudo-translate an entire file by passing in the path to your i18n resource JSON file:

const pt = ptify('./locales/en-US.json');

It returns a object who's text values have been pseudo-translated.

Configuration

Options include:

  • Translations vary in length and your UI should be able to accommodate these variations. To increase the pseudo-translation length by approximately 30%, pass in the following options object:

    const enu_obj = { MSG: 'Welcome {{ USER }}, please click {{HERE}}' };
    const options = {
        increase_lengh_30_pct: true
    };
    const pt = ptify(enu_obj, options);

    which results in:

    { MSG: '«Wélçömé {{ USER }}, pléäsé çlïçk {{HERE}} ω ä Ý Ä ñ ï»' }
  • Unicode "bookends", e.g. « and », are included by default to help identify string concatenation issues. For example:

    { "SUBMIT": "«Sübmït»" }

    To disable bookends, pass in the following option:

    const enu_obj = { "SUBMIT": "Submit" };
    const options = {
        include_unicode_bookends: false
    };
    const pt = ptify(enu_obj, options);

    resulting in:

    { "SUBMIT": "Sübmït" }

Issues

If you have any feature requests or bugs to report please add them here: https://github.com/rorsini/pseudo-translate/issues

Thanks for your support!