Skip to content

Commit

Permalink
add readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
egyjs committed Oct 26, 2022
1 parent a840833 commit 965f540
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 33 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -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
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
![API-Translator build](https://img.shields.io/appveyor/build/egyjs/API-Translator?style=flat-square)

<h1 align="center">
<img src="https://i.ibb.co/Lk9wGxF/app-store-icon.png" alt="free translate" width="40%"/>
</h1>

# 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 <a href="mailto:el3zahaby@gmail.com" target="_blank">`el3zahaby@gmail.com`</a>
- Instagram <a href="https://www.instagram.com/egyjs/" target="_blank">`@egyjs`</a>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api-translator",
"version": "1.0.0",
"version": "1.0.1",
"main": "index.js",
"types": "dist/index.d.ts",
"scripts": {
Expand Down
5 changes: 1 addition & 4 deletions tests/word.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})();
11 changes: 5 additions & 6 deletions tests/word.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 965f540

Please sign in to comment.