cd /news/ai-agents/finding-menu-items-in-31-languages-b… · home › topics › ai-agents › article
[ARTICLE · art-174444] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Finding menu items in 31 languages by reading the app's own translation files

A developer building Movie Engine, an AI agent that drives Kdenlive's Windows UI Automation to reload projects, described reading the app's own shipped translation catalogs to resolve localized control names across 31 languages instead of guessing translations. The approach parses GNU gettext .mo files (kxmlgui6, kconfigwidgets6, kdenlive) with a minimal PowerShell reader and Qt .qm files by computing ELF hashes of source strings, since modern lrelease drops the English source text. The developer noted a Windows PowerShell 5.1 pitfall where the .mo magic number 0x950412de parses as a negative Int32, and that CJK accelerators like ファイル(F) are retained because UI Automation reports them.

recommendation

Read control names from the app's own .mo/.qm catalogs and strip '&' accelerators, keeping CJK bracketed accelerators, so UI Automation agents work under any UI language.

more in playbook: Designing agent systems
by read6 min views2 publishedNov 23, 2026

Part 3 of a series on Movie Engine, where an AI agent edits Kdenlive video projects while the editor stays open. Earlier: Part 1, the overview, Part 2, UI Automation without stealing focus.

Movie Engine makes a running Kdenlive reload a project by pressing File > Revert through Windows UI Automation. UI Automation finds controls by their name, and the name is whatever the interface shows. In English it is "File" and "Revert". In German it is "Datei" and "Zuletzt gespeicherte Fassung". In Japanese it is "ファイル(F)" and "戻す(V)".

The launchers start Kdenlive in English by default (LANGUAGE=en_US), but a user who prefers their own language sets MOVIE_ENGINE_UI_LANG=de and the automation must still work. This post is about where the names come from and how each language is checked.

The tempting approach is to type the names in from memory or a translation service. That fails quietly: KDE's German for "Revert" is not "Zurücksetzen", it is "Zuletzt gespeicherte Fassung". The only correct source is the translation catalog the program actually loads.

The portable Kdenlive 26.08.3 for Windows ships them under bin/data/locale/<lang>/LC_MESSAGES/. The strings we need come from four files:

String File Format
File (menu) kxmlgui6.mo GNU gettext
Save, Revert, Open Recent kconfigwidgets6.mo GNU gettext
Create Folder, " project" kdenlive.mo GNU gettext
Information (message box title) kwidgetsaddons6_qt.qm Qt Linguist

GNU .mo is a simple binary format: a magic number, a count, and two tables of (length, offset) pairs pointing to the original and the translated strings. Here is a minimal reader in PowerShell (written for this post and checked against the shipped files):

function Read-Mo([string]$path) {
    $b = [IO.File]::ReadAllBytes($path)
    $u32 = { param($o) [BitConverter]::ToUInt32($b, $o) }
    if ((& $u32 0) -ne 2500072158) { throw 'not a little-endian .mo file' }   # 0x950412de
    $count = & $u32 8; $orig = & $u32 12; $trans = & $u32 16
    $utf8 = [Text.Encoding]::UTF8
    $map = @{}
    for ($i = 0; $i -lt $count; $i++) {
        $ol = & $u32 ($orig + 8 * $i); $oo = & $u32 ($orig + 8 * $i + 4)
        $tl = & $u32 ($trans + 8 * $i); $to = & $u32 ($trans + 8 * $i + 4)
        $id = $utf8.GetString($b, $oo, $ol).Split([char]4)[-1].Split([char]0)[0]
        $map[$id] = $utf8.GetString($b, $to, $tl).Split([char]0)[0]
    }
    $map
}
(Read-Mo "$loc\de\LC_MESSAGES\kconfigwidgets6.mo")['Re&vert']   # "Zuletzt gespeicherte Fassung" once the & is removed

Notice the magic number is written in decimal. In Windows PowerShell 5.1, 0x950412de is parsed as a negative Int32, so comparing it with the unsigned value read from the file always fails. I hit that while writing this post.

The keys carry the keyboard accelerator: &File, Re&vert, Open &Recent. UI Automation reports names without the &, so it is stripped. CJK translations keep the accelerator in brackets at the end, ファイル(F), and that part stays: it is what UIA reports.

Qt's .qm format surprised me. It is a sequence of tagged blocks (0x42 hash table, 0x69 messages, ...), and the messages block holds translations as UTF-16BE, but modern lrelease drops the English source text. Qt looks a message up by an ELF hash of the source string. So to read "Information" you hash "Information" and follow the hash table:

