AgentGPT icon indicating copy to clipboard operation
AgentGPT copied to clipboard

🔥 Auto-translate via Google (free) or OpenAI (needs API key)

Open Cs4K1Sr4C opened this issue 2 years ago • 3 comments

  • Collects and translates the translate functions
  • Default source translation JSON files from public/locales/en directory
  • Must to have OPENAI_API_KEY in ENV if the TRANSLATOR_SERVICE is set to openai
  • Alternative translation using Google translate (doesn't need any API Key)
  • If there is no namespace provided in the translate function then uses the common as default
  • Possible translation methods: chat, text
  • Possible translation services: google, openai
  • Create a separated directory in the public/locales/ named "translation" to avoid overwrite or delete already existing translations
  • Has 3 modes: Collect and Translate, Only Collect, Only Translate
  • Accept parameters and automatically parse them if they are provided

Cs4K1Sr4C avatar May 14 '23 12:05 Cs4K1Sr4C

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2023 9:38pm

vercel[bot] avatar May 14 '23 12:05 vercel[bot]

@Cs4K1Sr4C is attempting to deploy a commit to the reworkd Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar May 14 '23 12:05 vercel[bot]

This is awesome @Cs4K1Sr4C!

awtkns avatar May 14 '23 13:05 awtkns

@asim-shrestha @awtkns

So if we have a new static text to translate just easily use the translate("{key}", "{default text in English}", "{?namespace?}") syntax.

If you run the translator script (npm run translate) it will find and process the mentioned formula in every .ts and .tsx file; It will extract key/text/namespace combinations into an array then translates the text to the selected target language.

So you can use en as source and en as target and it will create the complete English translation and its json files; After overwrite the old files - and move the new ones if they are - in the public/locales/en/ directory just easily run again the translator script with an other target language to create the desired complete translation.

When the extraction is done it will change the source code of the file - where from the translatable part has been extracted - to the single translate("{key}", "{?namespace?}") syntax.

Cs4K1Sr4C avatar May 16 '23 21:05 Cs4K1Sr4C

Doesn't really belong in the main repo. Closing as a result, you can find this project here: https://github.com/Cs4K1Sr4C/ATi18n

asim-shrestha avatar May 27 '23 01:05 asim-shrestha