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 🙏

© 2026 – Pkg Stats / Ryan Hefner

t10

v1.0.2

Published

Translation for browser

Downloads

36

Readme

t10 v1.0.2

Greenkeeper badge

Translation for browser, 642B minified+gzipped

CircleCI codecov js-standard-style

Usage

First, load the script:

<script type="text/javascript" src="path/to/t10.js"></script>

Second, set the translation resource:

t10.setResource({
  id_foo: 'Translated foo!',
  id_bar: 'Translated bar!',
  id_baz: 'Translated baz!'
});

Finally, perform the translation:

t10.scan();

That's it. This performs the translation on the entire page synchronously.

With the above call the following html:

<p>
  <t>id_foo</t>
  <span class="t-text-done">id_bar</span>
  <input class="t-attr-done" placeholder="t:id_baz" />
</p>

Changes in to:

<p>
  Translated foo!
  <span class="t-text">Translated bar!</span>
  <input class="t-attr" placeholder="Translated baz!" />
</p>

Alternatively you can use via npm.

First install t10 locally:

npm i t10

Then require / import it and use it:

const t10 = require('t10');

or:

import * as t10 from require('t10');

The rest is the same.

What t10.scan() translates

t tag

...<t>str_id</t>...

translated into:

...translated str_id...

.t-text class

<span class="t-text">str_id</span>

translated into:

<span class="t-text-done">translated str_id</span>

.t-attr class

<input type="text" class="t-attr" placeholder="t:str_id" />

translated into:

<input type="text" class="t-attr-done" placeholder="translated str_id" />

Hide untranslated elements

You can hide untranslated elements by the following style:

t, .t-text, .t-attr {
    visibility: hidden;
}

Note: t tag and .t-text, .t-attr classes are going to be removed after the translation.

Select the best fit language from available list

Basic Usage

t10.setAvailables(['en', 'fr', 'ja']).getBestLanguage('ja'); // => 'ja'
t10.setAvailables(['en', 'fr', 'ja']).getBestLanuuage('de'); // => 'en' # the first available is the default
t10.setAvailables(['en', 'fr', 'ja']).getBestLanguage('en.US'); // => 'en'
t10.setAvailables(['en', 'fr', 'ja']).getBestLanguage('ja.JP'); // => 'ja'

Typical Usage

var language = t10.setAvailables(['en', 'fr', 'ja']).getBestLanguage(getFromSystem());

$.getScript('path/to/resource/' + language + '.js').then(function () {
    t10.scan();
});

Translate

t function translates a single key.

t10.setResource({pen: 'ペン'});

t10.t('pen'); // => ペン

Dependency

  • None

License

MIT License (Yoshiya Hinosawa)