Translation Tool

Runtime label translation for ASM UI (asm_ui_app) using Frappe Translation doctype records.

Features

  • Bulk API: flat { source_text: translated_text } map for a language
  • Client-side label_translator.js replaces hardcoded English labels/sections when Arabic is active
  • Cache invalidation when Translation records change

Install

cd ~/frappe-bench
bench get-app translation_tool  # if not already in apps/
bench --site <site> install-app translation_tool
bench build --app translation_tool
bench --site <site> clear-cache

Ensure translation_tool is listed in sites/<site>/apps.txt after install.

Translation records

Create rows in Translation doctype:

language source_text translated_text
ar Asset Information معلومات الأصل
ar Workflow Actions إجراءات سير العمل

source_text must match the visible English UI string exactly.

API

  • translation_tool.api.translations.get_translations?language=ar
  • translation_tool.api.translations.get_translation?source_text=...&language=ar
  • translation_tool.api.translations.get_available_languages

Changes in asm_ui_app — Translation Tool Integration

  • No React page files were changed.

  • Only the following 3 HTML entry files were updated by adding the label_translator.js script.

  • Added Script

  • <script src="/assets/translation_tool/js/label_translator.js?v=1.0.2" defer></script>

Modified Files

File Change
asm_ui_app/asm_app/index.html Added label_translator.js script. This is the source template and will be preserved for future Vite builds.
asm_ui_app/asm_ui_app/www/asm_app.html Added label_translator.js script. This is the live Frappe web route entry file.
asm_ui_app/asm_ui_app/public/asm_app/index.html Added label_translator.js script. This is the built SPA entry copy.
Description
Seera Unified Translation_Tool
Readme 36 KiB
Languages
JavaScript 68.6%
Python 31.4%