Documentation for the aidiomix library

Introduction

aidiomix is an AI-driven translation tool designed to facilitate the management and generation of translations for your projects. It offers integration with multiple AI services to automate the translation of textual content found in your source files.

Before starting

aidiomix suppose that you already have installed a translation library like i18next or react-i18n.

When you are coding a new page or component, instead of having to choose a translation key that fits the string you want to translate, and go manualy update all your translation files, you just have to write the string in your component in the language you want,

...and let aidiomix do the work.

Example:


const MyComponent = () => {

  return <div>Bonjour tout le monde</div>;
};

aidiomix will choose a key for you and update your translation files and your code.


const MyComponent = () => {

  return <div>{t('hello_world')}</div>;
};

In this case, you need to add the useTranslation hook to your component to use the translations.

Installation

Install aidiomix using npm:

npm install aidiomix

Configuration

Create an account and a project on aidiomix.io

You first need to create an account on aidiomix.io and create a project.

Go to https://aidiomix.io/sign-in and create an account.

Then create a project.

Create the configuration file

Run the init command to create the configuration file:

npx aidiomix init

This will create a aidiomix.config.cjs file in the root of your project.

You can get your API key on the dashboard of your project.

Here's an example configuration:

module.exports = {
  languages: ['en', 'fr', 'es'],
  localesPath: './locales/{lang}/translation.json',
  sourceDirectories: ['./app', './components'],
  apiKey: 'YOUR_API_KEY',
  translationFunction: 't',
};

Usage of npm tool

Parse your code to find the non-translated strings

To generate the translation files, run the following command:

npx aidiomix parse

This will parse the files and extract the non-translated strings Then it will translate them into the supported languages Then it will use IA to choose appropriate keys for the translations Then it will update the translation files with the new translations Then it will replace the non-translated strings with the new keys

Upload your translation to the aidiomix dashboard

You can upload your translation to the aidiomix dashboard to have a better overview of your translations.

npx aidiomix up

Download your translation from the aidiomix dashboard

You can download your translation from the aidiomix dashboard to get the translations uploaded from the dashboard.

npx aidiomix down

Usage of dashboard

In the dashboard, you can see the translations of your project. You can edit a transmation string for a specific language.

To sync your modifications, you have 3 options:

  • 1 - After saving the translation, run manually the npx aidiomix down command in your codebase to download the translations from the dashboard.
  • 2 - Use github setup in the dash to link your github repository to the dashboard. Any modification will create a commit in your repository.
  • 3 - Use a webhook to sync your dashboard with your repository.