Skip to content

feat: Arabic (AR) radio translation foundation - #8031

Merged
pfeerick merged 12 commits into
mainfrom
feat/arabic-translation
Nov 17, 2026
Merged

pfeerick merged 12 commits into
mainfrom
feat/arabic-translation

Conversation

@pfeerick

@pfeerick pfeerick commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Related: discussion #8027 (Arabic language support).

Draft / feasibility work. This adds the groundwork for an Arabic (AR) radio language on color LCD radios, so the translation from #8027 has somewhere to go. ar.h is now fully translated (#8034, by GyroGhost). It still needs native-speaker review, and a check that the strings fit on screen. The screen layout is not mirrored. Text is shaped and shown right to left, but menus and labels keep their current left-to-right positions.

Summary of changes:

RTL and Arabic letter shaping

  • AR is added to RADIO_LANGUAGES, TTS_LANGUAGES and RTL_LANGUAGES, which turns on LVGL bidi as it does for Hebrew.
  • New AP_LANGUAGES / TRANSLATION_NEEDS_AP enables LVGL's Arabic shaping (LV_USE_ARABIC_PERSIAN_CHARS, lv_txt_ap.c) for AR builds and the simulator. Shaping turns each letter into its isolated, initial, medial or final form.
  • LVGL only shapes text inside lv_label/lv_dropdown, so BitmapBuffer::drawSizedText() now also shapes any string that contains Arabic. That covers text drawn by custom widgets and Lua. It's not compiled into the bootloader, whose strings are always English for AR.

Fonts

  • Noto Sans Arabic Regular/Bold (OFL) are added under radio/src/fonts/Noto/.
  • get_char_ar.py collects the Arabic characters used in ar.h, plus the whole Presentation Forms-B block. Shaping produces those forms at runtime, so they never appear in the source text.
  • lv_font_ar_* is generated for all three screen sizes. The CN/TW/KO fonts are regenerated for the new "Arabic" voice-name glyphs.

