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

pdx-i18n

v3.0.7

Published

globalization tool

Downloads

5

Readme

pdx-i18n

what is this?

If you need a translation tool in your H5 project, try this

demo

Please link demo

feature

Support translate

  1. html
  2. placeholder
  3. variable

how to use?

  • install pxd-i18n package
npm i pdx-i18n
  • before use this ,add translate js file.
|-src
 |-i18n
   |-en
     |-module.js
   |-zh-cn
     |-module.js
   |-zh-hant
     |-module.js
   |-...

Please make sure the sub file name of en/zh-ch/... are same

  • import the module into main.js
import pdxI18n from 'pdx-i18n';
window.onload = function () {
  // Instantiation internationalization
  const myI18n = initI18N('zh-hant', 'add');

  // Simplified Chinese
  document.querySelector('#cn').addEventListener('click', ()=>{
    myI18n.setInnerHtml('zh-cn');
  });

  // traditional Chinese
  document.querySelector('#hant').addEventListener('click', ()=>{
    myI18n.setInnerHtml('zh-hant');
  });

  // english
  document.querySelector('#en').addEventListener('click', ()=>{
    myI18n.setInnerHtml('en');
  })
};

// Initialization internationalization
function initI18N(currentlang, currentFile) {
  const i18n =  new pdxI18n({
    currentLang: currentlang,
    useFileName: currentFile
  });
  i18n.setInnerHtml();
  return i18n;
}

index.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title></title>
</head>
<body>
<section>
  <div class="icon-bg"></div>
  <div id="create" class="lx-button lx-button-black i18n" data-i18n="btnCreate"><!--Create wallet--></div>
  <div id="import" class="lx-button i18n" data-i18n="btnImport"><!--Import wallet--></div>
  <button id="cn">zh-cn</button>
  <button id="hant">zh-hant</button>
  <button id="en">english</button>
  <br>
</section>
  <script src="./main.js"></script>
</body>
</html>

Please make sure project i18n file structure fit for under url ${window.location.href}i18n/${this.currentLang}/${this.useFileName}.js For example: http://xxx.xxx.xx:port/i18n/en/xxxx.js

api

new pdxI18n({currentLang: string,useFileName: string})

currentLang: the name of you create to put deffirent language file name . for example: en/zh-cn/zh-hant

useFileName: the name of module.js . for example: /en/module.js the useFileName is 'module'

   const i18n =  new pdxI18n({
      currentLang: currentlang,
      useFileName: currentFile
    });

setInnerHtml(lang: string)

translate html tag innerText value lang: currentLang

i18n.setInnerHtml('en');
or
i18n.setInnerHtml();

setPlaceholderLang(lang: string)

translate the placeholder of the element

  i18n.setPlaceholderLang('en');
  or
  i18n.setPlaceholderLang();

setObjsLang(variableName: string, lang: string, callback)

translate variable lang: needn't pass

const i18nObj = {};
i18n.setObjsLang('i18nObj', currentlang, data => {
    console.log(data);
});
or
myI18n.setObjsLang('i18nObj', 'en', data => {
   console.log(data);
});

the complete guide check the dome,please.