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

ultimate-i18n-js

v0.0.3

Published

Ultimate internationalization library for web applications.

Downloads

4

Readme

Ultimate I18n JS

Ultimate I18n JS 🤯

Build Status License: MIT View this project on NPM Twitter: b4rtaz

Ultimate internationalization library for web applications.

  • Super simple & easy.
  • Less than 1KB (minified and gziped).
  • 0 dependencies.
  • SEO friendly (default language will be indexed).
  • Automatic a user's language detection.
  • It remembers a language change (uses local storage).
  • JavaScript / TypeScript support.
  • Support all modern browsers (it uses the MutationObserver internally).

🤩 Online Examples

🚀 Use with Static HTML Web App

Set your default language code in the html tag.

<html lang="en">

Add this library as the first script in your <head> section.

<head>
   <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/index.min.js"></script>
   ...
</head>

That's it! 🤯 Now you can add language attributes to any element on your page.

<body>
  <h1
    i18n-pl="Witaj świecie"
    i18n-es="Hola Mundo">
    Hello World <!-- Your default language (en) -->
  </h1>

To change language call the set function.

UltimateI18n.set('es');
<button onclick="UltimateI18n.set('en');">EN</button>
<button onclick="UltimateI18n.set('es');">ES</button>
<button onclick="UltimateI18n.set('pl');">PL</button>

➡ Check examples for static HTML web apps

🚀 Use with Module Bundler

Install this package.

npm install ultimate-i18n-js

Set your default language code in the html tag.

<html lang="en">

Call the setup method before your app start.

import * as UltimateI18n from 'ultimate-i18n-js';

UltimateI18n.setup();

That's it! 🤯 Now you can add dynamicaly content to your app.

document.addEventListener('DOMContentLoaded', () => {
  document.getElementById('placeholder').innerHTML = `
    <span
      i18n-pl="Kocham czerwony"
      i18n-es="Amo el rojo">
      I love red
    </span>
  `;
});

To change language call the set function.

UltimateI18n.set('es');

➡ Check examples for Webpack apps

⚒ API

  • UltimateI18n.set('es') - Changes the current language.
  • UltimateI18n.get() - Reads the current language.
  • UltimateI18n.setup() - Initializes the library. This step is required only for a late setup.
  • UltimateI18n.isSupported - Returns true if the library is enabled, otherwise false.

👷‍♂️ TODO

React and Angular is not supported yet.

The dynamic attribute change is not supported yet. The below code currently doesn't work properly.

const season = document.getElementById('season');
season.innerHtml = 'Summer';
season.setAttribute('i18n-pl', 'Lato');
season.setAttribute('i18n-es', 'El verano');

Use the below approach instead. Basically you need to replace a whole element.

document.getElementById('seasonContainer').innerHTML = `
   <h2
      i18n-pl="Lato"
      i18n-es="El verano">
      Summer
   </h2>`;

Or:

const newSeason = document.createElement('h2');
newSeason.innerHtml = 'Summer';
newSeason.setAttribute('i18n-pl', 'Lato');
newSeason.setAttribute('i18n-es', 'El verano');

oldSeason.replaceWith(newSeason);

💡 License

This project is released under the MIT license.