#!/usr/bin/env python3 """Generate patch v2 assets: - layout/theme1/hiby_apps_main.view (app list page) - str/<13 langs>/apps.ini (title/back/hint/row placeholder text) """ import os ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "apps_assets") VIEW = """{ "viewgroup":{ "textview":{ "name":"apps_tv_title", "size":32, "color":"0x32526c", "focus_color":"0x32526c", "type":"static|h_center", "ini":"apps.ini", "text":"apps_title", "x":40, "y":10, "w":400, "h":40, "textview":true }, "textview":{ "name":"apps_tv_0", "size":24, "color":"0x32526c", "focus_color":"0x1062f2", "type":"static|left", "ini":"apps.ini", "text":"app_row_0", "x":40, "y":90, "w":400, "h":44, "textview":true }, "textview":{ "name":"apps_tv_1", "size":24, "color":"0x32526c", "focus_color":"0x1062f2", "type":"static|left", "ini":"apps.ini", "text":"app_row_1", "x":40, "y":146, "w":400, "h":44, "textview":true }, "textview":{ "name":"apps_tv_2", "size":24, "color":"0x32526c", "focus_color":"0x1062f2", "type":"static|left", "ini":"apps.ini", "text":"app_row_2", "x":40, "y":202, "w":400, "h":44, "textview":true }, "textview":{ "name":"apps_tv_3", "size":24, "color":"0x32526c", "focus_color":"0x1062f2", "type":"static|left", "ini":"apps.ini", "text":"app_row_3", "x":40, "y":258, "w":400, "h":44, "textview":true }, "textview":{ "name":"apps_tv_4", "size":24, "color":"0x32526c", "focus_color":"0x1062f2", "type":"static|left", "ini":"apps.ini", "text":"app_row_4", "x":40, "y":314, "w":400, "h":44, "textview":true }, "textview":{ "name":"apps_tv_5", "size":24, "color":"0x32526c", "focus_color":"0x1062f2", "type":"static|left", "ini":"apps.ini", "text":"app_row_5", "x":40, "y":370, "w":400, "h":44, "textview":true }, "textview":{ "name":"apps_tv_6", "size":24, "color":"0x32526c", "focus_color":"0x1062f2", "type":"static|left", "ini":"apps.ini", "text":"app_row_6", "x":40, "y":426, "w":400, "h":44, "textview":true }, "textview":{ "name":"apps_tv_7", "size":24, "color":"0x32526c", "focus_color":"0x1062f2", "type":"static|left", "ini":"apps.ini", "text":"app_row_7", "x":40, "y":482, "w":400, "h":44, "textview":true }, "textview":{ "name":"apps_tv_hint", "size":18, "color":"0x92a4b3", "focus_color":"0xa7b0bf", "type":"static|h_center", "ini":"apps.ini", "text":"apps_hint", "x":40, "y":520, "w":400, "h":36, "textview":true }, "textview":{ "name":"apps_tv_note", "size":16, "color":"0x9fb8d9", "focus_color":"0x9fb8d9", "type":"static|h_center", "ini":"apps.ini", "text":"apps_note", "x":40, "y":570, "w":400, "h":30, "textview":true }, "textview":{ "name":"apps_tv_back", "size":20, "color":"0x92a4b3", "focus_color":"0x1062f2", "type":"static|h_center", "ini":"apps.ini", "text":"apps_back", "x":40, "y":640, "w":400, "h":40, "textview":true }, "name":"vg_apps_main_hiby", "type":"lg_view", "x":0, "y":0, "w":480, "h":720, "color":"0xe4f5fe", "viewgroup":true, "add_layout":true } } """ # 13 languages, matching the firmware's str/ dirs LANGS = ["simplified_chinese", "traditional_chinese", "english", "russian", "korean", "japanese", "german", "italy", "spain", "poland", "french", "thai", "ukrainian"] T = { "simplified_chinese": ("应用列表", "返回", "点击应用启动,按任意键退出", "---"), "traditional_chinese": ("應用列表", "返回", "點擊應用啟動,按任意鍵退出", "---"), "english": ("Apps", "Back", "Tap an app to launch; press any key to exit", "---"), "russian": ("Приложения", "Назад", "Нажмите приложение; любая клавиша — выход", "---"), "korean": ("앱", "뒤로", "앱을 눌러 실행; 아무 키나 누르면 종료", "---"), "japanese": ("アプリ", "戻る", "アプリをタップして起動、任意キーで終了", "---"), "german": ("Apps", "Zurück", "App antippen; beliebige Taste beendet", "---"), "italy": ("App", "Indietro", "Tocca un'app; un tasto qualsiasi esce", "---"), "spain": ("Apps", "Atrás", "Toca una app; cualquier tecla sale", "---"), "poland": ("Aplikacje", "Wstecz", "Dotknij aplikacji; dowolny klawisz kończy", "---"), "french": ("Applications", "Retour", "Touchez une app ; toute touche quitte", "---"), "thai": ("แอป", "กลับ", "แตะแอปเพื่อเปิด กดปุ่มใดก็ได้เพื่อออก", "---"), "ukrainian": ("Застосунки", "Назад", "Торкніться застосунку; будь-яка клавіша — вихід", "---"), } def ini_xml(entries): body = "".join(f" <{k}>{v}\r\n" for k, v in entries) s = '\r\n\r\n' + body + "\r\n" return b"\xff\xfe" + s.encode("utf-16-le") def main(): # .view p = os.path.join(ROOT, "layout", "theme1", "hiby_apps_main.view") os.makedirs(os.path.dirname(p), exist_ok=True) with open(p, "w") as f: f.write(VIEW) # ini per language for lang in LANGS: title, back, hint, row = T[lang] entries = [("apps_title", title), ("apps_back", back), ("apps_hint", hint), ("apps_note", "MeowAPPs/MyApp/app.json")] for i in range(8): entries.append((f"app_row_{i}", row)) d = os.path.join(ROOT, "str", lang) os.makedirs(d, exist_ok=True) with open(os.path.join(d, "apps.ini"), "wb") as f: f.write(ini_xml(entries)) print(f"assets written under {ROOT}") print(" hiby_apps_main.view + apps.ini x", len(LANGS)) if __name__ == "__main__": main()