Strings

  • i18n/ar.h is fully translated (Full Arabic translation for ar.h #8034). Common EdgeTX/FPV terms such as Inputs, Mixes and Telemetry are kept in English on purpose. Harakat (diacritic marks) are avoided, because LVGL doesn't position combining marks.
  • TR_VOICE_ARABIC is added to every translation, and the sim string list and cfn sort order are regenerated.
  • B&W radios: AR can't be selected as the text language (no fonts). It can still be selected as the voice language.

Voice (TTS)

  • tts_ar.cpp implements Arabic number and duration grammar, based on tts_ru.cpp:
    • 4 unit forms: singular, dual, plural (3–10) and accusative (11–99)
    • separate prompt sets for 0–99 with masculine and with feminine units, so gender polarity is part of the recordings
    • dual and plural thousands, and a gender for each unit
  • The prompt layout in the file header is the spec for an Arabic voice pack in edgetx-sdcard-sounds. That pack doesn't exist yet.

Companion

  • ar is added to the firmware language list, and Arabic to the voice and color text-language selectors.
  • Companion's own UI can now be translated to Arabic. companion_ar.ts is added (all strings still untranslated), and Arabic (العربية) is listed under Settings → Set Menu Language. The locale is plain ar, because the translation is Modern Standard Arabic and not tied to one country.
  • Right-to-left layout needs no code. Qt's own qtbase_ar.qm switches the whole app to RTL. This was already the case for anyone running Companion on an Arabic (or Hebrew) OS.
  • tools/build-multilang.sh no longer builds AR firmware for B&W radios.

Translating Companion

  • Edit companion/src/translations/companion_ar.ts with Qt Linguist, and open a PR against this branch (as Full Arabic translation for ar.h #8034 did for ar.h).
  • Keep %1/%2 placeholders, HTML tags and & shortcut markers.
  • To test without rebuilding Companion: run lrelease companion_ar.ts, set EDGETX_APP_TRANSLATIONS_PATH to the folder that holds the .qm, and restart Companion.
  • Until at least one string is translated, Qt won't load the .qm, so Companion shows the mirrored layout with English text.

Answers to the questions in #8027

  • How hard is RTL + shaping? LVGL already supports both, and this PR turns them on. Joined letters, right-to-left word order and mixed Arabic/Latin/digit text all render correctly. Mirroring the layout would be a separate, much larger change, and is not currently even being considered.
  • Color radios only? Yes, here. The B&W bitmap fonts have no Arabic glyphs.
  • Flash size? TX16S AR firmware uses 80.05% of flash (1639 of 2048 KB). TX15 runs from QSPI, so its internal-flash figure isn't comparable. The Arabic fonts only go into AR builds. Every radio compiles every voice language, so tts_ar.cpp adds about 730 bytes on B&W radios (Zorro: 4.24 KB free).
  • Best way to start? Done: the full translation came in as a PR against this branch (Full Arabic translation for ar.h #8034). Corrections to strings can go in the same way: a PR against this branch, or a comment with the changed file attached. After the strings change, two generators have to be re-run and their output committed. just gen-fonts makes lv_font_ar_* pick up any new letters. just cfn-sort updates the special function sort order, and needs the ar_SA.UTF-8 locale installed (see tools/cfn_sorter.sh). The Custom function sort order check fails if cfn_sort.cpp is out of date.

Known gaps / TODO

  • Translate the rest of ar.h (Full Arabic translation for ar.h #8034 by GyroGhost, merged into this branch)
  • Review the translated strings, and check they fit on screen (simulator / hardware) (Arabic language support (RTL) – happy to do the translation #8027)
  • Regenerate lv_font_ar_* for the full translation, which adds ؟, ـ and 8 more Arabic letters (a15835e)
  • Native-speaker review of the tts_ar.cpp grammar and unit genders
  • Arabic voice pack for edgetx-sdcard-sounds, following the tts_ar.cpp prompt layout. Template PR: feat(ar): add Arabic voice pack edgetx-sdcard-sounds#194
  • Add ar_SA.UTF-8 to the locale-gen lists in tools/setup_buildenv_ubuntu2{2,4}.04.sh
  • build-edgetx: add ar_SA.UTF-8 to the locale-gen list in dev/Dockerfile. chore: add ar_SA locale for Arabic build-edgetx#62, merged. The ar_SA sort order was regenerated in a5868bb.
  • Cloud build / download servers need to accept ar
  • Translate companion_ar.ts (Companion UI)
  • Companion RTL polish, all minor: the mixes list text stays left to right, the expand arrows (▶) and the wizard's Next/Back arrows don't flip, and the new-model wizard text stays left-aligned
  • The primitives/transparency screenshot gtests have no AR reference images. They fail when gtests are built with TRANSLATIONS=AR, as they do for HE. CI runs them in EN.

Testing

  • Firmware builds: TX16S in AR and HE, and Zorro in EN. After rebasing on main: TX16S and TX15 in AR (a5868bb). Both binaries contain the Arabic strings from ar.h.
  • gtests: EN TX16S 277/277. AR TX16S 276/278; the 2 failures are the screenshot tests listed above.
  • Companion builds, and its gtests passed (53/53) before the rebase.
  • After rebasing on main: Companion built and run headless with an Arabic system locale. The main window, menus, models list, settings dialog and the model editor's Setup, Outputs, Curves and Mixes tabs all lay out right to left. The simulator was not checked.
  • A temporary render test (not included) drew Arabic through BitmapBuffer at every font size from XXS to XL bold. Letters join correctly, the لا ligature forms, and mixed Arabic/Latin/digits come out in the right order.
  • tts_ar.cpp compiled on the host against a stub plays the expected prompt sequence for 1, 2, 3, 11, 21, 103, 1250, 2000, decimals and durations.
  • Not yet tested on hardware.

🤖 Generated with Claude Code

pfeerick added a commit to EdgeTX/edgetx-sdcard-sounds that referenced this pull request Nov 12, 2026
voices/ar-SA.csv lists every file the Arabic TTS in the firmware
(radio/src/translations/tts/tts_ar.cpp, EdgeTX/edgetx#8031) can play,
plus all other prompts from en-US.csv, with the Translation column
left empty for a native speaker to fill in. The Context column
explains the grammatical form each file needs (masculine/feminine
number sets, the four thousand forms, and singular/dual/plural/
accusative unit forms) and the gender the firmware assumes per unit.

Adds an Azure job (ar-SA-ZariyahNeural -> SOUNDS/ar) so audio can be
generated once translations exist; rows without a translation are
skipped. README documents the template. No audio or sounds.json
entry yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pfeerick pfeerick added enhancement ✨ New feature or request and removed needs:translation labels Nov 13, 2026
@pfeerick pfeerick added this to the 3.0 milestone Nov 13, 2026
pfeerick and others added 6 commits November 13, 2026 02:52
Adds Arabic as a radio language for color LCD radios. Strings only;
the screen layout is not mirrored.

Firmware
- AR added to RADIO_LANGUAGES/TTS_LANGUAGES and RTL_LANGUAGES (bidi).
  New AP_LANGUAGES / TRANSLATION_NEEDS_AP enables LVGL Arabic letter
  shaping (LV_USE_ARABIC_PERSIAN_CHARS, lv_txt_ap.c) for AR builds and
  the simulator.
- BitmapBuffer::drawSizedText() also shapes text containing Arabic,
  since text drawn there bypasses lv_label (custom widgets, Lua).
  Not compiled into the bootloader, whose strings are never Arabic.
- i18n/ar.h: copy of en.h with the main menu strings translated
  (needs native speaker review). TR_VOICE_ARABIC added to all
  translations.
- Fonts: Noto Sans Arabic (OFL) with get_char_ar.py; the full Arabic
  Presentation Forms-B block is always included because shaped forms
  never appear in the source text. lv_font_ar_* generated for all
  screen sizes; CJK fonts regenerated for the new voice-name glyphs.
- tts_ar.cpp: Arabic number/duration grammar based on tts_ru.cpp:
  4 unit forms (singular/dual/plural/accusative), separate masculine
  and feminine 0-99 prompt blocks (gender polarity is in the
  recordings), dual/plural thousands, and per-unit gender. The
  prompt layout in the file header is the spec for a voice pack.
- Simulator: lang_ar.cpp, font tables and shared font buffer.
- cfn sort order regenerated with ar_SA.UTF-8.
- B&W radios: AR is not selectable as text language (no fonts).

Companion
- "ar" added to the firmware language list, and Arabic to the voice
  language and color text language selectors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cfn_sorter.sh needs ar_SA.UTF-8 to sort the Arabic custom function list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an empty companion_ar.ts (generated with the companion_translations
target) and list "ar" in the Companion UI languages, so Arabic can be
selected under "Set Menu Language" and translated with Qt Linguist.

The locale is language-only ("ar"), as the translation is Modern
Standard Arabic and not country specific. Qt's own qtbase_ar.qm sets
the application layout direction to right-to-left, so no extra RTL
code is needed. The other .ts changes are lupdate line number updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
B&W radios have no Arabic glyphs, so treat AR like CN/JP/KO/TW and
skip it for B&W targets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pfeerick
pfeerick force-pushed the feat/arabic-translation branch from c59fa17 to a15c675 Compare November 13, 2026 03:14
pfeerick and others added 6 commits November 13, 2026 03:30
The AR block was generated while the ar.h function names were still
English placeholders. Re-run `just cfn-sort` now that #8034 translated
them, so the Custom function sort order check passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Shorten quick menu labels that were cut off (Flight Reset, Apps)
- Use English for the trims/subtrim actions on the Outputs page, where mixed Arabic/English rendered in the wrong word order
- Use مستشعر for "sensor"
lz4_font.cpp drops the kerning data for fonts built with NO_KERN but
still copied kern_classes from the source font. decompressFont() then
built a kerning table whose class mappings and values all pointed at
offset 0 (the glyph descriptors), with right_class_cnt = 0, so LVGL
read glyph descriptor bytes as kerning values and shifted glyphs by
up to +-8 px. In Arabic XS tiles letters overlapped so text looked
missing ("التطبيقات" showed as "يقات"), and "إعداد" had a gap.

Only fonts whose source has kerning classes and are built with
NO_KERN are affected; today that is only Arabic (Noto Sans Arabic).
The HE/CN/TW/KO subsets have no kerning classes. Set kern_classes = 0
for NO_KERN fonts and regenerate: only the kern_classes and
lvglFontBufSize lines of the Arabic compressed fonts change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LVGL's default base direction is LTR. A string such as
"إضافة كل Trims إلى Subtrims" is split into RTL and LTR runs by the
Latin words, and with an LTR base those runs are laid out left to
right, so the phrase reads in the wrong order. (Text that is only
Arabic words is a single RTL run and was already correct.)

When bidi is enabled, give the main screen, top and system layers
base_dir AUTO so each text takes its direction from its first strong
character, and use AUTO for text drawn through
BitmapBuffer::drawSizedText(). AUTO doesn't mirror flex/grid layouts
(only RTL does), and text_align LEFT on the same roots keeps
unaligned text where it is today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
translations/sim/lang_ar.cpp was created from lang_he.cpp and still
included i18n/he.h, so selecting Arabic as the text language in the
simulator (and Companion's simulator) showed the Hebrew strings,
which the Arabic font can't draw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pfeerick
pfeerick marked this pull request as ready for review November 17, 2026 03:15
@pfeerick
pfeerick merged commit 2108dea into main Nov 17, 2026
61 checks passed
@pfeerick
pfeerick deleted the feat/arabic-translation branch November 17, 2026 03:16
pfeerick added a commit to EdgeTX/edgetx-sdcard-sounds that referenced this pull request Nov 19, 2026
Adds voices/ar-SA.csv following the Arabic TTS prompt layout in the
firmware (tts_ar.cpp, EdgeTX/edgetx#8031), the generated SOUNDS/ar
audio (Azure ar-SA-ZariyahNeural), a sounds.json entry and a README
section. Translations by GyroGhost, partly tested by him as a native
Arabic speaker.

Co-authored-by: GyroGhost <111621931+GyroGhost@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request translation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants