Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
translator-promise
Advanced tools
A node module to translate. There is power by Google Translate.
npm install translator-promise
const translate = require('translator-promise');
// async/await. The second parameter can be a language name (ISO 639-1)
const result = await translate('Hello world', 'ja');
console.log(result);
// Output:
// {
// word: 'Hello world',
// text: 'こんにちは世界',
// candidate: [ 'こんにちは世界', 'こんにちは' ]
// }
// Promises with .then(). The third parameter is the source language.
translate('こんにちは世界', 'cn', 'ja').then(result => {
console.log(result);
// Output:
// {
// word: 'こんにちは世界',
// text: '你好,世界!',
// candidate: [ '你好', '您好', '打招呼', '个招呼', '喂' ]
// }
});
function translate(word: string, to: string, from: string): object
parameter | description |
---|---|
word | The word want to translate. |
to | The target language. Default is Chinese(cn ). (Optional) |
from | The source language. Default is recognized automatically(auto ). (Optional) |
Note: If there is no source language, the language will be recognized automatically. When there is about 33.3% Chinese, the source language will be changed to Chinese.
key | description |
---|---|
word | The word want to translate. |
text | The most match result. |
candidate | Other translate result. |
You can check it in here (ISO 639-1).
translate('word', 'ja');
// {
// "word": "word",
// "text": "語",
// "candidate": [
// "ワード",
// "単語",
// "語",
// "言葉",
// "語句",
// "伝言",
// "一言半句",
// "口舌",
// "一言"
// ]
// }
translate('中文', 'ko', 'zh');
// {
// "word": "中文",
// "text": "중국어",
// "candidate": [
// "중국어"
// ]
// }
translate('中文');
// {
// "word": "中文",
// "text": "Chinese",
// "candidate": [
// "Chinese"
// ]
// }
translate('用 Google 翻译一下这条句子。');
// {
// word: '用 Google 翻译一下这条句子。',
// text: 'Translate this sentence with Google.',
// candidate:
// [
// 'Translate this sentence with Google.',
// 'By Google translate this sentence.'
// ]
// }
FAQs
A node module based on Google Translate.
The npm package translator-promise receives a total of 7 weekly downloads. As such, translator-promise popularity was classified as not popular.
We found that translator-promise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.