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

textualization

v0.6.2

Published

Dot notation based translate -> i18n('path.to.mi.text',{...params...},lang);

Downloads

36

Readme

Textualization

license Build Status npm version Github release npm downloads

Very simple internationalization (aka i18n) manager for Node.js

Textualization offers the possibility of not writing any user text message in your JS code. Allows to translate your code into any language without having to learn a complex methodology.


Textualization in 5 minutes:

Usual way for writing without i18n support:

var message = "User " + username + " has been disconnected at " + time + ".";

Usual way for programming with others i18n systems, something like:

var message = i18n.translate(
  "User %s has been disconnected at %s",
  [user.firstName+" "+user.lastName, time.toUTCString()],
  language
);

And a translation sheet entry similar to:

...
"User %s %s has been disconnected at %s." = "El usuario %s %s se ha desconectado a las %s.";
...
...

Textualization way:

var message = i18n('user.messages.logOut',{user:user, time:time}));

And translate by JSON i18n sheets, with direct dot-notation reference {} or evaluated expressions ·{}·:

{
  user: {
    messages: {
      logOut: "The user {user.firstName} {user.lastName} has been disconnected at ·{time.toUTCString()}·",
      ...
    },
    ...
  },
  ...
}

More possible uses (See String.format):

...:"The user ·{username.toUpperCase()}· has been logged out.",
...:"New properties ·{Object.keys(props).join(',')}· added!",
...:"Welcome {user.firstName} {user.lastName}!"

Easy numerals/plurals for every language:

i18n('mail.inbox.status', 5);             // Short version
i18n('mail.inbox.status', {_num_:5,...}); // For support of aditional params

Translation entry as array of numeral options:

...:[
      "No messages in the inbox",
      "There is a message in the inbox",
      "There are {_num_} messages in the inbox"
    ]

And direct objects and arrays parsing as JSON.

"The Object {myObj} is loaded." ==> "The Object {a:'A',b:'B'} is loaded."
"The Array {myArray} is loaded." ==> "The Array ['A','B','C'] is loaded."

Along with a simple translation sheet load system:

// Hypothetical working directory
myApp/
     /languages/
               /en.json
               /es.json
               /de.json
               /ru.json
i18n.load('nameSpace', './languages');
i18n.languages = ['en', 'es'];

Textualization load from directory ./languages only i18n.languages defined, and refresh translations cache if this property changes.

Additionally also supports .js files. In this case is possible to use functions in translations sheets.

({
  hello: "Hello {name}!",
  bye: function (){return "Good bye" + name;}, // contextualized evaluation.
  ...
})

The brackets at the beginning and end of the statement are optionals. In some text editors allows to have a correct syntax highlighting.

Nothing more, that's all. Simple?

This repository is part of the Pillars.js core libraries. Any contribution, collaboration, issues... is well come ;)

contact Us!:

License

MIT