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

tr-create

v1.0.0

Published

Finds __text to be translated__ in a specified HTML file and creates en.json plus new HTML file with {{ 'nameSpace.textToBeTranslated' | translate }}.

Downloads

16

Readme

tr-create

This project is focused mainly on angularjs projects using angular-translate.

Instalation

$ npm install -g tr-create

The Idea

Sometimes we are focused on the implementation and not on the copy text. We don't want our HTML/CSS/JS work to be bothered with the creation of the translate files for different languages. So we leave "Lorem ipsum" text or in my case "__text to be translated later__".

After the work is done, we run that script and it:

  • creates JSON files for translations (en.json or es.json) - if your JSON exists, we will merge the new content with the old one and will replace the existing file with the fresh content.
  • creates HTML file with {{ 'global.someText' | translate }} placeholder instead of __some text__

Usage

$ tr-create -s untranslated.html -t translated.html -l langs/en.json

Example:

untranslated.html content:

<!DOCTYPE html>
<html>
<head>
  <title>Example</title>
</head>
<body>
<div>__Please translate me__</div>
<h1>__I need a translation__</h1>
<p>__Please somebody to translate this text__</p>
</body>
</html>

execute:

tr-create -s untranslated.html

By default it will create:

  • en.json:
{
  "pleaseTranslateMe": "__Please translate me__",
  "iNeedATranslation": "__I need a translation__",
  "pleaseSomebodyToTranslateThisText": "__Please somebody to translate this text__"
}
  • untranslated_tr.html:
<!DOCTYPE html>
<html>
<head>
  <title>Example</title>
</head>
<body>
<div>{{'global.pleaseTranslateMe' | translate }}</div>
<h1>{{'global.iNeedATranslation' | translate }}</h1>
<p>{{'global.pleaseSomebodyToTranslateThisText' | translate }}</p>
</body>
</html>

Options

exmpale
tr-create -s [html_source_file] -l [language_json_file] -n [name_space]

-s,  --source
HTML file containig __text to translate__ dummy text

-r,  --replace
Replace the existing HTML with translations content

-n,  --name-space
Name space to be used in HTML translations: {{ 'nameSpace.textToBeTranslated' | translate }}

-l, --lang
Comma separated JSON file name for the languages.
You can provide full path if you need.
JSON extension will be added automatically if omitted
Example:
-l langs/en.json,langs/es.json
-l en,es

--ol, --only-language
Create only a language without HTML file

-t, --target-html
HTML file to be created with translation placeholders. If not specified we will create a new one with sufix.

-h, --help
Prints this help

MIT License

Contribute

If you have an idea or special needs that this tool doesn't cover don't hesitate to fork and add the needed feature. There is only one requirement - use ES6 and babel.

Changelog

v1.0.0

  • Changed -ol option to --ol
  • Added -r, --replace option - if set the existing HTML file provided by -s will be overwritten with the translations content
  • Multiple JSON files - comma separated: --lang en.json,es.json - or en,es (JSON extension will be added automatically if omitted)
  • Unit tests

v0.0.3