import re

path = '/home/tranhiep/tads.ctv.hanoi.vn/assets/lang.js'
with open(path, 'r', encoding='utf-8') as f:
    content = f.read()

new_strings = {
    'vi': "    explore_progress:'Tiến độ khám phá',\n    directions:     'Chỉ đường',",
    'en': "    explore_progress:'Exploration Progress',\n    directions:     'Directions',",
    'zh': "    explore_progress:'探索进度',\n    directions:     '导航',",
    'ja': "    explore_progress:'探索の進捗',\n    directions:     'ナビ',",
    'ko': "    explore_progress:'탐색 진행률',\n    directions:     '길 안내',",
    'fr': "    explore_progress:'Progression',\n    directions:     'Itinéraire',",
}

for lang, lines in new_strings.items():
    # Tìm km_away trong block lang
    pattern = r"(  " + lang + r": \{[^}]*?km_away:[^\n]+)"
    match = re.search(pattern, content, re.DOTALL)
    if match:
        content = content[:match.end()] + '\n' + lines + content[match.end():]
        print("OK " + lang)
    else:
        print("FAIL " + lang)

with open(path, 'w', encoding='utf-8') as f:
    f.write(content)
print("Done!")
