Socket
Socket
Sign inDemoInstall

combinedtranslate

Package Overview
Dependencies
100
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

dist/functions/getLanguage.d.ts

12

dist/main.d.ts

@@ -1,9 +0,7 @@

import translate from "./translate.js";
import translate from "./functions/translate.js";
import getLanguageByName from "./functions/getLanguageByName.js";
import getLanguageByCode from "./functions/getLanguageByCode.js";
import getLanguage from "./functions/getLanguage.js";
declare const languagesByCode: Record<string, string>, languagesByName: Record<string, string>, languagesList: string[];
/**
* @param {string} language - The name of the language
*/
declare function getLanguageByName(language: string): string | null;
declare function getLanguageByCode(code: string): string | null;
export { languagesByCode, languagesByName, languagesList, translate, getLanguageByCode, getLanguageByName };
export { languagesByCode, languagesByName, languagesList, translate, getLanguageByCode, getLanguageByName, getLanguage };
export default translate;

@@ -1,68 +0,13 @@

import * as asma from "@asmagin/google-translate-api";
import * as imli from "@imlinhanchao/google-translate-api";
import * as iuse from "@iuser/google-translate-api";
import * as plai from "@plainheart/google-translate-api";
import * as gtae from "google-translate-api-extend";
import * as gtan from "google-translate-api-next";
import translate from "./translate.js";
function getLanguages() {
const languagesByCode = {
zh: "Chinese",
"zh-cn": "Chinese Simplified",
"zh-tw": "Chinese Traditional",
ma: "Mandarin",
}, languagesByName = {
Chinese: "zh",
"Chinese Simplified": "zh-cn",
"Chinese Traditional": "zh-tw",
Mandarin: "ma",
};
[
asma.languages,
imli.languages,
iuse.languages,
plai.languages,
gtae.languages,
gtan.languages,
].map((language) => {
Object.entries(language).map(([code, name]) => {
if (typeof name === "function")
return;
try {
Object.defineProperty(languagesByCode, code, {
value: name,
writable: false,
enumerable: true,
});
}
catch { }
try {
Object.defineProperty(languagesByName, name, {
value: code,
writable: false,
enumerable: true,
});
}
catch { }
});
});
return {
languagesByCode,
languagesByName,
languages: Object.keys(languagesByName),
};
}
"use strict";
import translate from "./functions/translate.js";
import getLanguages from "./functions/getLanguages.js";
import getLanguageByName from "./functions/getLanguageByName.js";
import getLanguageByCode from "./functions/getLanguageByCode.js";
import getLanguage from "./functions/getLanguage.js";
const languagesByCode = getLanguages().languagesByCode, languagesByName = getLanguages().languagesByName, languagesList = getLanguages().languages;
/**
* @param {string} language - The name of the language
*/
function getLanguageByName(language) {
return languagesByName[(language.charAt(0).toUpperCase() + language.slice(1).toLowerCase())] || null;
}
function getLanguageByCode(code) {
return languagesByCode[`${code.split(/-/g)[0].toLowerCase()}${code.split(/-/g)[1]
? `-${code.split(/-/g)[1].toUpperCase()}`
: ""}`] || null;
}
export { languagesByCode, languagesByName, languagesList, translate, getLanguageByCode, getLanguageByName };
export {
// Constants
languagesByCode, languagesByName, languagesList,
// Functions
translate, getLanguageByCode, getLanguageByName, getLanguage };
export default translate;
{
"name": "combinedtranslate",
"version": "0.0.4",
"version": "0.0.5",
"description": "A translate package that combines multiple API's and packages.",
"main": "dist/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"dummi": "echo Hi!"
},

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

@@ -18,5 +18,5 @@ # CombinedTranslate \[BETA\]

```js
import translate from "combinedtranslate";
import translate from 'combinedtranslate';
const translation = await translate("Hallo Wereld", { to: "English" });
const translation = await translate('Hallo Wereld', { to: 'English' });
// Output: translation.content = 'Hello World'

@@ -31,4 +31,5 @@ ```

pronunciation: string | null, // If applied, it'll provide a phonetic script.
translated: boolean,
translated: boolean, // Whether it translated or not.
tries: number, // Number of times it switched API's to get the current response.
time: number // The amount of milliseconds it took to translate the given string.
language: {

@@ -50,3 +51,3 @@ source: { // The language translating from

corrected: boolean, // Whether autocorrect was used on the string
value: null // No idea what this is...
value: null // The corrected value.
},

@@ -70,7 +71,3 @@ raw: {

```js
import translate, {
languagesByCode,
languagesByName,
languageList,
} from "combinedtranslate";
import translate, { languagesByCode, languagesByName, languageList } from 'combinedtranslate';

@@ -77,0 +74,0 @@ languagesByCode; // An object with all supported languages by their ISO code.

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc