@translation/angular
Advanced tools
Comparing version 1.0.1 to 1.1.0
# Changelog | ||
## [v1.1.0](https://github.com/translation/angular/releases/tag/v1.1.0) (2022-09-30) | ||
#### New features: | ||
* New `proxy` option can be added to `tio.config.json` file. | ||
## [v1.0.1](https://github.com/translation/angular/releases/tag/v1.0.1) (2022-09-29) | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@translation/angular", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Translation.io client for Angular applications", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -33,2 +33,3 @@ # [Translation.io](https://translation.io/angular) client for Angular | ||
* [Localization syntax in details](#localization-syntax-in-details) | ||
* [Advanced configuration options](#advanced-configuration-options) | ||
* [List of clients for Translation.io](#list-of-clients-for-translationio) | ||
@@ -377,2 +378,17 @@ * [Ruby on Rails (Ruby)](#ruby-on-rails-ruby) | ||
## Advanced configuration options | ||
The `tio.config.json` file, at the root of your application, can take other optional configuration options. | ||
### Proxy | ||
If you need to use a proxy to connect to Translation.io, add the following line to your `tio.config.json` file: | ||
```json | ||
{ | ||
... | ||
"proxy": "http://login:pass@127.0.0.1:8080" | ||
} | ||
``` | ||
## List of clients for Translation.io | ||
@@ -379,0 +395,0 @@ |
const Interpolation = require('../utils/interpolation') | ||
const fs = require('fs') | ||
const fs = require('fs') | ||
const { XMLParser, XMLBuilder } = require('fast-xml-parser') | ||
const { parse: icuParse } = require('@formatjs/icu-messageformat-parser') | ||
const { parse: icuParse } = require('@formatjs/icu-messageformat-parser') | ||
const axios = require('axios').default | ||
const httpsProxyAgent = require('https-proxy-agent') | ||
@@ -50,2 +52,6 @@ class Base { | ||
proxy() { | ||
return this.options()['proxy'] | ||
} | ||
/*--------------------------*/ | ||
@@ -240,2 +246,19 @@ /* XML Parser/Builder Utils */ | ||
/*-----------------------------------------------------------*/ | ||
/* Wrapper for the axios client using a proxy, if applicable */ | ||
/*-----------------------------------------------------------*/ | ||
axiosClient() { | ||
let clientOptions = {} | ||
let proxy = this.proxy() | ||
if (proxy) { | ||
clientOptions = { | ||
httpsAgent: httpsProxyAgent(proxy) | ||
} | ||
} | ||
return axios.create(clientOptions) | ||
} | ||
/*----------------------------------------*/ | ||
@@ -242,0 +265,0 @@ /* Save target .xlf files after init/sync */ |
const Base = require('./base') | ||
const fs = require('fs') | ||
const axios = require('axios').default | ||
const fs = require('fs') | ||
@@ -57,3 +56,5 @@ class Init extends Base { | ||
const url = `${this.endpoint()}/v1/segments/init.json?api_key=${this.apiKey()}` | ||
// 4. Send source/target segments and save response | ||
const axios = this.axiosClient() | ||
const url = `${this.endpoint()}/v1/segments/init.json?api_key=${this.apiKey()}` | ||
@@ -60,0 +61,0 @@ axios.post(url, request, { headers: { 'Content-Type': 'application/json' }}) |
const Base = require('./base') | ||
const fs = require('fs') | ||
const axios = require('axios').default | ||
const fs = require('fs') | ||
@@ -39,3 +38,4 @@ class Sync extends Base { | ||
// 2. Send source segments and save translated target segments | ||
const url = `${this.endpoint()}/v1/segments/sync.json?api_key=${this.apiKey()}` | ||
const axios = this.axiosClient() | ||
const url = `${this.endpoint()}/v1/segments/sync.json?api_key=${this.apiKey()}` | ||
@@ -42,0 +42,0 @@ axios.post(url, request, { headers: { 'Content-Type': 'application/json' }}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45679
624
451
1