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

sciter-i18n

v2.0.1

Published

A translation engine for [sciter.js](https://sciter.com/) on top of [i18next](https://www.i18next.com/).

Downloads

15

Readme

sciter i18n

A translation engine for sciter.js on top of i18next.

sciter i18n screenshot

IMPORTANT NOTE From 4.4.8.14, sciter.js offers native translation support.

demo

  • git clone the repository
  • install packages npm install
  • install latest sciter sdk npm run install-sdk
  • start the demo npm run scapp

demo requirements

  • A recent version of Node.js node (tested with 16 LTS) and its package manager npm.

add to your project

using npm

  • install package npm install sciter-i18n

copy source

  • add the src dir to your project
  • in <script type="module">
// import from npm package
import I18n from "node_modules/sciter-i18n/src/i18n.js";

// import from src dir
import I18n from "src/i18n.js";

document.on("ready", function() {
    const locale = "fr";
    const file   = URL.toPath(__DIR__ + `locales/${locale}.json`);
    const config = {
        // i18n logging
        logging: true,

        // debug i18next
        debug: true,
    };

    // initialize translation engine
    if (I18n.init(locale, file, config)) {
        console.log("i18n init - OK");

        // translate window
        I18n.i18n(document);
    }
});
  • create translation file locales\fr.json
{
    "translation": {
        "key1": "test du moteur i18n"
    }
}
  • then in the html code add attribute data-i18n to all elements you want translated. If the data-i18n attribute value is set then it will be used as the translation key.
<h1 data-i18n="key1">i18n engine test</h1>
  • otherwise the element's innerText will be the key
<h1 data-i18n>h1</h1>

translate text in code

// with 2 arguments, first serves as key, second as default value (better option)
let message = I18n.m("no-update", "Widget could not be updated.");

// with a single argument, it's both the key and the default value
let message = I18n.m("Widget could not be updated.");

interpolation

The basics

let message = I18n.m("Widget failed with error {{error_number}}.", { eror_number: 18 });

Interpolation can also be set at initialization to apply to all translations.

const config = {
    interpolation: {
        defaultVariables: {
            name: "Yuri",
            country: "Russia",
        },
    },
};

I18n.init(locale, path, config);

let message = I18n.m("My name is {{name}} and I'm from {{country}}.");

todo

  • i18next file system backend or fetch backend
  • add missing ids to json
  • how to deal with interface refresh?