Skip to content

Cs4K1Sr4C/ATi18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– ATi18n - An Autonomous Translator Agent for projects with i18n module ๐ŸŒ

โญ Description

ATi18n is an autonomous translator agent designed for projects that utilize the i18n (internationalization) module. Its primary function is to search for combinations of key, key/namespace, and key/default_text/namespace, and then translate the extracted default_text or the value corresponding to the key from the project's default language source translation file using the selected translation service. ATi18n has various parameters and is able to process the entire project to extract the raw texts and modify the source files to make it compatible with the i18n module. In addition, it is also able to recognize the project and make suggestions and guide the user through the integration process if the i18n module is missing. It is also able to create a new or modify and configure properly the essential (next)-i18n(ext).config.js file based on the project's directory structure.

๐Ÿ”ฅ ATi18n Translated Projects

One of the most amazing open-source autonomous task creator and executor AI Agent

AgentGPT

An other amazing open-source autonomous AI Agent which can write from the right to the left

BabyAGI-UI

โœจ Features

ATi18n has the ability to collect raw texts from the source files's code.

Extracts the following functions:

  • i18n?.t
  • t
  • translate

Accepts the ' and " in the functions for the key, default_text, namespace values.

Extracts translations by the following syntaxes:

  • translate|t|i18n?.t("{key}")
  • translate|t|i18n?.t("{key}", "{namespace}")
  • translate|t|i18n?.t("{key}", { ns: {"{namespace}" })
  • translate|t|i18n?.t("{key}", "{default_text"}, "{namespace}")

Important note: for the translate|t|i18n?.t("{key}") syntax it's important to set the corresponding ENV variable to the default namespace (default: "common")

Option: if the SHORTEN_AND_REWRITE ENV variable is true then it will remove the "default_text" parameter and change the file's soruce code at the matched part to translate|t|i18n?.t("{key}", "{namespace}") syntax

If the key or the value isn't found in the /{locales_dir}/{default_language}/{namespace}.json source translation file then the script will create the "{key}": "MISSING_TRANSLATION" key/value pair and writes it into the /{locales_dir}/translation/{namespace}.json file.

๐Ÿ’ป AI driven interactive terminal

terminal.mp4

Regular Expressions

Translation collecting

translate|t|i18n?.t("DEFAULT_TEXT")

image

translate|t|i18n?.t("KEY", {ns: "NAMESPCE"})

image

translate|t|i18n?.t("KEY", "DEFAUL_TEXT", "NAMESPACE")

image

Text extraction

image

image

๐Ÿ› Bugs and other issues

But hey, let's keep it real! ATi18n isn't perfect just yet. ๐Ÿ™ˆ๐Ÿ”ง It does have a few bugs and areas that need improvement. I'm as the main developer constantly working on making it even better! ๐Ÿ’ช๐Ÿ› ๏ธ I'm aware that some bugs may creep in, causing unexpected behavior. ๐Ÿ› Don't worry, I'm actively addressing these issues and squashing those bugs. ๐Ÿœ๐Ÿ”จ

In addition, I'm always open for the suggestions and feedback from the community. ๐Ÿคโค๏ธ Your input can help me enhance ATi18n's features, usability, and overall performance. Let's collaborate with me and others to create something amazing together! ๐ŸŒŸ๐ŸŒˆ

๐Ÿš— Roadmap

  • โœ” Interactive terminal
  • โ—ป Standalone npm installable module
  • โœ” Supports Flat Translation JSON files
  • โœ” Supports Nested translation JSON files
  • โœ” OpenAI Chat & Text Completion as translator service
  • โœ” Google Translate API-less solution
  • โœ” Ability to translate the missing key/value combination from the terminal
  • โœ” AI guess the translation from the key if the source translation or the default text is missing
  • โœ” AI suggests the KEY and NAMESPACE if only the default text exists
  • โ—ป AI driven folder management
  • โœ” Auto-detection of the project's allowed locales
  • โœ” Translate automatically the entire project from the selected source language using the detected allowed languages
  • โœ” Supports .ts, .tsx, .js, .jsx, .cjs, .mjs files
  • โœ” Prompt for language/languages array creation ([{language_code, label, flag_icon}])
  • โ—ป Parameterizable npm run scripts
  • โ—ป Self-integration into the project's package.json
  • โ—ป Autosearch for hard-coded parts which should be translatable
  • โ—ป Self-integration to files, where found hard-coded parts, but the import of the translation module is missing

๐ŸŽ Services as translators

  1. Google Translate - doesn't need API key
  2. OpenAI
  • Text completion
  • Chat completion

๐Ÿงฎ Requirements

  • source translation file - otherwise it will create only "{key}": NO_TRANSLATION_FOUND if there is no OpenAI API key set and the TRY_TO_GUESS_POSSIBLE_TRANSLATION_BY_KEY ENV variable is false
  • OpenAI API key if you want to use it as the translator service

(Note: if you have the translate|t|i18n?.t("{key}", "{default_text"}, "{namespace}") syntax in your code then it will process the extracted default_text as translatable value and creates the corresponding {namespace}.json file(s))

โ“ How to configure โš™๏ธ and run ๐Ÿƒ

  1. Clone the repository using the git clone https://github.com/Cs4K1Sr4C/AutoTranslator-i18n or download and unzip the following archive: AutoTranslator-i18n
  2. Rename the .env.example file to .env or add its content to your .env file (Note: be sure to set the proper values which fit your project)
  3. Copy the .env and translator.cjs files to the directory where your package.json is located
  4. Add the translate: node ./translator.cjs to your scripts in the package.json
  5. Use one of the following npm run command:
npm run translate
npm run translate --srcLang="<enter your source language here>" --targetLang="<enter your target language here>"
npm run translate --allAvailableLanguages --suggestKeyNamespace --onlyDefaultText --changeToGoogleAfterSuggestion
npm run translate --onlyExtractKeys

๐Ÿ“น Video

ATi18n_converted_3.mp4

(In the video I used an other amazing open-source project, Guild.XYZ, for demonstrating and testing ๐Ÿค–ATi18n's automatized translation power... ๐Ÿฆพ

๐ŸŒŸ Contribution

๐Ÿค Why Contribute?

  • Enhance your coding skills...
  • Collaborate with passionate developers worldwide...
  • Build a solid portfolio...
  • Contribute the project if aligns with your interests...
  • Make a positive impact...

๐Ÿ”ง How to Contribute?

  • Fork the repository and create your branch.
  • Implement your changes, ensuring code quality and adherence to guidelines.
  • Test thoroughly to maintain a stable codebase.
  • Submit a pull request with a clear description of your changes.
  • Engage in constructive discussions with fellow contributors.
  • Iterate and improve based on valuable feedback.

Everyone is welcome to contribute! โค๏ธ

๐ŸŽ‰ Start Contributing Now

  1. Visit the open issues.
  2. Choose one that interests you or propose new ideas.

Your contributions, big or small, are highly valued and appreciated! ๐Ÿค

About

๐Ÿค– AI driven interactive and autonomous i18n extractor and translator for projects with i18n internationalization modules ๐ŸŒ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages