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

ngxe

v1.3.3

Published

Angular 11.1+ JSON Translations Editor.

Downloads

164

Readme

npm version CI

📜 ngxe

Angular 11.1+ JSON Translations Editor.

A simple UI for your translations: hosted on NPM, runs on your dev machine.

Features

  • Works directly with your files, no additional routine.
  • Any number of locales.
  • Diff changes.
  • Filters, handy pagination.
  • Suggestions based on similar sources.
  • Themes: light, solarized, dark.

ngxe screenshop

Installation

$ npm i ngxe -D

Usage

Create ngxe.json config file in the root:

{
  "name": "Project Name",
  "input": "path/to/messages.json",
  "output": {
    "source": "path/to/messages.source.json",
    "translations": [
      {
        "locale": "de",
        "path": "path/to/messages.de.json"
      }
    ]
  }
}
  • input - file generated by Angular, you can add it to .gitignore
  • output.source - copy of the input file, but ordered by keys (need for further transitions and smooth committing to Git).
  • output.translations - target locales.

Extract translations from your project in JSON format:

$ ng extract-i18n --format=json

The editor works best if i18n messages have IDs, but it is not necessary:

<div i18n="@@MSG_ID">Message with ID</div>
...
$localize`:@@MSG_ID_2:Message with ID 2`;

Use ngxe:

$ npx ngxe

Browser should open the app (http://localhost:7600/).

Use the ngxe app to update messages and press Save Project (all output files will be updated).

Optional config path:
$ npx ngxe -p=./path/to/ngxe.json

Build your app

  1. You can use the default flow with separated build for each lang.
  2. Or import messages on the app bootstrapping in main.ts:
import { loadTranslations } from '@angular/localize';

...

loadMessages()
  .then(() => {
    platformBrowserDynamic().bootstrapModule(AppModule);
  })
  .catch(err => console.error(err));
  
async function loadMessages() {
  // Detect lang and compile proper path to messages here:
  const path = ...;
  const m = await import(path);
  loadTranslations(m.translations);
}

Config

Interface of the ngxe.json file: meta/config.ts

Convert existing xlf files to json

$ npm i @locl/cli -D
$ npx locl convert -s=path/to/messages.de.xlf -f=json -o=path/to/messages.de.json

You can get error: The translation file "path/to/messages.de.xlf" does not contain a target locale and no explicit locale was provided for this file.

Make sure you have the target-language attribute in xlf file:

<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en" target-language="de" ...>
    ...

After that you can delete @locl/cli package.

Online editor — ngxe.oleksanovyk.com

Useful for delegating translation process. Use "Export"/"Import" options at the ngxe dashboard.