Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a suggest #54

Open
yyy33 opened this issue May 10, 2022 · 13 comments · May be fixed by #92
Open

a suggest #54

yyy33 opened this issue May 10, 2022 · 13 comments · May be fixed by #92

Comments

@yyy33
Copy link

yyy33 commented May 10, 2022

I suggest that the author can package the project into a binary file and provide a network interface, like http, so that the other language can benefit from the project,

@Animenosekai
Copy link
Owner

so that the other language can benefit from the project,

Other languages can already use translatepy from the command line interface though

@Animenosekai Animenosekai added this to To do in Next version via automation May 15, 2022
@Animenosekai
Copy link
Owner

I mean we could use something like Nuitka which seems to work pretty well (just tested it on translatepy)

@yyy33
Copy link
Author

yyy33 commented May 16, 2022

I mean we could use something like Nuitka which seems to work pretty well (just tested it on translatepy)

Yes, but the pythong module is a bit difficult to manage for those of us who have not studied python

@Animenosekai
Copy link
Owner

Yes, but the pythong module is a bit difficult to manage for those of us who have not studied python

Oh you mean like installing stuff and all...

Yeah I guess I could release some kind of binaries 👌

@Animenosekai Animenosekai removed this from To do in Next version May 17, 2022
@yyy33
Copy link
Author

yyy33 commented May 21, 2022

Nuitka

I tried to package the binary using the Nuitka package you recommended, and it worked for me. Then I called it in golang, but it was a bit slow, because I needed to start translate once for each translation

@Animenosekai
Copy link
Owner

Then I called it in golang, but it was a bit slow, because I needed to start translate once for each translation

Ok I guess I could make some kind of HTTP server then

@yyy33
Copy link
Author

yyy33 commented May 26, 2022

Then I called it in golang, but it was a bit slow, because I needed to start translate once for each translation

Ok I guess I could make some kind of HTTP server then

great!

@Animenosekai
Copy link
Owner

great!

I now have something like this:

GET /translate?text=Hello%20world&dest=japanese
{
    "success": true,
    "error": null,
    "message": null,
    "data": {
        "service": "Google",
        "source": "Hello world",
        "sourceLang": "eng",
        "destLang": "jpn",
        "result": "こんにちは世界"
    }
}

Which also handles the errors and where you can specify the translators and all.

The documentation is available under the translatepy/server/docs folder.

I'll add more endpoints in the near future to cover the other functions.

Also, you need to install Nasse to be able to run the server, which is for now only available on Unix systems (macOS, Linux, etc.).

@Animenosekai
Copy link
Owner

Also, I seem to have a problem with threading + fork() when running the server on my mac so I'm currently using Linux on GitHub Codespaces where it works perfectly.

@Animenosekai
Copy link
Owner

@yyy33 The HTTP server seems to work fine now, with lots of new endpoints added covering somewhat everything that can be done with translatepy

Here are the docs

translatepy/server/docs/Getting Started.md

How can it be ran

You can use the new server action of the CLI to easily run the HTTP server.

$ translatepy server

Here is more details for this command

🧃❯ translatepy server -h
usage: translatepy server [-h] [--port PORT] [--host HOST]

optional arguments:
  -h, --help            show this help message and exit
  --port PORT, -p PORT  port to run the server on
  --host HOST           host to run the server on

@Animenosekai
Copy link
Owner

Now I just need to create the binaries for each release and it should be good 👍

@yyy33
Copy link
Author

yyy33 commented Jun 13, 2022

现在我只需要为每个版本创建二进制文件,它应该很好 👍

I haven't tested it yet, and I will give the results feedback here after using it

@Animenosekai
Copy link
Owner

Animenosekai commented Jun 13, 2022

I haven't tested it yet, and I will give the results feedback here after using it

You should test the one on the website branch (I'm currently making a website for translatepy, which I should finish right after my exams). I modified some stuff for the HTTP server to be easier for developers on it, as I was making use of the HTTP server myself.

Make sure to download the dependencies from requirements.txt instead of setup.py

@Animenosekai Animenosekai mentioned this issue Feb 23, 2023
27 tasks
@Animenosekai Animenosekai linked a pull request Aug 29, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants