Socket
Socket
Sign inDemoInstall

@talend/i18n-scripts

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@talend/i18n-scripts - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

common/error.js

31

package.json
{
"name": "@talend/i18n-scripts",
"version": "0.1.0",
"description": "Download i18n locales for current version of package",
"description": "Set of scripts to ease i18n workflow",
"version": "0.1.1",
"license": "Apache-2.0",
"main": "index.js",
"bin": {
"download-locales": "./download-locales/index.js"
"talend-i18n": "./index.js"
},
"author": "Talend Frontend <frontend@talend.com>",
"homepage": "https://github.com/Talend/ui/tree/master/packages/i18n-scripts#readme",
"homepage": "https://github.com/Talend/i18n-product/scripts#readme",
"bugs": {
"url": "https://github.com/Talend/ui/issues"
"url": "https://github.com/Talend/i18n-product/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/Talend/ui.git"
"url": "https://github.com/Talend/i18n-product.git"
},
"license": "Apache-2.0",
"dependencies": {
"download": "^7.0.0"
"adm-zip": "0.4.11",
"chalk": "^2.4.1",
"cross-spawn": "^6.0.4",
"form-data": "^2.3.3",
"lodash.template": "^4.4.0",
"lodash.templatesettings": "^4.1.0",
"merge-dirs": "^0.2.1",
"mkdirp": "^0.5.1",
"node-fetch": "^2.2.0",
"rimraf": "^2.6.2",
"shelljs": "^0.8.2",
"xml2json": "^0.11.2"
},
"publishConfig": {
"access": "public"
}
}

@@ -1,14 +0,227 @@

# @talend/i18n-scripts
Collection of i18n-related scripts
# Talend i18n scripts
# download-locales
Download-locales will download locales from zip files attached to the Github releases for the current release. This way, if we put the script in `postinstall`, we don't have to wait for locales before publishing ui packages, but we can update them after. Apps that install ui packages using this script will get up-to-date locales when they do yarn install.
<img src="./process.png">
Name of zip should be "[package.json name (minus `@talend/`)]-loales.zip"
The i18n process has multiple steps
Add this script in package.json:
1- Extract and upload
2- Translation within the cloud system
3- Download and versionning to github
4- Download translated files to the bundle
The @talend/i18n-scripts module targets steps 1 - 2 - 3.
# Installation
```shell
yarn global install @talend/i18n-scripts
```
or
```shell
npm install -g @talend/i18n-scripts
```
Now the cli `talend-i18n` is available.
# Actions
There are 4 actions you can perform
```shell
talend-i18n extract
talend-i18n upload
talend-i18n download
talend-i18n deploy
```
# Configuration
The scripts are based on a `talend-i18n.json` configuration file at project root.
## Extract
This step will extract the i18n files from the project and create a zip.
All the files will be wrapped in a folder with your app extracted version.
The version (major.minor) is taken from files at project root.
* lerna.json
* pom.xml
* package.json
There are 4 methods of extraction
- npm : run an npm script
- yarn : same as npm but with yarn
- files : get the files from a list of path
- expression : get the files matching an expression, starting with a provided folder
*Npm/Yarn*
```json
"scripts": {
"postinstall": "download-locales"
{
"extract": {
"method": "npm",
"script": "extract-i18n",
"target": "./i18n",
"transform": "flatten"
}
}
```
| Configuration | Description |
|---|---|
| method | `npm` or `yarn` |
| script | The npm script name |
| target | The folder where the npm script will gather the translation files. This is used to create the zip file. |
| transform | Optional. Transformation to apply to file hierarchy. For now only `flatten` is accepted, putting all file directly under the target language folder. |
*Files*
```json
{
"extract": {
"method": "files",
"files": ["./src/i18n/translation.json", "./src/app/other.json"],
"target": "./i18n"
}
}
```
| Configuration | Description |
|---|---|
| method | `npm` or `yarn` |
| files | The list of files to extract. |
| target | The folder where the script will gather the translation files. This is used to create the zip file. Note that the files folder hierarchy is preserved. |
*Expression*
```json
{
"extract": {
"method": "expression",
"rootPath": "./src",
"expression": "message*.json",
"target": "./i18n"
}
}
```
| Configuration | Description |
|---|---|
| method | `expression` |
| rootPath | The folder to start the search. |
| expression | Expression describing the files name. You can use `*` as wildcard. `message*.json` means every files that start with `message` and end with `.json` (ex: message-errors.json, message.json, ...), whereas `message.json` matches only the `message.json` files. |
| target | The folder where the script will gather the translation files. This is used to create the zip file. Note that the files folder hierarchy is preserved. |
## Upload/Download
You need to pass xtm information as environment variables
```shell
> XTM_API_URL=https://XXX \
XTM_CUSTOMER_ID=YYY \
XTM_TOKEN=ZZZ \
talend-i18n <upload|download>
```
| Variable | Description |
|---|---|
| XTM_API_URL | The XTM api url |
| XTM_CUSTOMER_ID | The XTM customer ID |
| XTM_TOKEN | The XTM authentication token |
### Upload
This step will upload previously created i18n zip to XTM.
```json
{
"load": {
"project": "UI"
}
}
```
| Configuration | Description |
|---|---|
| project | The XTM project name. |
### Download
This step will download, unzip and transform files from XTM.
```json
{
"load": {
"project": "UI"
}
}
```
| Configuration | Description |
|---|---|
| project | The XTM project name. |
It will download only the files corresponding to the current version of your project (version extracted). If no version is detected, all versions will be downloaded.
### Deploy
This step will push downloaded i18n files to github. Files will be generated to create a npm or maven module. For now, no module is deployed on npm/mvn repositories.
You need to pass github credentials as environment variables.
```shell
> GITHUB_LOGIN=XXX \
GITHUB_TOKEN=YYY \
talend-i18n deploy
```
| Variable | Description |
|---|---|
| GITHUB_LOGIN | Github username that will be used to push to the locales repo |
| GITHUB_TOKEN | Github token |
`talend-i18n.json` configuration
```json
{
"github": {
"url": "https://github.com/Talend/locales.git"
},
"module": {
"type": "mvn",
"private": true,
"repository": {
"id": "private-releases",
"url": "https://mydomain.com/nexus/content/repositories/MyPrivateSourceRelease"
}
}
}
```
| Configuration | Type | Description |
|---|---|---|
| github.url | `string` | The https git url. |
| module.type | `string` | The module type to deploy (`npm` | `mvn`). |
| module.private | `boolean` | If the module should be private. |
| module.repository | `object` | This will be set in pom.xml for `mvn` modules. It should reflect the repository this module should be released. |
| module.repository.id | `string` | The repository id. |
| module.repository.url | `string` | The repository url. |
The i18n files will be pushed to a branch `{XTM_project}/{version}`.
With this branch structure, the locales for your project can be downloaded from a defined url.
```
https://github.com/{github_org}/{repo_name}/archive/{XTM_project}/{version}.zip
```
In the example :
```
https://github.com/Talend/locales/archive/UI/1.10.zip
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc