From 965f5407eeb2955a8aeb25dbde09c9fb5e2a1bbf Mon Sep 17 00:00:00 2001 From: egyjs Date: Thu, 27 Oct 2022 01:58:40 +0200 Subject: [PATCH] add readme file --- .github/workflows/npm-publish.yml | 44 +++++++++--------- README.md | 76 +++++++++++++++++++++++++++++++ package.json | 2 +- tests/word.js | 5 +- tests/word.test.ts | 11 ++--- 5 files changed, 105 insertions(+), 33 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 9fa2faa..14494c1 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,25 +1,25 @@ name: npm-publish on: - push: - branches: - - master + push: + branches: + - master jobs: - npm-publish: - name: npm-publish - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Publish if version has been updated - uses: pascalgn/npm-publish-action@1.3.9 - with: # All of theses inputs are optional - tag_name: "v%s" - tag_message: "v%s" - create_tag: "true" - commit_pattern: "^Release (\\S+)" - workspace: "." - publish_command: "yarn" - publish_args: "--non-interactive" - env: # More info about the environment variables in the README - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated - NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings + npm-publish: + name: npm-publish + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Publish if version has been updated + uses: pascalgn/npm-publish-action@1.3.9 + with: # All of theses inputs are optional + tag_name: "v%s" + tag_message: "v%s" + create_tag: "true" + commit_pattern: "^Release (\\S+)" + workspace: "." + publish_command: "yarn" + publish_args: "--non-interactive" + env: # More info about the environment variables in the README + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings diff --git a/README.md b/README.md index e69de29..5648662 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,76 @@ +![API-Translator build](https://img.shields.io/appveyor/build/egyjs/API-Translator?style=flat-square) + +

+free translate +

+ +# A free and unlimited translator for Node.js + +> 🈂️ ⠀free text translator for Node.js. + +## **Install** + +To install free-translate, you can use NPM: + +```bash +npm install free-translate +``` + +## **Quick examples** + +```js +const { translate } = require("free-translate"); + +(async () => { + const translatedText = await translate("Hello World", { + from: "en", + to: "ar", + }); + + console.log(translatedText); // اهلا بالعالم +})(); +``` + +### **Automatic language recognition** + +If the language informed in the `from` is dynamic, just do not send it and the translator will automatically recognize it: + +```js +const { translate } = require("free-translate"); + +(async () => { + const translatedText = await translate("This is cool!", { to: "ar" }); + + console.log(translatedText); // هذا رائع! +})(); +``` + +### **Multiple texts** + +You can also translate multiple texts at the same time: + +```js +const { translate } = require("free-translate"); + +(async () => { + const translatedText = await translate(["Hello World", "This is cool!"], { + to: "ar", + }); + + console.log(translatedText); // [ 'اهلا بالعالم', 'هذا رائع!' ] +})(); +``` + +--- + + +## Contributing + +- If you want to contribute to the project, you can do it by opening a pull request or opening an issue. + + +--- +## Contact me! + +- E-mail `el3zahaby@gmail.com` +- Instagram `@egyjs` diff --git a/package.json b/package.json index b356c9c..9c765c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "api-translator", - "version": "1.0.0", + "version": "1.0.1", "main": "index.js", "types": "dist/index.d.ts", "scripts": { diff --git a/tests/word.js b/tests/word.js index 99a25ae..3013890 100644 --- a/tests/word.js +++ b/tests/word.js @@ -2,9 +2,6 @@ const { translate } = require("../dist"); const { log } = require("console"); (async () => { - const result = await translate( - "hello world", - { to: "ar" }, - ); + const result = await translate("hello world", { to: "ar" }); log(result); })(); diff --git a/tests/word.test.ts b/tests/word.test.ts index c4fd301..dec32bd 100644 --- a/tests/word.test.ts +++ b/tests/word.test.ts @@ -8,14 +8,13 @@ beforeEach(() => { jest.useFakeTimers(); }); test('test "hello world" in Arabic', async () => { - const result = await translate("hello world", { from: "en", to: "ar" }); expect(result).toBe("مرحبا بالعالم"); }); -test('test translate a long text > 5000', async () => { - const text = 'hello world '.repeat(502); -// info(text.length); - const result = await translate(text, { from: 'en', to: 'ar' }); - expect(result).not.toBe(text); +test("test translate a long text > 5000", async () => { + const text = "hello world ".repeat(502); + // info(text.length); + const result = await translate(text, { from: "en", to: "ar" }); + expect(result).not.toBe(text); });