1.0.19 • Published 6 years ago

@ciortanmadalina/angular2-translations-synchroniser v1.0.19

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

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 :

keyvalue
key1Translated value for key 1
key2Translated 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:

keyenfrnl
key1Key 1 in EnglishKey 1 in FrenchKey 1 in Nl
key2Key 2 in EnglishKey 2 in FrenchKey 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:

keyenfrnl
key1Key 1 in EnglishKey 1 in FrenchKey 1 in Nl
key2Key 2 in EnglishKey 2 in FrenchKey 2 in Nl
1.0.19

6 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago