As an emerging operating system, HarmonyOS has a significant demand for software migration, where the User Interface (UI) translation accounts for a critical link. However, recent UI development has shifted to declarative paradigms, e.g., Kotlin Jetpack Compose (KJC) for Android, SwiftUI for iOS, and ArkUI for HarmonyOS, making prior translation approaches inapplicable because they target either backend logic or legacy imperative UIs. Thus, related research is limited. To systematically evaluate KJC/SwiftUI-to-ArkUI migration, we build a parallel benchmark of 100 KJC and 100 SwiftUI files across eight scenarios, plus 52 real-world UI pages from nine open-source apps. Evaluating nine direct-translation setups (including diverse LLMs and agents), we find Compilation Success Rate (CSR) spans 0.00%-35.00%; common strategies (reference screenshots and compiler-guided repair) lift capable setups to 94.00%-99.00% CSR but fail on lightweight LLMs. By manually analyzing a 3,102-sample subset, deriving a regular-expression pattern for each failure family, and applying these patterns to generalize the resulting taxonomy to the full 29,593-sample set, we find residual errors rooted in (1) broken structure, (2) nonexistent APIs, and (3) missing resources (e.g., colors, strings, and icons). Accordingly, we propose ArkTrans, a declarative UI translation framework that maps these roots to deterministic structure supply, ArkUI knowledge and resource reference injection via a demonstration example, and iterative repair targeting residual errors, via four steps: Metadata Extraction, Skeleton Construction, LLM-driven Translation, and Compiler-Guided Iterative Repair. With Qwen3.6-27B, ArkTrans raises CSR from 0.00% to 70.00% on KJC and 64.00% on SwiftUI, achieving strong visual fidelity, and attains 65.63%/80.00% CSR on real-world pages, far outperforming the best common strategy at lower token cost.
翻译:暂无翻译