New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

crowdin-api

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crowdin-api - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

165

index.js

@@ -107,5 +107,6 @@ 'use strict';

class CrowdinApi {
constructor({ baseUrl = 'https://api.crowdin.com', apiKey } = {}) {
constructor({ baseUrl = 'https://api.crowdin.com', apiKey, projectName } = {}) {
this.baseUrl = baseUrl;
this.apiKey = apiKey;
this.projectName = projectName;

@@ -115,2 +116,6 @@ if (!apiKey) {

}
if (!projectName) {
throw new Error('Please specify CrowdIn project.');
}
}

@@ -157,3 +162,2 @@

* Add new file to Crowdin project
* @param projectName {String} Should contain the project identifier
* @param files {Array} Files array that should be added to Crowdin project.

@@ -164,4 +168,4 @@ * Array keys should contain file names with path in Crowdin project.

*/
addFile(projectName, files, params) {
return this.postPromise(`project/${projectName}/add-file`, undefined, {
addFile(files, params) {
return this.postPromise(`project/${this.projectName}/add-file`, undefined, {
...packFiles(files), ...params

@@ -173,3 +177,2 @@ });

* Upload latest version of your localization file to Crowdin.
* @param projectName {String} Should contain the project identifier
* @param files {Array} Files array that should be updated.

@@ -179,4 +182,4 @@ * Note! 20 files max are allowed to upload per one time file transfer.

*/
updateFile(projectName, files, params) {
return this.postPromise(`project/${projectName}/update-file`, undefined, {
updateFile(files, params) {
return this.postPromise(`project/${this.projectName}/update-file`, undefined, {
...packFiles(files), ...params

@@ -188,7 +191,6 @@ });

* Delete file from Crowdin project. All the translations will be lost without ability to restore them.
* @param projectName {String} Should contain the project identifier
* @param fileName {String} Name of file to delete.
*/
deleteFile(projectName, fileName) {
return this.postPromise(`project/${projectName}/delete-file`, undefined, {
deleteFile(fileName) {
return this.postPromise(`project/${this.projectName}/delete-file`, undefined, {
file: fileName

@@ -200,3 +202,2 @@ });

* Upload existing translations to your Crowdin project
* @param projectName {String} Should contain the project identifier
* @param files {Array} Translated files array. Array keys should contain file names in Crowdin.

@@ -207,5 +208,5 @@ * Note! 20 files max are allowed to upload per one time file transfer.

*/
updateTranslations(projectName, files, language, params) {
return this.postPromise(`project/${projectName}/upload-translation`, undefined, {
...packFiles(files), ...params
updateTranslations(files, language, params) {
return this.postPromise(`project/${this.projectName}/upload-translation`, undefined, {
...packFiles(files), ...params, language
});

@@ -216,5 +217,5 @@ }

* Track your Crowdin project translation progress by language.
* @param projectName {String} Should contain the project identifier. */
translationStatus(projectName) {
return this.postPromise(`project/${projectName}/status`);
*/
translationStatus() {
return this.postPromise(`project/${this.projectName}/status`);
}

@@ -224,6 +225,5 @@

* Get the detailed translation progress for specified language.
* @param projectName {String} Should contain the project identifier.
* @param language {String} Crowdin language codes. */
languageStatus(projectName, language) {
return this.postPromise(`project/${projectName}/language-status`, undefined, {
languageStatus(language) {
return this.postPromise(`project/${this.projectName}/language-status`, undefined, {
language

@@ -235,6 +235,5 @@ });

* Get Crowdin Project details.
* @param projectName {String} Should contain the project identifier.
*/
projectInfo(projectName) {
return this.postPromise(`project/${projectName}/info`);
projectInfo() {
return this.postPromise(`project/${this.projectName}/info`);
}

@@ -244,3 +243,2 @@

* Get a list of issues reported in the Editor.
* @param projectName {String} Should contain the project identifier.
* @param params {Object} See https://support.crowdin.com/api/issues/

@@ -253,4 +251,4 @@ * @param params.type {String} Defines the issue type.

* @param params.date_to {String} Issues added to. Use the following ISO 8601 format: YYYY-MM-DD±hh:mm. */
reportedIssues(projectName, params = {}) {
return this.postPromise(`project/${projectName}/language-status`, undefined, params);
reportedIssues(params = {}) {
return this.postPromise(`project/${this.projectName}/language-status`, undefined, params);
}

@@ -260,3 +258,2 @@

* This method exports single translated files from Crowdin.
* @param projectName {String} Should contain the project identifier.
* @param file {String} This parameter specifies a path to the file that should be exported from the project.

@@ -269,4 +266,4 @@ * @param language {String} Crowdin language code.

* @param params.export_approved_only {Boolean} If set to 1 only approved translations will be exported in resulted file. */
exportFile(projectName, file, language, params = {}) {
return this.getStream(`project/${projectName}/export-file`, {
exportFile(file, language, params = {}) {
return this.getStream(`project/${this.projectName}/export-file`, {
...params,

@@ -281,4 +278,4 @@ file,

*/
downloadTranslations(projectName, languageCode) {
return this.getStream(`project/${projectName}/download/${languageCode}.zip`);
downloadTranslations(languageCode) {
return this.getStream(`project/${this.projectName}/download/${languageCode}.zip`);
}

@@ -289,4 +286,4 @@

*/
downloadAllTranslations(projectName) {
return this.getStream(`project/${projectName}/download/all.zip`);
downloadAllTranslations() {
return this.getStream(`project/${this.projectName}/download/all.zip`);
}

@@ -299,4 +296,4 @@

*/
exportTranslations(projectName) {
return this.getPromise(`project/${projectName}/export`);
exportTranslations() {
return this.getPromise(`project/${this.projectName}/export`);
}

@@ -306,7 +303,6 @@

* Get the status of translations export.
* @param projectName {String} Project identifier.
* @param branch {String} The name of related version branch (Versions Management).
*/
translationExportStatus(projectName, branch = '') {
return this.getPromise(`project/${projectName}/export-status`, {
translationExportStatus(branch = '') {
return this.getPromise(`project/${this.projectName}/export-status`, {
branch

@@ -318,3 +314,2 @@ });

* Pre-translate Crowdin project files.
* @param projectName {String} Project identifier.
* @param languages {Array} Set of languages to which pre-translation should be applied.

@@ -331,4 +326,4 @@ * @param files {Array} Files array that should be translated. Values should match your Crowdin project structure.

*/
preTranslate(projectName, languages, files, params = {}) {
return this.postPromise(`project/${projectName}/pre-translate`, undefined, {
preTranslate(languages, files, params = {}) {
return this.postPromise(`project/${this.projectName}/pre-translate`, undefined, {
...params,

@@ -342,7 +337,6 @@ languages,

* Edit Crowdin project
* @param projectName {String} Name of the project to change
* @param params {Object} New parameters for the project.
*/
editProject(projectName, params) {
return this.postPromise(`project/${projectName}/edit-project`, undefined, params);
editProject(params) {
return this.postPromise(`project/${this.projectName}/edit-project`, undefined, params);
}

@@ -352,6 +346,5 @@

* Delete Crowdin project with all translations.
* @param projectName {String} Name of the project to delete.
*/
deleteProject(projectName) {
return this.postPromise(`project/${projectName}/delete-project`);
deleteProject() {
return this.postPromise(`project/${this.projectName}/delete-project`);
}

@@ -361,7 +354,7 @@

* Add directory to Crowdin project.
* @param projectName {String} Should contain the project identifier.
* @param directory {String} Directory name (with path if nested directory should be created).
* @param params {Object} New parameters for the directory.
*/
createDirectory(projectName, directory) {
return this.postPromise(`project/${projectName}/add-directory`, undefined, {
createDirectory(directory, params) {
return this.postPromise(`project/${this.projectName}/add-directory`, params, {
name: directory

@@ -373,10 +366,9 @@ });

* Rename directory or modify its attributes. When renaming directory the path can not be changed (it means new_name parameter can not contain path, name only).
* @param projectName {String} Full directory path that should be modified (e.g. /MainPage/AboutUs).
* @param directory {String} New directory name.
* @param params {Object} New parameters for the directory.
*/
changeDirectory(projectName, directory, params) {
return this.postPromise(`project/${projectName}/change-directory`, undefined, {
changeDirectory(directory, params) {
return this.postPromise(`project/${this.projectName}/change-directory`, params, {
name: directory
}, params);
});
}

@@ -386,7 +378,6 @@

* Delete Crowdin project directory. All nested files and directories will be deleted too.
* @param projectName {String} Should contain the project identifier.
* @param directory {String} Directory path (or just name if the directory is in root).
*/
deleteDirectory(projectName, directory) {
return this.postPromise(`project/${projectName}/delete-directory`, undefined, {
deleteDirectory(directory) {
return this.postPromise(`project/${this.projectName}/delete-directory`, undefined, {
name: directory

@@ -399,4 +390,4 @@ });

*/
downloadGlossary(projectName) {
return this.getStream(`project/${projectName}/download-glossary`);
downloadGlossary() {
return this.getStream(`project/${this.projectName}/download-glossary`);
}

@@ -406,6 +397,5 @@

* Upload your glossaries for Crowdin Project in TBX file format.
* @param projectName {String} Should contain the project identifier.
* @param fileNameOrStream {String|ReadStream} Name of the file to upload or stream which contains file to upload.
*/
uploadGlossary(projectName, fileNameOrStream) {
uploadGlossary(fileNameOrStream) {
if (typeof fileNameOrStream === 'string') {

@@ -415,3 +405,3 @@ fileNameOrStream = fs.createReadStream(fileNameOrStream);

return this.postPromise(`project/${projectName}/upload-glossary`, undefined, {
return this.postPromise(`project/${this.projectName}/upload-glossary`, undefined, {
file: fileNameOrStream

@@ -424,4 +414,4 @@ });

*/
downloadTranslationMemory(projectName) {
return this.postPromise(`project/${projectName}/download-tm`);
downloadTranslationMemory() {
return this.postPromise(`project/${this.projectName}/download-tm`);
}

@@ -431,6 +421,5 @@

* Upload your Translation Memory for Crowdin Project in TMX file format.
* @param projectName {String} Should contain the project identifier.
* @param fileNameOrStream {String|ReadStream} Name of the file to upload or stream which contains file to upload.
*/
uploadTranslationMemory(projectName, fileNameOrStream) {
uploadTranslationMemory(fileNameOrStream) {
if (typeof fileNameOrStream === 'string') {

@@ -440,3 +429,3 @@ fileNameOrStream = fs.createReadStream(fileNameOrStream);

return this.postPromise(`project/${projectName}/upload-tm`, undefined, {
return this.postPromise(`project/${this.projectName}/upload-tm`, undefined, {
file: fileNameOrStream

@@ -455,3 +444,2 @@ });

* Generate pseudo translation files for the whole project.
* @param projectName {String} Project identifier.
* @param params {Object} https://support.crowdin.com/api/pseudo-export/

@@ -463,4 +451,4 @@ * @param params.prefix {String} Add special characters at the beginning of each string to show where messages have been concatenated together.

*/
pseudoExport(projectName, params = {}) {
return this.getPromise(`project/${projectName}/pseudo-export`, params);
pseudoExport(params = {}) {
return this.getPromise(`project/${this.projectName}/pseudo-export`, params);
}

@@ -470,6 +458,5 @@

* Download ZIP file with pseudo translations.
* @param projectName {String} Project identifier.
*/
pseudoDownload(projectName) {
return this.getStream(`project/${projectName}/pseudo-download`);
pseudoDownload() {
return this.getStream(`project/${this.projectName}/pseudo-download`);
}

@@ -480,3 +467,2 @@

* This report allows you to calculate the approximate translation cost of currently untranslated strings in the project.
* @param projectName {String} Project identifier.
* @param language {String} The language for which the report should be generated.

@@ -494,4 +480,6 @@ * @param params {Object} https://support.crowdin.com/api/export-costs-estimation-report/

*/
exportCostsEstimationReport(projectName, language, params = {}) {
return this.postPromise(`project/${projectName}/reports/costs-estimation/export`, undefined, params);
exportCostsEstimationReport(language, params = {}) {
return this.postPromise(`project/${this.projectName}/reports/costs-estimation/export`, undefined, {
...params, language
});
}

@@ -501,7 +489,6 @@

* Download previously generated Costs Estimation report.
* @param projectName {String} Project identifier.
* @param hash {String} Defines hash previously received from the export of Costs Estimation report method.
*/
downloadCostsEstimationReport(projectName, hash) {
return this.getStream(`project/${projectName}/reports/costs-estimation/download`, {
downloadCostsEstimationReport(hash) {
return this.getStream(`project/${this.projectName}/reports/costs-estimation/download`, {
hash

@@ -514,3 +501,2 @@ });

* and proofreaders should be paid.
* @param projectName {String} Project identifier.
* @param params {Object} https://support.crowdin.com/api/export-translation-costs-report/

@@ -528,4 +514,4 @@ * @param params.unit {String} Defines the report unit.

*/
exportTranslationCostsReport(projectName, params = {}) {
return this.postPromise(`project/${projectName}/reports/translation-costs/export`, undefined, params);
exportTranslationCostsReport(params = {}) {
return this.postPromise(`project/${this.projectName}/reports/translation-costs/export`, undefined, params);
}

@@ -535,7 +521,6 @@

* Download previously generated Translation Costs report.
* @param projectName {String} Project identifier.
* @param hash {String} Defines hash previously received from the export of Translation Costs report method.
*/
downloadTranslationCostsReport(projectName, hash) {
return this.getStream(`project/${projectName}/reports/translation-costs/download`, {
downloadTranslationCostsReport(hash) {
return this.getStream(`project/${this.projectName}/reports/translation-costs/download`, {
hash

@@ -548,3 +533,2 @@ });

* your project's translation during the specified date range.
* @param projectName {String} Project identifier.
* @param params {Object} https://support.crowdin.com/api/export-top-members-report/

@@ -557,4 +541,4 @@ * @param params.unit {String} Defines the report unit.

*/
exportTopMembersReport(projectName, params = {}) {
return this.postPromise(`project/${projectName}/reports/top-members/export`, undefined, params);
exportTopMembersReport(params = {}) {
return this.postPromise(`project/${this.projectName}/reports/top-members/export`, undefined, params);
}

@@ -564,7 +548,6 @@

* Download previously generated Top Members report.
* @param projectName {String} Project identifier.
* @param hash {String} Defines hash previously received from the export of Top Members report method.
*/
downloadTopMembersReport(projectName, hash) {
return this.getStream(`project/${projectName}/reports/top-members/download`, {
downloadTopMembersReport(hash) {
return this.getStream(`project/${this.projectName}/reports/top-members/download`, {
hash

@@ -571,0 +554,0 @@ });

{
"name": "crowdin-api",
"version": "3.0.0",
"version": "4.0.0",
"description": "API client for Crowdin",

@@ -5,0 +5,0 @@ "repository": {

@@ -8,5 +8,8 @@ # Crowdin API

var CrowdinApi = require('crowdin-api');
var api = new CrowdinApi({ apiKey: 'abcd' }); // Get this from your project page
var api = new CrowdinApi({
apiKey: 'abcd', // Get this from your project page
project: 'project-name'
});
api.uploadFile('project-name', ...).then(function(result) {...}).catch(function(err) {...});
api.updateFile(files, ...).then(function(result) {...}).catch(function(err) {...});
```
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