Giter Site home page Giter Site logo

deeplx's Introduction

DeepLX

⚡️ DeepLX API npm package.

test dw

Usage

npm i @ifyour/deeplx

In your backend service, install and use this package, you can use any backend framework you like. Here's a demo of my deployment on AirCode, you can click here to deploy one of your own.

import { query } from '@ifyour/deeplx';

export default async function(params, context) {
  return await query(params);
}
curl --location 'https://nw6usm5uha.us.aircode.run/demo' \
--header 'Content-Type: application/json' \
--data '{
    "text": "你好,世界",
    "source_lang": "zh",
    "target_lang": "en"
}'
{
  "code": 200,
  "message": "success",
  "data": "Hello, world.",
  "source_lang": "zh",
  "target_lang": "en",
  "alternatives": ["Hello, World.", "Hello, world!", "Hi, world."]
}

demo

Dev

yarn install

# You need to install bun, please refer to https://bun.sh
yarn run dev

yarn run test

yarn run lint --fix

Known issues

Based on current testing, Cloudflare and Cloudflare-based edge function runtimes (Vercel) are not able to correctly request the DeepL server, and a 525 error occurs, a detailed description of the issue can be found here.

For this case, it can be solved using the DeepL proxy server, please refer to the code example.

License

DeepLX is available under the MIT license.

deeplx's People

Contributors

ifyour avatar mar0xy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deeplx's Issues

Supported Languages Type

const langs = [
    "el",
    "bg",
    "lv",
    "ko",
    "lt",
    "id",
    "uk",
    "sl",
    "sk",
    "tr",
    "ro",
    "cs",
    "et",
    "fi",
    "da",
    "hu",
    "sv",
    "nb",
    "ru",
    "pl",
    "pt",
    "nl",
    "it",
    "es",
    "fr",
    "de",
    "ja",
    "en",
    "zh"
] as const

type Lang = typeof langs[number]
type SourceLang = Lang | 'auto'
type TargetLang = Lang

Error running the exported Edge Handler TypeError: (t.text || "").split is not a function

Error running the exported Edge Handler TypeError: (t.text || "").split is not a function
at a (/var/task/node_modules/@ifyour/deeplx/dist/deeplx.cjs.production.min.js:1:7637)
at /var/task/node_modules/@ifyour/deeplx/dist/deeplx.cjs.production.min.js:1:8287
at f (/var/task/node_modules/@ifyour/deeplx/dist/deeplx.cjs.production.min.js:1:643)
at Generator.<anonymous> (/var/task/node_modules/@ifyour/deeplx/dist/deeplx.cjs.production.min.js:1:1974)
at Generator.next (/var/task/node_modules/@ifyour/deeplx/dist/deeplx.cjs.production.min.js:1:1053)
at e (/var/task/node_modules/@ifyour/deeplx/dist/deeplx.cjs.production.min.js:1:6562)
at u (/var/task/node_modules/@ifyour/deeplx/dist/deeplx.cjs.production.min.js:1:6765)
at /var/task/node_modules/@ifyour/deeplx/dist/deeplx.cjs.production.min.js:1:6824
at new Promise (<anonymous>)
at /var/task/node_modules/@ifyour/deeplx/dist/deeplx.cjs.production.min.js:1:6705

seems to be here

return (translateText || '').split('i').length - 1;

adding .toString() should fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.