Skip to content

Commit

Permalink
chore: remote to deeplx
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed May 31, 2022
1 parent 69c46d2 commit bace305
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"changelog": [
"@changesets/changelog-github",
{
"repo": "rx-ts/deepl-translate"
"repo": "rx-ts/deeplx"
}
],
"commit": false,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm release
commit: 'chore: release deepl-translate'
title: 'chore: release deepl-translate'
commit: 'chore: release deeplx'
title: 'chore: release deeplx'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# deepl-translate
# deeplx

## 0.1.0

### Minor Changes

- [`b65e4d7`](https://github.com/rx-ts/deepl-translate/commit/b65e4d77ad168dcb1962053bf8545f135074ffab) Thanks [@JounQin](https://github.com/JounQin)! - refactor: support `auto` for source language
- [`b65e4d7`](https://github.com/rx-ts/deeplx/commit/b65e4d77ad168dcb1962053bf8545f135074ffab) Thanks [@JounQin](https://github.com/JounQin)! - refactor: support `auto` for source language

* [`0882e36`](https://github.com/rx-ts/deepl-translate/commit/0882e364ffcc2efe2ec68cfe6e3284af82a47714) Thanks [@JounQin](https://github.com/JounQin)! - feat: first blood, should just work
* [`0882e36`](https://github.com/rx-ts/deeplx/commit/0882e364ffcc2efe2ec68cfe6e3284af82a47714) Thanks [@JounQin](https://github.com/JounQin)! - feat: first blood, should just work
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# DeepL Translate

[![GitHub Actions](https://github.com/rx-ts/deepl-translate/workflows/CI/badge.svg)](https://github.com/rx-ts/deepl-translate/actions/workflows/ci.yml)
[![Codecov](https://img.shields.io/codecov/c/github/rx-ts/deepl-translate.svg)](https://codecov.io/gh/rx-ts/deepl-translate)
[![Codacy Grade](https://img.shields.io/codacy/grade/1d00ac27c99d4412bb70211e258706ab)](https://app.codacy.com/gh/rx-ts/deepl-translate)
[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2Frx-ts%2Fdeepl-translate%2Fmaster%2Fpackage.json)](https://github.com/plantain-00/type-coverage)
[![npm](https://img.shields.io/npm/v/deepl-translate.svg)](https://www.npmjs.com/package/deepl-translate)
[![GitHub Release](https://img.shields.io/github/release/rx-ts/deepl-translate)](https://github.com/rx-ts/deepl-translate/releases)
[![GitHub Actions](https://github.com/rx-ts/deeplx/workflows/CI/badge.svg)](https://github.com/rx-ts/deeplx/actions/workflows/ci.yml)
[![Codecov](https://img.shields.io/codecov/c/github/rx-ts/deeplx.svg)](https://codecov.io/gh/rx-ts/deeplx)
[![Codacy Grade](https://img.shields.io/codacy/grade/1d00ac27c99d4412bb70211e258706ab)](https://app.codacy.com/gh/rx-ts/deeplx)
[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2Frx-ts%2Fdeeplx%2Fmaster%2Fpackage.json)](https://github.com/plantain-00/type-coverage)
[![npm](https://img.shields.io/npm/v/deeplx.svg)](https://www.npmjs.com/package/deeplx)
[![GitHub Release](https://img.shields.io/github/release/rx-ts/deeplx)](https://github.com/rx-ts/deeplx/releases)

[![David Peer](https://img.shields.io/david/peer/rx-ts/deepl-translate.svg)](https://david-dm.org/rx-ts/deepl-translate?type=peer)
[![David](https://img.shields.io/david/rx-ts/deepl-translate.svg)](https://david-dm.org/rx-ts/deepl-translate)
[![David Dev](https://img.shields.io/david/dev/rx-ts/deepl-translate.svg)](https://david-dm.org/rx-ts/deepl-translate?type=dev)
[![David Peer](https://img.shields.io/david/peer/rx-ts/deeplx.svg)](https://david-dm.org/rx-ts/deeplx?type=peer)
[![David](https://img.shields.io/david/rx-ts/deeplx.svg)](https://david-dm.org/rx-ts/deeplx)
[![David Dev](https://img.shields.io/david/dev/rx-ts/deeplx.svg)](https://david-dm.org/rx-ts/deeplx?type=dev)

[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)
Expand All @@ -23,13 +23,13 @@ An unofficial Node package to translate text using [DeepL](https://www.deepl.com

```sh
# npm
npm i deepl-translate
npm i deeplx

# pnpm
pnpm add deepl-translate
pnpm add deeplx

# yarn
yarn add deepl-translate
yarn add deeplx
```

## Usage
Expand Down Expand Up @@ -72,13 +72,13 @@ You can either input the abbreviation or the language written in english.
#### Help

```sh
deepl --help
deeplx --help
```

```log
Usage: deepl [options]
Usage: deeplx [options]
An unofficial Node package to translate text using [DeepL](https://www.deepl.com).
An unofficial Node package to translate text using [DeepL](https://www.deeplx.com).
Options:
-V, --version output the version number
Expand All @@ -95,7 +95,7 @@ Options:
This will translate a Spanish (`ES`) text into Russian (`RU`):

```sh
deepl -tl russian -t "¡Buenos días!"
deeplx -tl russian -t "¡Buenos días!"
```

```plain
Expand All @@ -107,15 +107,15 @@ deepl -tl russian -t "¡Buenos días!"
This will translate the file (`test.txt`) text from Italian (`IT`) into Portuguese (`PT`):

```sh
deepl -tl PT -f test.txt
deeplx -tl PT -f test.txt
```

#### Example 3

This will translate a Spanish (`ES`) text into Russian (`RU`) in _formal_ tone:

```sh
deepl -tl RU --text "¿Cómo te llamas?" --formal
deeplx -tl RU --text "¿Cómo te llamas?" --formal
```

```plain
Expand All @@ -129,7 +129,7 @@ Note: _informal_ would be "_Как **тебя** зовут?_"
This will translate a Japanese (`JP`) text into German (`DE`) in _informal_ tone:

```sh
deepl -tl DE --text "お元気ですか?" --formal false
deeplx -tl DE --text "お元気ですか?" --formal false
```

```plain
Expand All @@ -145,7 +145,7 @@ Note: _formal_ would be "_Wie geht es **Ihnen**?_"
This will translate a Chinese (`ZH`) text into Dutch (`NL`):

```js
import { translate } from 'deepl-translate'
import { translate } from 'deeplx'

translate('你好', 'NL', 'ZH')
```
Expand All @@ -159,7 +159,7 @@ translate('你好', 'NL', 'ZH')
This will translate a `danish` text into `german` in informal tone:

```js
import { translate } from 'deepl-translate'
import { translate } from 'deeplx'

translate('Ring til mig!', 'german', 'danish', undefined, undefined, false)
```
Expand Down
2 changes: 1 addition & 1 deletion api/_deepl.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from 'deepl-translate'
export * from 'deeplx'
32 changes: 7 additions & 25 deletions api/translate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { VercelRequest, VercelResponse } from '@vercel/node'
import type { SourceLanguage, TargetLanguage } from 'deepl-translate'
import type { SourceLanguage, TargetLanguage } from 'deeplx'

// Workaround for Vercel `Cannot find module 'deepl-translate'`
// Workaround for Vercel `Cannot find module 'deeplx'`
import { abbreviateLanguage, translate } from './_deepl'

export interface RequestParams {
Expand All @@ -11,8 +11,6 @@ export interface RequestParams {
}

const OK = 200
const NO_CONTENT = 204
const NOT_ALLOWED = 405
const INTERNAL_ERROR = 500

export default async (
Expand All @@ -26,30 +24,14 @@ export default async (
// type-coverage:ignore-next-line
} = req.body as RequestParams

if (req.method !== 'POST' || !abbreviateLanguage(targetLang)) {
res.status(NOT_ALLOWED)
res.end(
JSON.stringify({
code: NOT_ALLOWED,
}),
)
return
}
text = text?.trim()

if (text == null) {
res.status(NO_CONTENT)
return
}
if (req.method !== 'POST' || !text || !abbreviateLanguage(targetLang)) {
res.end(`DeepL Translate Api
text = text.trim()
POST {"text": "have a try", "source_lang": "auto", "target_lang": "ZH"} to /translate
if (!text) {
res.end(
JSON.stringify({
code: OK,
data: '',
}),
)
https://github.com/rx-ts/deeplx`)
return
}

Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const config: Config.InitialOptions = {
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
'^deepl-translate$': '<rootDir>/src/index.ts',
'^deeplx$': '<rootDir>/src/index.ts',
},
globals: {
'ts-jest': {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "deepl-translate",
"name": "deeplx",
"version": "0.1.0",
"type": "module",
"description": "An unofficial Node package to translate text using [DeepL](https://www.deepl.com).",
Expand All @@ -9,7 +9,7 @@
"node": ">=12.20"
},
"bin": {
"deepl": "./lib/cli.js"
"deeplx": "./lib/cli.js"
},
"main": "./lib/index.cjs",
"module": "./lib/index.js",
Expand All @@ -26,6 +26,7 @@
"deepl",
"deepl-api",
"deepl-free",
"deeplx",
"deepl-translate",
"deepl-translation",
"deepl-translator",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const main = async () => {
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>Deepl Translate</title>
<title>DeepLx</title>
<link
rel="icon"
type="image/png"
Expand Down
2 changes: 1 addition & 1 deletion test/generators.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateJobs } from 'deepl-translate'
import { generateJobs } from 'deeplx'

test('generate jobs with one sentence', () => {
const sentences = ['Forever alone.']
Expand Down
2 changes: 1 addition & 1 deletion test/hacks.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-magic-numbers */

import { calculateValidTimestamp, generateId } from 'deepl-translate'
import { calculateValidTimestamp, generateId } from 'deeplx'

test('calculateValidTimestamp', () => {
expect(calculateValidTimestamp(10, 0)).toBe(10)
Expand Down
2 changes: 1 addition & 1 deletion test/sentence-split.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { jest } from '@jest/globals'

import { splitIntoSentences } from 'deepl-translate'
import { splitIntoSentences } from 'deeplx'

if (process.env.CI === 'true') {
jest.setTimeout(20 * 1000)
Expand Down
2 changes: 1 addition & 1 deletion test/translation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { jest } from '@jest/globals'

import { randRange, translate } from 'deepl-translate'
import { randRange, translate } from 'deeplx'

if (process.env.CI === 'true') {
jest.setTimeout(20 * 1000)
Expand Down
2 changes: 1 addition & 1 deletion test/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { abbreviateLanguage } from 'deepl-translate'
import { abbreviateLanguage } from 'deeplx'

test('abbreviateLanguage', () => {
expect(abbreviateLanguage('RuSsIaN')).toBe('RU')
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"deepl-translate": ["./src/index.ts"]
"deeplx": ["./src/index.ts"]
}
}
}

0 comments on commit bace305

Please sign in to comment.