@vocab/phrase 1.3.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,8 +39,8 @@ This is the language Vocab will assume when it sees a `translation.json` file wi
39
39
  ```js
40
40
  // vocab.config.js
41
41
  module.exports = {
42
- languages: [{ name: 'en' }, { name: 'fr' }]
43
- devLanguage: 'en',
42
+ languages: [{ name: 'en' }, { name: 'fr' }],
43
+ devLanguage: 'en'
44
44
  };
45
45
  ```
46
46
 
@@ -5,8 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var fs = require('fs');
6
6
  var path = require('path');
7
7
  var core = require('@vocab/core');
8
- var FormData = require('form-data');
9
- var fetch = require('node-fetch');
10
8
  var pc = require('picocolors');
11
9
  var debug = require('debug');
12
10
  var sync = require('csv-stringify/sync');
@@ -14,8 +12,6 @@ var sync = require('csv-stringify/sync');
14
12
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
13
 
16
14
  var path__default = /*#__PURE__*/_interopDefault(path);
17
- var FormData__default = /*#__PURE__*/_interopDefault(FormData);
18
- var fetch__default = /*#__PURE__*/_interopDefault(fetch);
19
15
  var pc__default = /*#__PURE__*/_interopDefault(pc);
20
16
  var debug__default = /*#__PURE__*/_interopDefault(debug);
21
17
 
