/**
 * Heritage Voice — lang.js
 * UI strings cho 6 ngôn ngữ: VI · EN · ZH · JA · KO · FR
 * Sử dụng: T('key') hoặc T('key', {var: value})
 */

const HV_LANG = {

  vi: {
    // ── Bottom Nav ─────────────────────────────────────────
    nav_home:       'Trang chủ',
    nav_map:        'Bản đồ',
    nav_qr:         'Quét QR',
    nav_profile:    'Hồ sơ',
    nav_chat:       'Hỏi AI',

    // ── Home ───────────────────────────────────────────────
    nearby:         'Gần bạn',
    featured:       'Nổi bật',
    resume:         'Tiếp tục nghe',
    all_sites:      'Tất cả di sản',
    provinces:     'Tỉnh thành',
    good_morning:  'Chào buổi sáng',
    good_afternoon: 'Chào buổi chiều',
    good_evening:   'Chào buổi tối',
    search_hint:    'Tìm di sản...',
    audio_points:   'Điểm nghe',
    duration:       'Thời gian',
    listen_now:     'Nghe ngay',
    explore_map:    'Khám phá bản đồ',

    // ── Detail ─────────────────────────────────────────────
    overview:       'Tổng quan',
    audio_tab:      'Điểm nghe',
    map_tab:        'Bản đồ',
    full_profile:   'Hồ sơ di tích đầy đủ',
    ask_ai:         'Hỏi AI về di tích này',
    join_tour:      'Tham gia tour',
    start_tour:     'Bắt đầu tour',
    points:         'điểm',
    minutes:        'phút',

    // ── Map ────────────────────────────────────────────────
    explore_mode:   'Khám phá',
    filter_all:     'Tất cả',
    filter_nearby:  'Gần đây',
    locate_me:      'Vị trí của tôi',
    loading_map:    'Đang tải bản đồ...',

    // ── Profile ────────────────────────────────────────────
    profile:        'Hồ sơ',
    activity:       'Hoạt động',
    favorites:      'Yêu thích',
    settings:       'Cài đặt',
    guide_tab:      'HDV',
    listened:       'Đã nghe',
    visited:        'Đã đến',
    qr_scanned:     'QR đã quét',
    fav_count:      'Yêu thích',
    no_history:     'Chưa có lịch sử nghe',
    no_favorites:   'Chưa có di sản yêu thích',
    logout:         'Đăng xuất',
    edit_profile:   'Chỉnh sửa hồ sơ',
    language:       'Ngôn ngữ',
    notifications:  'Thông báo',
    change_password:'Đổi mật khẩu',

    // ── Guide ──────────────────────────────────────────────
    guide_title:    'Hướng dẫn viên',
    guide_sites:    'Di sản bạn được dẫn tour',
    guide_apply:    'Đăng ký làm Hướng dẫn viên',
    guide_pending:  'Đơn đang chờ duyệt',
    guide_approved: 'Đã được duyệt',
    guide_rejected: 'Không được duyệt',
    start_guide:    'Dẫn tour',
    tours_led:      'tour đã dẫn',

    // ── Tour Guest ─────────────────────────────────────────
    join_tour_title:'Tham gia Tour',
    pin_hint:       'Nhập mã PIN từ hướng dẫn viên',
    pin_label:      'Mã PIN (6 chữ số)',
    lang_label:     'Chọn ngôn ngữ thuyết minh',
    join_btn:       'Tham gia tour',
    waiting_guide:  'Đang chờ hướng dẫn viên...',
    now_playing:    'Đang phát',
    members_count:  'người đang tham gia tour',
    no_translation: 'Chưa có bản dịch',

    // ── Tour Host ──────────────────────────────────────────
    host_title:     'Hướng dẫn viên',
    pin_share:      'Mã PIN khách tham gia',
    copy_pin:       'Sao chép',
    copied:         'Đã sao chép',
    guests_online:  'khách đang tham gia',
    not_playing:    'Chưa phát',
    end_tour:       'Kết thúc',
    end_confirm:    'Kết thúc phiên tour? Tất cả khách sẽ bị ngắt kết nối.',
    tour_ended:     'Phiên tour đã kết thúc.',
    select_site:    'Chọn di sản muốn tour',
    start_session:  'Bắt đầu phiên tour',

    // ── Common ─────────────────────────────────────────────
    loading:        'Đang tải...',
    error_network:  'Lỗi kết nối. Kiểm tra lại mạng.',
    error_generic:  'Có lỗi xảy ra. Vui lòng thử lại.',
    back:           '←',
    save:           'Lưu',
    cancel:         'Hủy',
    close:          'Đóng',
    confirm:        'Xác nhận',
    delete:         'Xóa',
    share:          'Chia sẻ',
    offline:        'Bạn đang offline',
    login_required: 'Vui lòng đăng nhập',
    km_away:        'km',
    explore_progress:'Tiến độ khám phá',
    points_heard:  'điểm đã nghe',
    copyright:      'Copyright 2026 © Heritage Voice',
    operated_by:    'Vận hành bởi',
    contribute_title:'Bạn có tư liệu về nơi này?',
    contribute_btn: 'Đóng góp',
    verified_by:    'Nội dung kiểm chứng bởi',
    points:        'Điểm',
    relisten:      'Nghe lại',
    intro:         'Giới thiệu',
    directions:     'Chỉ đường',
    m_away:         'm',
    type_relic:     'Di tích',
    type_relic_full:'Di tích lịch sử',
    type_museum:    'Bảo tàng',
    type_craft:     'Làng nghề',
    type_heritage:  'Di sản thế giới',
    type_landscape: 'Danh thắng',
    explore_themes: 'Khám phá theo chủ đề',
    home_hero:      'Khám phá di sản',
    home_hero2:     'quanh bạn hôm nay',
    all_sites:      'Điểm đến',
  },

  en: {
    nav_home:       'Home',
    nav_map:        'Map',
    nav_qr:         'Scan QR',
    nav_profile:    'Profile',
    nav_chat:       'Ask AI',
    nearby:         'Nearby',
    featured:       'Featured',
    resume:         'Continue Listening',
    all_sites:      'All Heritage Sites',
    provinces:     'Provinces',
    good_morning:  'Good morning',
    good_afternoon: 'Good afternoon',
    good_evening:   'Good evening',
    search_hint:    'Search heritage sites...',
    audio_points:   'Audio Points',
    duration:       'Duration',
    listen_now:     'Listen Now',
    explore_map:    'Explore Map',
    overview:       'Overview',
    audio_tab:      'Audio',
    map_tab:        'Map',
    full_profile:   'Full Heritage Profile',
    ask_ai:         'Ask AI about this site',
    join_tour:      'Join Tour',
    start_tour:     'Start Tour',
    points:         'points',
    minutes:        'min',
    explore_mode:   'Explore',
    filter_all:     'All',
    filter_nearby:  'Nearby',
    locate_me:      'My Location',
    loading_map:    'Loading map...',
    profile:        'Profile',
    activity:       'Activity',
    favorites:      'Favorites',
    settings:       'Settings',
    guide_tab:      'Guide',
    listened:       'Listened',
    visited:        'Visited',
    qr_scanned:     'QR Scanned',
    fav_count:      'Favorites',
    no_history:     'No listening history yet',
    no_favorites:   'No favorite sites yet',
    logout:         'Log Out',
    edit_profile:   'Edit Profile',
    language:       'Language',
    notifications:  'Notifications',
    change_password:'Change Password',
    guide_title:    'Tour Guide',
    guide_sites:    'Sites you can guide',
    guide_apply:    'Apply as Tour Guide',
    guide_pending:  'Application pending',
    guide_approved: 'Approved',
    guide_rejected: 'Not approved',
    start_guide:    'Start Tour',
    tours_led:      'tours led',
    join_tour_title:'Join Tour',
    pin_hint:       'Enter PIN from your guide',
    pin_label:      'PIN Code (6 digits)',
    lang_label:     'Select commentary language',
    join_btn:       'Join Tour',
    waiting_guide:  'Waiting for guide...',
    now_playing:    'Now Playing',
    members_count:  'people in this tour',
    no_translation: 'No translation available',
    host_title:     'Tour Guide',
    pin_share:      'Guest PIN',
    copy_pin:       'Copy',
    copied:         'Copied!',
    guests_online:  'guests online',
    not_playing:    'Not playing',
    end_tour:       'End Tour',
    end_confirm:    'End this tour session? All guests will be disconnected.',
    tour_ended:     'Tour session ended.',
    select_site:    'Select a heritage site',
    start_session:  'Start Tour Session',
    loading:        'Loading...',
    error_network:  'Connection error. Please check your network.',
    error_generic:  'Something went wrong. Please try again.',
    back:           '←',
    save:           'Save',
    cancel:         'Cancel',
    close:          'Close',
    confirm:        'Confirm',
    delete:         'Delete',
    share:          'Share',
    offline:        'You are offline',
    login_required: 'Please log in',
    km_away:        'km',
    explore_progress:'Exploration Progress',
    points_heard:  'points heard',
    copyright:      'Copyright 2026 © Heritage Voice',
    operated_by:    'Operated by',
    contribute_title:'Do you have materials about this place?',
    contribute_btn: 'Contribute',
    verified_by:    'Content verified by',
    points:        'Point',
    relisten:      'Listen again',
    intro:         'Introduction',
    directions:     'Directions',
    m_away:         'm',
    type_relic:     'Relic',
    type_relic_full:'Historical Relic',
    type_museum:    'Museum',
    type_craft:     'Craft Village',
    type_heritage:  'World Heritage',
    type_landscape: 'Landscape',
    explore_themes: 'Explore by Theme',
    home_hero:      'Discover Heritage',
    home_hero2:     'around you today',
    all_sites:      'Sites',
  },

  zh: {
    nav_home:       '首页',
    nav_map:        '地图',
    nav_qr:         '扫码',
    nav_profile:    '我的',
    nav_chat:       'AI问答',
    nearby:         '附近',
    featured:       '精选',
    resume:         '继续收听',
    all_sites:      '所有遗产',
    provinces:     '省份',
    good_morning:  '早上好',
    good_afternoon: '下午好',
    good_evening:   '晚上好',
    search_hint:    '搜索遗产地...',
    audio_points:   '音频点',
    duration:       '时长',
    listen_now:     '立即收听',
    explore_map:    '探索地图',
    overview:       '概览',
    audio_tab:      '音频',
    map_tab:        '地图',
    full_profile:   '完整遗产档案',
    ask_ai:         '向AI询问此遗产',
    join_tour:      '加入导览',
    start_tour:     '开始导览',
    points:         '个点',
    minutes:        '分钟',
    explore_mode:   '探索',
    filter_all:     '全部',
    filter_nearby:  '附近',
    locate_me:      '我的位置',
    loading_map:    '地图加载中...',
    profile:        '个人资料',
    activity:       '活动',
    favorites:      '收藏',
    settings:       '设置',
    guide_tab:      '导游',
    listened:       '已收听',
    visited:        '已到访',
    qr_scanned:     '已扫码',
    fav_count:      '收藏',
    no_history:     '暂无收听记录',
    no_favorites:   '暂无收藏',
    logout:         '退出登录',
    edit_profile:   '编辑资料',
    language:       '语言',
    notifications:  '通知',
    change_password:'修改密码',
    guide_title:    '导游',
    guide_sites:    '您可以导览的遗产',
    guide_apply:    '申请成为导游',
    guide_pending:  '申请待审核',
    guide_approved: '已批准',
    guide_rejected: '未批准',
    start_guide:    '开始导览',
    tours_led:      '次导览',
    join_tour_title:'加入导览',
    pin_hint:       '输入导游提供的PIN码',
    pin_label:      'PIN码（6位数字）',
    lang_label:     '选择讲解语言',
    join_btn:       '加入导览',
    waiting_guide:  '等待导游...',
    now_playing:    '正在播放',
    members_count:  '人正在参加导览',
    no_translation: '暂无翻译',
    host_title:     '导游',
    pin_share:      '游客PIN码',
    copy_pin:       '复制',
    copied:         '已复制',
    guests_online:  '位游客在线',
    not_playing:    '未播放',
    end_tour:       '结束导览',
    end_confirm:    '结束此次导览？所有游客将断开连接。',
    tour_ended:     '导览已结束。',
    select_site:    '选择遗产地',
    start_session:  '开始导览',
    loading:        '加载中...',
    error_network:  '网络错误，请检查网络连接。',
    error_generic:  '出现错误，请重试。',
    back:           '←',
    save:           '保存',
    cancel:         '取消',
    close:          '关闭',
    confirm:        '确认',
    delete:         '删除',
    share:          '分享',
    offline:        '您处于离线状态',
    login_required: '请先登录',
    km_away:        '公里',
    explore_progress:'探索进度',
    points_heard:  '个已收听',
    copyright:      'Copyright 2026 © Heritage Voice',
    operated_by:    '运营方',
    contribute_title:'您有关于此地的资料吗？',
    contribute_btn: '贡献',
    verified_by:    '内容经审核',
    points:        '点',
    relisten:      '重新收听',
    intro:         '简介',
    directions:     '导航',
    m_away:         '米',
    type_relic:     '遗址',
    type_relic_full:'历史遗址',
    type_museum:    '博物馆',
    type_craft:     '手工艺村',
    type_heritage:  '世界遗产',
    type_landscape: '自然景观',
    explore_themes: '按主题探索',
    home_hero:      '探索遗产',
    home_hero2:     '发现身边的历史',
    all_sites:      '目的地',
  },

  ja: {
    nav_home:       'ホーム',
    nav_map:        'マップ',
    nav_qr:         'QRスキャン',
    nav_profile:    'プロフィール',
    nav_chat:       'AI質問',
    nearby:         '近く',
    featured:       '注目',
    resume:         '続きを聴く',
    all_sites:      'すべての遺産',
    provinces:     '省',
    good_morning:  'おはようございます',
    good_afternoon: 'こんにちは',
    good_evening:   'こんばんは',
    search_hint:    '遺産を検索...',
    audio_points:   '音声ポイント',
    duration:       '時間',
    listen_now:     '今すぐ聴く',
    explore_map:    'マップを探索',
    overview:       '概要',
    audio_tab:      '音声',
    map_tab:        'マップ',
    full_profile:   '遺産の詳細プロフィール',
    ask_ai:         'この遺産についてAIに質問',
    join_tour:      'ツアーに参加',
    start_tour:     'ツアー開始',
    points:         'ポイント',
    minutes:        '分',
    explore_mode:   '探索',
    filter_all:     'すべて',
    filter_nearby:  '近く',
    locate_me:      '現在地',
    loading_map:    'マップを読み込み中...',
    profile:        'プロフィール',
    activity:       'アクティビティ',
    favorites:      'お気に入り',
    settings:       '設定',
    guide_tab:      'ガイド',
    listened:       '聴いた',
    visited:        '訪問した',
    qr_scanned:     'QRスキャン',
    fav_count:      'お気に入り',
    no_history:     '視聴履歴がありません',
    no_favorites:   'お気に入りがありません',
    logout:         'ログアウト',
    edit_profile:   'プロフィール編集',
    language:       '言語',
    notifications:  '通知',
    change_password:'パスワード変更',
    guide_title:    'ツアーガイド',
    guide_sites:    'ガイドできる遺産',
    guide_apply:    'ツアーガイドに申請',
    guide_pending:  '申請中',
    guide_approved: '承認済み',
    guide_rejected: '不承認',
    start_guide:    'ツアー開始',
    tours_led:      '回ガイド',
    join_tour_title:'ツアーに参加',
    pin_hint:       'ガイドからPINを入力',
    pin_label:      'PINコード（6桁）',
    lang_label:     '解説言語を選択',
    join_btn:       'ツアーに参加',
    waiting_guide:  'ガイドを待っています...',
    now_playing:    '再生中',
    members_count:  '人がツアーに参加中',
    no_translation: '翻訳なし',
    host_title:     'ツアーガイド',
    pin_share:      'ゲストPIN',
    copy_pin:       'コピー',
    copied:         'コピーしました',
    guests_online:  '人のゲストがオンライン',
    not_playing:    '未再生',
    end_tour:       'ツアー終了',
    end_confirm:    'このツアーを終了しますか？全ゲストが切断されます。',
    tour_ended:     'ツアーが終了しました。',
    select_site:    '遺産を選択',
    start_session:  'ツアーセッション開始',
    loading:        '読み込み中...',
    error_network:  '接続エラー。ネットワークを確認してください。',
    error_generic:  'エラーが発生しました。もう一度お試しください。',
    back:           '←',
    save:           '保存',
    cancel:         'キャンセル',
    close:          '閉じる',
    confirm:        '確認',
    delete:         '削除',
    share:          'シェア',
    offline:        'オフラインです',
    login_required: 'ログインしてください',
    km_away:        'km',
    explore_progress:'探索の進捗',
    points_heard:  'ポイント聴取済み',
    copyright:      'Copyright 2026 © Heritage Voice',
    operated_by:    '運営',
    contribute_title:'この場所に関する資料をお持ちですか？',
    contribute_btn: '投稿',
    verified_by:    'コンテンツ監修',
    points:        'ポイント',
    relisten:      'もう一度聴く',
    intro:         '紹介',
    directions:     'ナビ',
    m_away:         'm',
    type_relic:     '遺跡',
    type_relic_full:'歴史的遺跡',
    type_museum:    '博物館',
    type_craft:     '工芸村',
    type_heritage:  '世界遺産',
    type_landscape: '景勝地',
    explore_themes: 'テーマ別探索',
    home_hero:      '遺産を探索',
    home_hero2:     '今日のおすすめ',
    all_sites:      '目的地',
  },

  ko: {
    nav_home:       '홈',
    nav_map:        '지도',
    nav_qr:         'QR 스캔',
    nav_profile:    '프로필',
    nav_chat:       'AI 질문',
    nearby:         '근처',
    featured:       '추천',
    resume:         '이어 듣기',
    all_sites:      '모든 유산',
    provinces:     '지방',
    good_morning:  '좋은 아침이에요',
    good_afternoon: '안녕하세요',
    good_evening:   '좋은 저녁이에요',
    search_hint:    '유산 검색...',
    audio_points:   '오디오 포인트',
    duration:       '시간',
    listen_now:     '지금 듣기',
    explore_map:    '지도 탐색',
    overview:       '개요',
    audio_tab:      '오디오',
    map_tab:        '지도',
    full_profile:   '유산 전체 프로필',
    ask_ai:         '이 유산에 대해 AI에게 질문',
    join_tour:      '투어 참가',
    start_tour:     '투어 시작',
    points:         '포인트',
    minutes:        '분',
    explore_mode:   '탐색',
    filter_all:     '전체',
    filter_nearby:  '근처',
    locate_me:      '내 위치',
    loading_map:    '지도 로딩 중...',
    profile:        '프로필',
    activity:       '활동',
    favorites:      '즐겨찾기',
    settings:       '설정',
    guide_tab:      '가이드',
    listened:       '들은',
    visited:        '방문한',
    qr_scanned:     'QR 스캔',
    fav_count:      '즐겨찾기',
    no_history:     '청취 기록이 없습니다',
    no_favorites:   '즐겨찾기가 없습니다',
    logout:         '로그아웃',
    edit_profile:   '프로필 편집',
    language:       '언어',
    notifications:  '알림',
    change_password:'비밀번호 변경',
    guide_title:    '투어 가이드',
    guide_sites:    '가이드 가능한 유산',
    guide_apply:    '투어 가이드 신청',
    guide_pending:  '신청 심사 중',
    guide_approved: '승인됨',
    guide_rejected: '미승인',
    start_guide:    '투어 시작',
    tours_led:      '회 가이드',
    join_tour_title:'투어 참가',
    pin_hint:       '가이드로부터 PIN 입력',
    pin_label:      'PIN 코드 (6자리)',
    lang_label:     '해설 언어 선택',
    join_btn:       '투어 참가',
    waiting_guide:  '가이드를 기다리는 중...',
    now_playing:    '재생 중',
    members_count:  '명이 투어 중',
    no_translation: '번역 없음',
    host_title:     '투어 가이드',
    pin_share:      '게스트 PIN',
    copy_pin:       '복사',
    copied:         '복사됨',
    guests_online:  '명의 게스트 온라인',
    not_playing:    '재생 안 함',
    end_tour:       '투어 종료',
    end_confirm:    '이 투어를 종료하시겠습니까? 모든 게스트가 연결 해제됩니다.',
    tour_ended:     '투어가 종료되었습니다.',
    select_site:    '유산 선택',
    start_session:  '투어 세션 시작',
    loading:        '로딩 중...',
    error_network:  '연결 오류. 네트워크를 확인하세요.',
    error_generic:  '오류가 발생했습니다. 다시 시도하세요.',
    back:           '←',
    save:           '저장',
    cancel:         '취소',
    close:          '닫기',
    confirm:        '확인',
    delete:         '삭제',
    share:          '공유',
    offline:        '오프라인 상태입니다',
    login_required: '로그인하세요',
    km_away:        'km',
    explore_progress:'탐색 진행률',
    points_heard:  '포인트 청취 완료',
    copyright:      'Copyright 2026 © Heritage Voice',
    operated_by:    '운영',
    contribute_title:'이 장소에 대한 자료가 있으신가요?',
    contribute_btn: '기여',
    verified_by:    '콘텐츠 검증',
    points:        '포인트',
    relisten:      '다시 듣기',
    intro:         '소개',
    directions:     '길 안내',
    m_away:         'm',
    type_relic:     '유적',
    type_relic_full:'역사 유적',
    type_museum:    '박물관',
    type_craft:     '공예 마을',
    type_heritage:  '세계 문화유산',
    type_landscape: '경치',
    explore_themes: '테마별 탐색',
    home_hero:      '유산 탐색',
    home_hero2:     '오늘의 주변 명소',
    all_sites:      '목적지',
  },

  fr: {
    nav_home:       'Accueil',
    nav_map:        'Carte',
    nav_qr:         'Scanner QR',
    nav_profile:    'Profil',
    nav_chat:       'IA',
    nearby:         'À proximité',
    featured:       'En vedette',
    resume:         'Continuer l\'écoute',
    all_sites:      'Tous les sites',
    provinces:     'Provinces',
    good_morning:  'Bonjour',
    good_afternoon: 'Bon après-midi',
    good_evening:   'Bonsoir',
    search_hint:    'Rechercher un site...',
    audio_points:   'Points audio',
    duration:       'Durée',
    listen_now:     'Écouter',
    explore_map:    'Explorer la carte',
    overview:       'Aperçu',
    audio_tab:      'Audio',
    map_tab:        'Carte',
    full_profile:   'Fiche complète du site',
    ask_ai:         'Demander à l\'IA',
    join_tour:      'Rejoindre la visite',
    start_tour:     'Commencer la visite',
    points:         'points',
    minutes:        'min',
    explore_mode:   'Explorer',
    filter_all:     'Tous',
    filter_nearby:  'Proche',
    locate_me:      'Ma position',
    loading_map:    'Chargement de la carte...',
    profile:        'Profil',
    activity:       'Activité',
    favorites:      'Favoris',
    settings:       'Paramètres',
    guide_tab:      'Guide',
    listened:       'Écouté',
    visited:        'Visité',
    qr_scanned:     'QR scanné',
    fav_count:      'Favoris',
    no_history:     'Aucun historique d\'écoute',
    no_favorites:   'Aucun site favori',
    logout:         'Déconnexion',
    edit_profile:   'Modifier le profil',
    language:       'Langue',
    notifications:  'Notifications',
    change_password:'Changer le mot de passe',
    guide_title:    'Guide touristique',
    guide_sites:    'Sites où vous guidez',
    guide_apply:    'Devenir guide',
    guide_pending:  'Candidature en attente',
    guide_approved: 'Approuvé',
    guide_rejected: 'Non approuvé',
    start_guide:    'Démarrer la visite',
    tours_led:      'visites guidées',
    join_tour_title:'Rejoindre la visite',
    pin_hint:       'Entrez le PIN de votre guide',
    pin_label:      'Code PIN (6 chiffres)',
    lang_label:     'Choisir la langue du commentaire',
    join_btn:       'Rejoindre',
    waiting_guide:  'En attente du guide...',
    now_playing:    'En cours',
    members_count:  'personnes dans la visite',
    no_translation: 'Pas de traduction',
    host_title:     'Guide touristique',
    pin_share:      'PIN visiteurs',
    copy_pin:       'Copier',
    copied:         'Copié !',
    guests_online:  'visiteurs en ligne',
    not_playing:    'Pas de lecture',
    end_tour:       'Terminer',
    end_confirm:    'Terminer cette visite ? Tous les visiteurs seront déconnectés.',
    tour_ended:     'La visite est terminée.',
    select_site:    'Choisir un site',
    start_session:  'Démarrer la session',
    loading:        'Chargement...',
    error_network:  'Erreur de connexion. Vérifiez votre réseau.',
    error_generic:  'Une erreur est survenue. Veuillez réessayer.',
    back:           '←',
    save:           'Enregistrer',
    cancel:         'Annuler',
    close:          'Fermer',
    confirm:        'Confirmer',
    delete:         'Supprimer',
    share:          'Partager',
    offline:        'Vous êtes hors ligne',
    login_required: 'Veuillez vous connecter',
    km_away:        'km',
    explore_progress:'Progression',
    points_heard:  'points écoutés',
    copyright:      'Copyright 2026 © Heritage Voice',
    operated_by:    'Exploité par',
    contribute_title:'Avez-vous des documents sur ce lieu?',
    contribute_btn: 'Contribuer',
    verified_by:    'Contenu vérifié par',
    points:        'Point',
    relisten:      'Réécouter',
    intro:         'Introduction',
    directions:     'Itinéraire',
    m_away:         'm',
    type_relic:     'Site historique',
    type_relic_full:'Site historique',
    type_museum:    'Musée',
    type_craft:     'Village artisanal',
    type_heritage:  'Patrimoine mondial',
    type_landscape: 'Paysage',
    explore_themes: 'Explorer par thème',
    home_hero:      'Découvrez le patrimoine',
    home_hero2:     'autour de vous',
    all_sites:      'Sites',
  },
};