[uint32]$h = 0
foreach ($c in [Text.Encoding]::UTF8.GetBytes($source)) {
    $h = (($h -shl 4) -band 0xFFFFFFFFL) + $c
    $g = $h -band 0xF0000000L
    if ($g) { $h = $h -bxor ($g -shr 24); $h = $h -band (-bnot $g -band 0xFFFFFFFFL) }
}
if (-not $h) { $h = 1 }

That gives Informationen for German, Ilmoitus for Finnish, Bilgi for Turkish: the same values that are in the engine.

The engine does not parse catalogs at run time. The names were extracted once and live in engine/tools/kd-ui.ps1, English first:

$script:KdNames = @{
    File    = @('File', 'Файл', 'Datei', 'Fichier', 'Archivo', 'Arquivo', '文件(F)', 'ファイル(F)', 'Plik', ...)
    Revert  = @('Revert', 'Восстановить', 'Відновити', 'Zuletzt gespeicherte Fassung', 'Annuler', ...)
    ...
}
function New-KdNameCondition([string]$key) {
    $conds = @($script:KdNames[$key] | ForEach-Object {
        New-Object System.Windows.Automation.PropertyCondition($script:KdAE::NameProperty, $_) })
    if ($conds.Count -eq 1) { return $conds[0] }
    New-Object System.Windows.Automation.OrCondition(, [System.Windows.Automation.Condition[]]$conds)
}

One OrCondition covers every language at once, so the code that opens the File menu does not need to know which language is running. Dialog titles ("Information", " project", the "revert to last saved version?" question) are matched by regular expressions built the same way. Several languages share a word ("Fil" is the File menu in Danish and Norwegian Bokmål, "Datoteka" in Bosnian, Croatian and Slovenian), so the File list has fewer entries than there are languages.

The supported set is 31 interface languages: en, ru, uk, de, fr, es, pt_BR, zh_CN, ja, it, pl, ar, bs, ca, cs, da, el, et, fi, ga, hr, hu, lt, lv, nb, nl, ro, sk, sl, sv, tr.

A name table is only a claim until a real Kdenlive in that language confirms it. engine/tools/kd-langcheck.ps1 starts a throw-away Kdenlive with MOVIE_ENGINE_UI_LANG set, on a separate Windows desktop created by kd-hidden.ps1 (CreateDesktop, so it can never take my focus). It reads the menu bar, finds the File menu and the Save button, expands File and looks for Revert and Open Recent:

$menu = $file.GetCurrentPattern([System.Windows.Automation.ExpandCollapsePattern]::Pattern)
try { $menu.Expand() } catch { }
for ($i = 0; $i -lt 30 -and -not ($revert -and $recent); $i++) {
    Start-Sleep -Milliseconds 200
    if (-not $revert) { $revert = Find-KdNamed $file 'Revert' }
    if (-not $recent) { $recent = Find-KdNamed $file 'Recent' }
}

It exits 0 only when all four were found. Each run's report is kept in docs/proof/language-<lang>.txt, for example:

language check, 2026-11-23 05:12, MOVIE_ENGINE_UI_LANG='ja'
menu bar: ファイル(F) | 編集 | ビュー | メディア | シーケンス | ツール | モニタ | マーカー | 設定(S) |  | ヘルプ(H)
File menu found: True as 'ファイル(F)'
Save button found: True as '保存(S)'
Revert item found: True as '戻す(V)'

The German check passed, but its menu bar looked like this:

menu bar: Datei | Bearbeiten | Ansicht | Мультимедиа | Последовательность | Werkzeug | ...

"Media" and "Sequence" are Russian. Those strings are missing from the German translation, and instead of falling back to English, the missing ones fell back to the Windows display language of the test machine, which is Russian. The four items the engine needs are translated, so the check passes, but it is a reminder that an interface can mix languages, and that a table built on one PC is only proven for what it actually checked.

Two more notes from the docs: a language Kdenlive has no kdenlive.mo for (for example Swahili or Amharic) shows English menus, which already work. Adding a new language means adding its names to kd-ui.ps1 and running kd-langcheck.ps1 with MOVIE_ENGINE_UI_LANG set to it.

.mo is easy to parse; .qm needs the ELF hash of the source text. Windows only, Kdenlive 26.08.3, MIT licensed: https://github.com/vladtarrow/movie-engine. To try it, clone the repo and run:

.\setup.cmd
── more in #ai-agents 4 stories · sorted by recency
── more on @movie engine 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/finding-menu-items-i…] indexed:0 read:6min 2026-11-23 · —