@@ -79,12 +75,12 @@ function _callPhrase(path, options = {}) {
79
75
  if (!phraseApiToken) {
80
76
  throw new Error('Missing PHRASE_API_TOKEN');
81
77
  }
82
- return fetch__default["default"](path, {
78
+ return fetch(path, {
83
79
  ...options,
84
80
  headers: {
85
81
  Authorization: `token ${phraseApiToken}`,
86
82
  // Provide identification via User Agent as requested in https://developers.phrase.com/api/#overview--identification-via-user-agent
87
- 'User-Agent': 'SEEK Demo Candidate App (jhope@seek.com.au)',
83
+ 'User-Agent': 'Vocab Client (https://github.com/seek-oss/vocab)',
88
84
  ...options.headers
89
85
  }
90
86
  }).then(async response => {
@@ -157,20 +153,18 @@ async function pushTranslations(translationsByLanguage, {
157
153
  } = translationsToCsv(translationsByLanguage, devLanguage);
158
154
  let devLanguageUploadId = '';
159
155
  for (const [language, csvFileString] of Object.entries(csvFileStrings)) {
160
- const formData = new FormData__default["default"]();
161
- const fileContents = Buffer.from(csvFileString);
162
- formData.append('file', fileContents, {
163
- contentType: 'text/csv',
164
- filename: `${language}.translations.csv`
165
- });
156
+ const formData = new FormData();
157
+ formData.append('file', new Blob([csvFileString], {
158
+ type: 'text/csv'
159
+ }), `${language}.translations.csv`);
166
160
  formData.append('file_format', 'csv');
167
161
  formData.append('branch', branch);
168
162
  formData.append('update_translations', 'true');
169
163
  formData.append('update_descriptions', 'true');
170
- formData.append(`locale_mapping[${language}]`, messageIndex);
171
- formData.append('format_options[key_index]', keyIndex);
172
- formData.append('format_options[comment_index]', commentIndex);
173
- formData.append('format_options[tag_column]', tagColumn);
164
+ formData.append(`locale_mapping[${language}]`, messageIndex.toString());
165
+ formData.append('format_options[key_index]', keyIndex.toString());
166
+ formData.append('format_options[comment_index]', commentIndex.toString());
167
+ formData.append('format_options[tag_column]', tagColumn.toString());
174
168
  formData.append('format_options[enable_pluralization]', 'false');
175
169
  log(`Uploading translations for language ${language}`);
176
170
  const result = await callPhrase(`uploads`, {
@@ -5,8 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var fs = require('fs');
6
6
  var path = require('path');
7
7
  var core = require('@vocab/core');
8
- var FormData = require('form-data');
9
- var fetch = require('node-fetch');
10
8
  var pc = require('picocolors');
11
9
  var debug = require('debug');
12
10
  var sync = require('csv-stringify/sync');
@@ -14,8 +12,6 @@ var sync = require('csv-stringify/sync');
14
12
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
13
 
16
14
  var path__default = /*#__PURE__*/_interopDefault(path);
17
- var FormData__default = /*#__PURE__*/_interopDefault(FormData);
18
- var fetch__default = /*#__PURE__*/_interopDefault(fetch);
19
15
  var pc__default = /*#__PURE__*/_interopDefault(pc);
20
16
  var debug__default = /*#__PURE__*/_interopDefault(debug);
21
17
 
@@ -79,12 +75,12 @@ function _callPhrase(path, options = {}) {
79
75
  if (!phraseApiToken) {
80
76
  throw new Error('Missing PHRASE_API_TOKEN');
81
77
  }
82
- return fetch__default["default"](path, {
78
+ return fetch(path, {
83
79
  ...options,
84
80
  headers: {
85
81
  Authorization: `token ${phraseApiToken}`,
86
82
  // Provide identification via User Agent as requested in https://developers.phrase.com/api/#overview--identification-via-user-agent
87
- 'User-Agent': 'SEEK Demo Candidate App (jhope@seek.com.au)',
83
+ 'User-Agent': 'Vocab Client (https://github.com/seek-oss/vocab)',
88
84
  ...options.headers
89
85
  }
90
86
  }).then(async response => {
@@ -157,20 +153,18 @@ async function pushTranslations(translationsByLanguage, {
157
153
  } = translationsToCsv(translationsByLanguage, devLanguage);
158
154
  let devLanguageUploadId = '';
159
155
  for (const [language, csvFileString] of Object.entries(csvFileStrings)) {
160
- const formData = new FormData__default["default"]();
161
- const fileContents = Buffer.from(csvFileString);
162
- formData.append('file', fileContents, {
163
- contentType: 'text/csv',
164
- filename: `${language}.translations.csv`
165
- });
156
+ const formData = new FormData();
157
+ formData.append('file', new Blob([csvFileString], {
158
+ type: 'text/csv'
159
+ }), `${language}.translations.csv`);
166
160
  formData.append('file_format', 'csv');
167
161
  formData.append('branch', branch);
168
162
  formData.append('update_translations', 'true');
169
163
  formData.append('update_descriptions', 'true');
170
- formData.append(`locale_mapping[${language}]`, messageIndex);
171
- formData.append('format_options[key_index]', keyIndex);
172
- formData.append('format_options[comment_index]', commentIndex);
173
- formData.append('format_options[tag_column]', tagColumn);
164
+ formData.append(`locale_mapping[${language}]`, messageIndex.toString());
165
+ formData.append('format_options[key_index]', keyIndex.toString());
166
+ formData.append('format_options[comment_index]', commentIndex.toString());
167
+ formData.append('format_options[tag_column]', tagColumn.toString());
174
168
  formData.append('format_options[enable_pluralization]', 'false');
175
169
  log(`Uploading translations for language ${language}`);
176
170
  const result = await callPhrase(`uploads`, {
@@ -1,8 +1,6 @@
1
1
  import { promises } from 'fs';
2
2
  import path from 'path';
3
3
  import { getAltLanguages, loadAllTranslations, getUniqueKey, getAltLanguageFilePath } from '@vocab/core';
4
- import FormData from 'form-data';
5
- import fetch from 'node-fetch';
6
4
  import pc from 'picocolors';
7
5
  import debug from 'debug';
8
6
  import { stringify } from 'csv-stringify/sync';
@@ -72,7 +70,7 @@ function _callPhrase(path, options = {}) {
72
70
  headers: {
73
71
  Authorization: `token ${phraseApiToken}`,
74
72
  // Provide identification via User Agent as requested in https://developers.phrase.com/api/#overview--identification-via-user-agent
75
- 'User-Agent': 'SEEK Demo Candidate App (jhope@seek.com.au)',
73
+ 'User-Agent': 'Vocab Client (https://github.com/seek-oss/vocab)',
76
74
  ...options.headers
77
75
  }
78
76
  }).then(async response => {
@@ -146,19 +144,17 @@ async function pushTranslations(translationsByLanguage, {
146
144
  let devLanguageUploadId = '';
147
145
  for (const [language, csvFileString] of Object.entries(csvFileStrings)) {
148
146
  const formData = new FormData();
149
- const fileContents = Buffer.from(csvFileString);
150
- formData.append('file', fileContents, {
151
- contentType: 'text/csv',
152
- filename: `${language}.translations.csv`
153
- });
147
+ formData.append('file', new Blob([csvFileString], {
148
+ type: 'text/csv'
149
+ }), `${language}.translations.csv`);
154
150
  formData.append('file_format', 'csv');
155
151
  formData.append('branch', branch);
156
152
  formData.append('update_translations', 'true');
157
153
  formData.append('update_descriptions', 'true');
158
- formData.append(`locale_mapping[${language}]`, messageIndex);
159
- formData.append('format_options[key_index]', keyIndex);
160
- formData.append('format_options[comment_index]', commentIndex);
161
- formData.append('format_options[tag_column]', tagColumn);
154
+ formData.append(`locale_mapping[${language}]`, messageIndex.toString());
155
+ formData.append('format_options[key_index]', keyIndex.toString());
156
+ formData.append('format_options[comment_index]', commentIndex.toString());
157
+ formData.append('format_options[tag_column]', tagColumn.toString());
162
158
  formData.append('format_options[enable_pluralization]', 'false');
163
159
  log(`Uploading translations for language ${language}`);
164
160
  const result = await callPhrase(`uploads`, {
package/package.json CHANGED
@@ -1,21 +1,27 @@
1
1
  {
2
2
  "name": "@vocab/phrase",
3
- "version": "1.3.3",
3
+ "version": "2.0.1",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/seek-oss/vocab.git",
7
+ "directory": "packages/phrase"
8
+ },
9
+ "engines": {
10
+ "node": ">=18"
11
+ },
4
12
  "main": "dist/vocab-phrase.cjs.js",
5
13
  "module": "dist/vocab-phrase.esm.js",
6
14
  "author": "SEEK",
7
15
  "license": "MIT",
8
16
  "dependencies": {
9
- "@vocab/core": "^1.6.2",
10
17
  "csv-stringify": "^6.2.3",
11
18
  "debug": "^4.3.1",
12
- "form-data": "^3.0.0",
13
- "node-fetch": "^2.6.1",
14
- "picocolors": "^1.0.0"
19
+ "picocolors": "^1.0.0",
20
+ "@vocab/core": "^1.6.2"
15
21
  },
16
22
  "devDependencies": {
17
23
  "@types/debug": "^4.1.5",
18
- "@types/node-fetch": "^2.5.7"
24
+ "@types/node": "^18.11.9"
19
25
  },
20
26
  "files": [
21
27
  "dist"