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

wc-translate

v0.0.14

Published

Package used for working with i18n (translations) in stencil.js.

Downloads

9

Readme

Web-Components-i18n

This repository was made mostly with Stencil.js in mind but hopefully will receive more love and will be extended to cover more web components loving frameworks.

How to?

  1. Run init to create initial configuration in your main directory.
  2. Create directory you've provided in config (default is src/locales/i18n) and create there a default translation file (derfault is en.js).
  3. Run extract to extract all of your translations.

How it works?

The module fills your files with translations found in your components. Module saves them as objects with key being an original string and value being a translation. For default language they are the same, for any additional language it will be ERR! No translation! until you provide translations to this file.

To extract translations make sure that your components are using attributes given in config - for instance trText="Text to be translated." will generated a key-pair in default translation of "Text to be translated.": "Text to be translated." and in every other locale file: "Text to be translated.": "ERR! No translation!".

This module does more though - it can also extract translations from ts/js files and even work with them! All you need to use is a function called reduceTranslations which gets following arguments:

  1. translations translations object (np. content of default translation).
  2. translationEntry which is essentially a text that is meant to be translated. The one that serves as a key in locale files.
  3. vars optional parameter to work with string literals that contain variables.
String literals

To work with string literals be sure to put them as simple strings, for instance: "This is variable ${this.world}" and to use this quantifier.

Side note: This behaviour will be altered soon and need of quantifier will be deprecated.

CLI

This module is, for now, only a CLI with following commands:

  • init (Generates basic configuration.)
  • extract-default (Extracts default translation.)
  • extract (Extracts all translations.)

Sidenote: To use extract you have to create files first. For instance - you have default translation called en.js so if you want to have translations for norwegian language you have to add manually no.js and run extract. This will fill no.js with untranslated strings.

Todo

  • Clean up
  • Tests
  • Make it more bulletproof
  • Create translation files automatically by giving an array of names in the config.
  • Export translation files to google drive.
  • Import translation files from google drive.

Export / import from google should make translator's life easier.