invopop / ctxi18n

Go Context Internationalization - translating apps easily
Apache License 2.0
48 stars 3 forks source link

Machine translation #7

Open gedw99 opened 5 months ago

gedw99 commented 5 months ago

I am using this with templ. It’s really good.

The only thing missing is auto translation using google translate of the new strings on a run , and an override field in the yaml translation fields where you can manually fix a machine translation from google translate.

ccoVeille commented 5 months ago

Libre translate would be a better option I think.

It would be open source at least

gedw99 commented 5 months ago

Libre translate would be a better option I think.

It would be open source at least

True that would be a great option. Would we still need a cache of Translations to reduce the hits to the Service though ? Then when we do a Translation run, we dont have to work out what is new, but instead just hit the local cache, and on a cache miss hit the Service that does there Translation.

It looks like this is the code for https://github.com/LibreTranslate/LibreTranslate. Do you know of a quality benchmark and based on languages though ? It would be good to get an idea of its quality .

Looks like they have a pricing of 29 USD / Month. https://portal.libretranslate.com.

The only other aspect is substitution. To send a string for translation that has a value such as " Hello {name }", what format does Libre Translate expect ? We would have to do a simple conversion of substitution frames into the Service and back out.

ccoVeille commented 5 months ago

I have never used substitution with libre translate

About libretranlate I had very good result with a local docker instance, something that might also be triggered in GHA if needed, so I don't think it's worth paying for it

https://github.com/LibreTranslate/LibreTranslate?tab=readme-ov-file#run-with-docker

About the quality is good, but was under Google Translate of course

gedw99 commented 5 months ago

If it’s a single docker then that could be a good one . Fly. Io can do serverless of dockers too so saves costs. Does it need a gpu though ?

ccoVeille commented 5 months ago

No GPU needed for what I know

gedw99 commented 5 months ago

Thanks @ccoVeille

I tried it on fly.io but failed : https://github.com/LibreTranslate/LibreTranslate/issues/531

I will swing back around to this later as it does sound cool.

But i also want to add google translate so that there is a good stable option , with the Libre as an open source unstable option.

ccoVeille commented 5 months ago

Indeed, did you find a thread on the forum about it?

gedw99 commented 5 months ago

No lt yet. Been mega busy today ..

samlown commented 4 months ago

Hey! Very keen to see what you can come up with here! I've just been using Copilot and ChatGTP as best as possible for translations 😆 it has the advantage of being a little more context aware, and handles YAML files well.

Given that the YAML file structure is copied directly from Rails i18n, I'd expect there to be more than one service out there that makes translations easier.

gedw99 commented 4 months ago

Hey @samlown

Thats a great idea. I never thought of that approach, but it's a good approach too.

I like to try it. Have you got a repo to show maybe ?

I am working up a htmx project that can do the i18n and Bidi stuff correctly too. Bidi is the RTL and LTR stuff.

samlown commented 4 months ago

@gedw99 no code, I just do the translations manually and hope for the best. Its not ideal. I've haven't tested much with RLT/LTR, but in my experience it should be handled with UTF-8 automatically. Let us know how it goes!