// ── Core functions ────────────────────────────────────────────

const SUPPORTED_LANGS = ['vi','en','zh','ja','ko','fr'];
const DEFAULT_LANG    = 'vi';

function HV_getLang() {
  return localStorage.getItem('hv_lang') || DEFAULT_LANG;
}

function HV_setLang(lang) {
  if (!SUPPORTED_LANGS.includes(lang)) lang = DEFAULT_LANG;
  localStorage.setItem('hv_lang', lang);
  HV_applyLang();
}

// T('key') — lấy string theo ngôn ngữ hiện tại
function T(key) {
  const lang = HV_getLang();
  return (HV_LANG[lang] && HV_LANG[lang][key])
      || (HV_LANG[DEFAULT_LANG] && HV_LANG[DEFAULT_LANG][key])
      || key;
}

// Áp dụng lang lên toàn trang — patch các element có data-i18n
function HV_applyLang() {
  document.querySelectorAll('[data-i18n]').forEach(el => {
    const key = el.getAttribute('data-i18n');
    const attr = el.getAttribute('data-i18n-attr'); // placeholder, title, etc.
    if (attr) {
      el.setAttribute(attr, T(key));
    } else {
      el.textContent = T(key);
    }
  });
  // Update lang attribute
  document.documentElement.lang = HV_getLang();
}

// Chạy khi DOM sẵn sàng
if (document.readyState === 'loading') {
  document.addEventListener('DOMContentLoaded', HV_applyLang);
} else {
  HV_applyLang();
}
