[F/OS] ThMLT [V2.1] - An extension to make translation and text styling easier

The acronym "ThMLT" stands for "Theme and Multilanguage Translation." It represents a component designed to manage themes (such as colors and fonts) and facilitate multilanguage support (translation) in AI2.

This extension offers a straightforward solution that I've been using in my personal projects. Recognizing its potential value to the broader community, I've opted to share it. I hope this extension proves beneficial to others.

Blocks

Usage

You have to use this block only one screen. after that you can access from any screen.

colorScheme

You can use any letter as a key. Value can be color integer, Hex color
There are 3 protected keys. if you use these keys then you can access colors directly from their property values
p = ColorPrimary
s = ColorSecondary
a = ColorAccent

fonts

You can use any letter as key. Value will be font names.
NOTE : Font must be in asset folder

There are 4 protected keys. if you use these keys then you can access font names directly from their property values
r = FontRegular
b = FontBold
i = FontItalic
m = FontMaterial

translationFiles

Sample translation file in JSON.

{
  "SupportedLanguages": ["en","bn"],
  "Translations": {
    "name": {
      "en": "Hridoy",
      "bn": "হৃদয়"
    },
    "age": {
      "en": "30",
      "bn": "৩০"
    }
  }
}

To use multiple languages you have to add language codes in SupportedLanguages object.

defaultLanguage

You can set default language for translation. It must be present in SupportedLanguages


This block will translate all the labels.

Designer Section

In the label text:

  1. Begin with {-
  2. If you wish to translate the label, use t; otherwise, use n
  3. Add your font key, such as r for regular or any key you set on initialization.
  4. Similarly, specify the color, like p for primary
  5. Conclude with }
  6. Next, include your text. To facilitate translation, use the same key as in the JSON file.
    In my case it is {-trp}name
V1

Usage

colorScheme
You can use any letter as a key. But
p = ColorPrimary
s = ColorSecondary
a = ColorAccent

fonts
You can use any letter as key.
Except
r = FontRegular
b = FontBold
i = FontItalic
m = FontMaterial
If you want the bold/italic font to be the same as the regular font, set the value to "r" in your fonts value.

These keys will trigger the property blocks for Color and Fonts

translationFiles
Add your translation files as a JSON text

defaultLanguage
You can set default language for translation

In the label text:

  1. Begin with {-
  2. If you wish to translate the label, use "t"; otherwise, use "n"
  3. Add your font key, such as "r" for regular
  4. Similarly, specify the color, like "p" for primary
  5. Conclude with }
  6. Next, include your text. To facilitate translation, use the same key as in the JSON file.
    In my case it is {-trp}name

V1 - com.hridoy.thmlt.aix (13.0 KB)
AIA - ThMLT_Test.aia (267.6 KB)

V2

Blocks Added :new:

Bug Fixes :zap:

  • Formatting not working in apk. It's fixed now

V2.1 Latest :new:

AIX :
com.hridoy.thmlt.aix (10.3 KB)

AIA : ThMLT_V2_1.aia (269.3 KB)

Open Source

6 Likes

Update - V2 :fire:

Blocks Added :new:

Bug Fixes :zap:

  • Formatting not working in apk. It's fixed now
1 Like