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

@ciortanmadalina/angular2-translations-synchroniser

v1.0.19

Published

Downloads

25

Readme

Angular 2 translations synchroniser

This project offers the following translation management functionalities for angular2 projects.

Install

npm install -g @ciortanmadalina/angular2-translations-synchroniser

Synchronise HTML translation placeholders used in given folder with json translations files

This command line tool can be used like:

synchroniseTranslations --scanFolder ./src --translationFolder ./src/i18n --preferredLanguage en --missingLabel ## 

It performs the following 3 steps:

  1. Parses all html files found in given scanFolder and extracts all translation placeholders. It exports these keys as a Map of custom type TranslationCollection with default values missingLabel + key value.
    For instance if an html file uses {{'mykey' | translate}} the map will hold {'mykey': '##mykey'} (missingLabel + key)

  2. For all json files found in translationFolder, adds the above missing labels {'mykey': '##mykey'}

  3. Parses all translations files from translation folder and generates more meaningful placeholders for the keys which were defined in one file and missing in others. For instance if we have 3 translation files and the key was added to only one of them ({'mykey': 'Value'}), the other files will be updated with ({'mykey': '##Value'}). The file which will provide the reference values will be the one corresonding to the input preferred language (en.json by default), but if it doesn't have a declared value the script will pick one from any other file.

Update translation files with new content as json/csv/xls

This functionality facilitates the global update of translated labels with content managed by business, which can be provided as json/CSV/xls.

The command line tool can be used like:

mergeTranslations --translationFolder ./src/i18n --updateFolder ./updateFolder

This script updates translation files found in given translationFolder with new lables from given updateFolder.
It takes all json files found in updateFolder and merges them with corresonding files in translationFolder, by name. Thus, the en.json in updateFolder will overwrite en.json in translationFolder, etc.

If updateFolder contains CSV files, the first step is to convert them to json. For instance

key1,Value Key 1
key2,Value Key 2

Becomes :

{
    'key1':'Value Key 1',
    'key2':'Value Key 2'
}

Alternatively, updateFolder may contain xls files which will be parsed.
One single xls file may contain the labels for all languges, as the parser will aggregate all excel sheets named after an existing language (2 letters lowercase iso code).

For instance, an excel file may contain on sheet en the following values under a key - value header :

| key | value |
|---|---| | key1 | Translated value for key 1 | | key2 | Translated value for key 2 |

This will generate a json like :

{
    "key1" : "Translated value for key 1",
    "key2" : "Translated value for key 2"
}

These Json files with overwrite the values found in corresonding json translation files in translationFolder.

The code uses https://github.com/ciortanmadalina/angular2-translations-synchroniser.

Export Json files to Excel

This functionality exports all content of json files to one excel sheet with columns for each supported language. It can be called from the command line:

jsonToExcel --jsonInputFolder ./src/i18n --outputExcelFile ./input/labels.xlsx

Excel file will look like:

| key | en | fr | nl | |---|---| ---|---|---| | key1 | Key 1 in English | Key 1 in French | Key 1 in Nl | | key2 | Key 2 in English | Key 2 in French | Key 2 in Nl |

Update Json files from Excel

This functionality updates json translation files with content from the excel file.

It can be called from the command line:

excelToJson --inputExcelFile ./input/labels.xlsx --outputJsonFolder ./src/i18n

Excel file has the following format:

| key | en | fr | nl | |---|---| ---|---|---| | key1 | Key 1 in English | Key 1 in French | Key 1 in Nl | | key2 | Key 2 in English | Key 2 in French | Key 2 in Nl |