import * as React from 'react';
import { enUS, ja, zhCN, ko } from 'date-fns/locale';
// FIX: Import the 'Locale' type from 'date-fns' to resolve the 'Cannot find name' error.
import type { Locale } from 'date-fns';

export type Language = 'en' | 'ja' | 'zh' | 'ko';

export const resources = {
  en: {
    translation: {
      // General
      'add': 'Add',
      'cancel': 'Cancel',
      'save': 'Save',
      'delete': 'Delete',
      'update': 'Update',
      'edit': 'Edit',
      'name': 'Name',
      'pro': 'PRO',
      'all': 'All',
      'for': 'For',
      'no_items_found': 'No items found.',
      'scheduled': 'Scheduled',
      'unscheduled': 'Unscheduled',
      'open': 'Open',
      'resolved': 'Resolved',
      
      // Sidebar
      'nav.page': 'Page',
      'nav.page.link': 'Link',
      'nav.page.media': 'Media',
      'nav.page.design': 'Design',
      'nav.ai_assistant': 'AI Assistant',
      'nav.ai_assistant.persona': 'Persona',
      'nav.ai_assistant.knowledge': 'Knowledge',
      'nav.ai_assistant.sensitivity': 'Sensitivity',
      'nav.analytics': 'Analytics',
      'nav.analytics.page': 'Page',
      'nav.analytics.interactions': 'Interactions',
      'nav.analytics.crm': 'CRM',
      'nav.seo': 'SEO',
      'nav.seo.short_links': 'Short Links',
      'nav.seo.hosting': 'Enterprise Hosting',
      'nav.seo.services': 'SEO Services',
      'nav.aigc': 'AIGC',
      'nav.aigc.creator': 'Creator',
      'nav.aigc.news': 'News',
      'nav.aigc.scheduler': 'Scheduler',
      'nav.showcase': 'Showcase',
      'nav.showcase.personal': 'Personal',
      'nav.showcase.enterprise': 'Enterprise',
      'sidebar.select_page': 'Select Page',
      'sidebar.logout': 'Logout',
      'sidebar.light_theme': 'Light',
      'sidebar.dark_theme': 'Dark',
      'sidebar.language': 'Language',

      // App
      'app.welcome': 'Welcome!',
      'app.no_pages_prompt': "You don't have any pages yet. Let's create your first one.",
      'app.create_first_page': 'Create Your First Page',
      'app.import_success': "'{{name}}' has been added to your pages! You can now edit it.",
      'app.videos_generated_success': "{{count}} video(s) generated successfully! You can find them in the Content Scheduler's video library.",
      'app.form_submission_success': 'New form submission received! You can view it in the CRM.',
      'app.no_page_selected': 'No Page Selected',
      
      // Page Builder
      'page_builder.title': 'My Page',
      'page_builder.url_prompt': 'Your public URL:',
      'page_builder.share': 'Share',
      'page_builder.personal_mode': 'Personal',
      'page_builder.enterprise_mode': 'Enterprise',
      'page_builder.exit_fullscreen': 'Exit Fullscreen',
      
      // Link Editor
      'link_editor.add_block': 'Add Block',
      'link_editor.header_text': 'Header Text',
      'link_editor.alignment': 'Alignment',
      'link_editor.title': 'Title',
      'link_editor.url': 'URL',
      'link_editor.thumbnail_url': 'Thumbnail URL (Optional)',
      'link_editor.display_style': 'Display Style',
      'link_editor.under_avatar': 'Under Avatar',
      'link_editor.block_button': 'Block Button',
      'link_editor.floating_widget': 'Floating Widget',
      'link_editor.icon': 'Icon',
      'link_editor.label': 'Label',
      'link_editor.value': 'Value',
      'link_editor.add_info_item': 'Add Info Item',
      'link_editor.add_link': 'Add Link',
      'link_editor.add_mock_links': 'Add Mock Links',
      'link_editor.layout_mode': 'Layout Mode',
      'link_editor.single_column': 'Single Column',
      'link_editor.grid': 'Grid',
      'link_editor.source': 'Source',
      'link_editor.upload': 'Upload',
      'link_editor.aigc_library': 'AIGC Library',
      'link_editor.add_media': 'Add {{type}}',
      'link_editor.add_mock_media': 'Add 3 Mock {{type}}s',
      'link_editor.address': 'Address or Location',
      'link_editor.map_preview': 'Map Preview',
      'link_editor.image_overlay': 'Image Overlay',
      'link_editor.background_image': 'Background Image',
      'link_editor.button_label': 'Button Label',
      'link_editor.email_address': 'Email Address',
      'link_editor.phone_number': 'Phone Number',
      'link_editor.display_mode': 'Display Mode',
      'link_editor.label_only': 'Label Only',
      'link_editor.label_and_value': 'Label + Value',
      'link_editor.layout': 'Layout',
      'link_editor.list': 'List',
      'link_editor.content_source': 'Content Source',
      'link_editor.aigc_lib': 'AIGC Library',
      'link_editor.custom_urls': 'Custom URLs',
      'link_editor.select_articles': 'Select Articles',
      'link_editor.no_articles_selected': 'No articles selected.',
      'link_editor.select_from_aigc': 'Select from AIGC Library',
      'link_editor.add_url': 'Add URL',
      'link_editor.add_mock_items': 'Add 3 Mock Items',
      'link_editor.add_products_from_url': 'Add Products from URL',
      'link_editor.add_from_urls': 'Add from URLs',
      'link_editor.fetching': 'Fetching...',
      'link_editor.add_sample_products': 'Or Add Sample Products',
      'link_editor.add_award': 'Add Award',
      'link_editor.subtitle': 'Subtitle (e.g., Awarded by)',
      'link_editor.year': 'Year',
      'link_editor.image_url': 'Image URL',
      'link_editor.description': 'Description',
      'link_editor.form_fields': 'Form Fields',
      'link_editor.purpose_options': 'Purpose Options',
      'link_editor.submit_button_text': 'Submit Button Text',
      'link_editor.required': 'Required',
      'link_editor.add_option': 'Add Option',
      'link_editor.aigc_select_video': 'Select a Video from AIGC Library',
      
      // Design Editor
      'design_editor.templates': 'Templates',
      'design_editor.profile': 'Profile',
      'design_editor.appearance': 'Appearance',
      'design_editor.typography': 'Typography',
      'design_editor.buttons': 'Buttons',
      'design_editor.background': 'Background',
      'design_editor.enterprise_layout': 'Enterprise Layout',
      'design_editor.more_themes': 'More Themes...',
      'design_editor.avatar': 'Avatar',
      'design_editor.source': 'Source',
      'design_editor.custom': 'Custom',
      'design_editor.background_color': 'Background',
      'design_editor.text_color': 'Text Color',
      'design_editor.button_color': 'Button Color',
      'design_editor.button_text': 'Button Text',
      'design_editor.font_color': 'Font Color',
      'design_editor.font_size': 'Font Size',
      'design_editor.font_family': 'Font Family',
      'design_editor.button_style': 'Button Style',
      'design_editor.button_shape': 'Button Shape',
      'design_editor.upload_image': 'Upload Image',
      'design_editor.banner': 'Banner',
      'design_editor.banner_type': 'Banner Type',
      'design_editor.banner_width': 'Banner Width',
      'design_editor.contained': 'Contained',
      'design_editor.full_width': 'Full Width',
      'design_editor.banner_height': 'Banner Height (px)',
      'design_editor.banner_color': 'Banner Color',
      'design_editor.side_nav': 'Side Navigation',
      'design_editor.position': 'Position',
      'design_editor.normal': 'Normal',
      'design_editor.float_top': 'Float Top',
      'design_editor.float_center': 'Float Center',
      'design_editor.background_style': 'Background Style',
      'design_editor.compact': 'Compact',
      'design_editor.full_height': 'Full Height',
      'design_editor.active_link': 'Active Link',
      'design_editor.hover_bg': 'Hover BG',
      'design_editor.hover_text': 'Hover Text',
      'design_editor.chat_widget': 'Chat Widget',
      'design_editor.icon_color': 'Icon Color',
      'design_editor.header_bg': 'Header BG',
      'design_editor.header_text': 'Header Text',
      'design_editor.panel_bg': 'Panel BG',
      'design_editor.user_message': 'User Message',
      'design_editor.user_text': 'User Text',
      'design_editor.ai_message': 'AI Message',
      'design_editor.ai_text': 'AI Text',
      
      // AI Assistant
      'ai_assistant.title': 'AI Assistant',
      'ai_assistant.subtitle': "Configure your AI's behavior and knowledge.",
      'ai_assistant.test_title': 'Test your Assistant',
      'ai_assistant.save_changes': 'Save Changes',
      'ai_assistant.save_success': 'AI Assistant settings saved successfully!',
      'ai_assistant.system_instruction': 'System Instruction',
      'ai_assistant.system_instruction_desc': "Define the AI's core identity, personality, and instructions.",
      'ai_assistant.voice': 'Voice',
      'ai_assistant.voice_desc': 'Select a voice for audio responses.',
      'ai_assistant.clone': 'Clone',
      'ai_assistant.clone_desc': 'Create a clone of your own voice.',
      'ai_assistant.clone_voice': 'Clone Voice',
      'ai_assistant.language': 'Language',
      'ai_assistant.language_desc': 'The primary language for the AI.',
      'ai_assistant.conversation_style': 'Conversation Style',
      'ai_assistant.conversation_style_desc': 'The overall tone of the AI.',
      'ai_assistant.add_knowledge': 'Add Knowledge Source',
      'ai_assistant.no_knowledge': 'No knowledge sources',
      'ai_assistant.no_knowledge_desc': 'Add files or web pages for your AI to learn from.',
      'ai_assistant.forbidden_user': 'Forbidden User Topics',
      'ai_assistant.forbidden_user_desc': 'The AI will refuse to answer questions containing these keywords.',
      'ai_assistant.forbidden_ai': 'Forbidden AI Responses',
      'ai_assistant.forbidden_ai_desc': 'The AI will avoid using these keywords in its responses.',

      // Analytics
      'analytics.page.title': 'Page Analytics',
      'analytics.page.last_days': 'Last {{range}} Days',
      'analytics.page.all_time': 'All Time',
      'analytics.page.views': 'Views',
      'analytics.page.clicks': 'Clicks',
      'analytics.page.ctr': 'Click-Through Rate',
      'analytics.page.unique_visitors': 'Unique Visitors',
      'analytics.page.performance': 'Performance',
      'analytics.page.device_breakdown': 'Device Breakdown',
      'analytics.page.top_locations': 'Top Locations',
      'analytics.page.top_referrers': 'Top Referrers',
      'analytics.interactions.title': 'Customer Interaction Analytics',
      'analytics.interactions.search_placeholder': 'Search conversations...',
      'analytics.interactions.date_label': 'Date:',
      'analytics.interactions.last_7_days': 'Last 7 days',
      'analytics.interactions.last_28_days': 'Last 28 days',
      'analytics.interactions.total_conversations': 'Total Conversations',
      'analytics.interactions.resolution_rate': 'Resolution Rate',
      'analytics.interactions.avg_interactions': 'Avg. Interactions',
      'analytics.interactions.avg_first_response': 'Avg. First Response',
      'analytics.interactions.visitor_breakdown': 'Visitor Breakdown',
      'analytics.interactions.common_topics': 'Common Topics',
      'analytics.interactions.visitor': 'Visitor',
      'analytics.interactions.conversations': 'Conversations',
      'analytics.interactions.mark_resolved': 'Mark as Resolved',
      'analytics.interactions.no_conversations': 'No conversations found for the selected filters.',
      'analytics.interactions.edit_response_title': 'Edit AI Response',
      'analytics.interactions.save_and_update': 'Save & Update Model',
      'analytics.interactions.update_success': 'Response updated successfully. The AI will learn from this correction.',
      'analytics.crm.title': 'Visitor CRM',
      'analytics.crm.visitor_id': 'Visitor ID',
      'analytics.crm.last_seen': 'Last Seen',
      'analytics.crm.visits': 'Visits',
      
      // AIGC
      'aigc.creator.generate_videos_progress': 'Generating Videos...',
      'aigc.creator.processing_video': 'Processing video {{current}} of {{total}}. This may take a moment.',
      'aigc.creator.my_first_video': 'My First Video',
      'aigc.creator.untitled_video': 'Untitled Video {{count}}',
      'aigc.creator.at_least_one_scene': 'A project must have at least one scene.',
      'aigc.creator.script_first': 'Please write a script first.',
      'aigc.creator.polish_error': "Sorry, we couldn't polish the script at this time.",
      'aigc.creator.generate_videos': 'Generate {{count}} Video',
      'aigc.creator.generate_videos_plural': 'Generate {{count}} Videos',
      'aigc.creator.add_scene': 'Add Scene',
      'aigc.creator.script': 'Script',
      'aigc.creator.ai_polish': 'AI Polish',
      'aigc.creator.polishing': 'Polishing...',
      'aigc.creator.background': 'Background',
      'aigc.creator.media': 'Media',
      'aigc.creator.upload_image': 'Upload Image',
      'aigc.creator.upload_video': 'Upload Video',
      'aigc.news.title': 'News Library',
      'aigc.news.create': 'Create New Article',
      'aigc.news.edit': 'Edit Article',
      'aigc.news.save_lib': 'Save to Library',
      'aigc.news.save_changes': 'Save Changes',
      'aigc.news.ai_tools': 'AI & Import Tools',
      'aigc.news.generate_ai': 'Generate with AI',
      'aigc.news.import_url': 'Import from URL',
      'aigc.news.enter_topic': 'Enter a topic...',
      'aigc.news.enter_url': 'https://example.com/article',
      'aigc.news.generate': 'Generate',
      'aigc.news.generating': '...',
      'aigc.news.title_req': 'Title is required.',
      'aigc.news.summary': 'Summary',
      'aigc.news.full_content': 'Full Content',
      'aigc.news.delete_confirm': 'Are you sure you want to delete this article?',
      'aigc.news.empty_title': 'Select an article to view',
      'aigc.news.empty_desc': 'Or create a new one to get started.',
      'aigc.scheduler.update_post': 'Update Post',
      'aigc.scheduler.schedule_post': 'Schedule Post',
      'aigc.scheduler.time': 'Time',
      'aigc.scheduler.caption': 'Caption',
      'aigc.scheduler.post_to': 'Post to',
      'aigc.scheduler.schedule': 'Schedule',
      'aigc.scheduler.video_library': 'Video Library',
      'aigc.scheduler.no_videos_filter': 'No videos match the current filter.',
      
      // Auth
      'auth.welcome_back': 'Welcome Back',
      'auth.create_account': 'Create an Account',
      'auth.signin_prompt': 'Sign in to continue to your pages.',
      'auth.signup_prompt': 'Start building your presence in seconds.',
      'auth.email': 'Email Address',
      'auth.password': 'Password',
      'auth.processing': 'Processing...',
      'auth.signin': 'Sign In',
      'auth.signup': 'Sign Up',
      'auth.no_account': "Don't have an account?",
      'auth.has_account': 'Already have an account?',
      
      // Modals
      'modal.share.title': 'Share Your Page',
      'modal.share.pc_version': 'PC Version',
      'modal.share.mobile_version': 'Mobile Version',
      'modal.share.copy': 'Copy',
      'modal.share.copied': 'Copied!',
      'modal.pages.title': 'Select a Page',
      'modal.pages.create_new': 'Create New Page',

      // SEO & Hosting
      'seo.short_links.title': 'Short Link',
      'seo.short_links.subtitle': 'Customize your main page URL.',
      'seo.short_links.your_url': 'Your GreenPage URL',
      'seo.short_links.your_url_desc': 'This is your main link that you can share anywhere. Keep it short and memorable.',
      'seo.hosting.title': 'Enterprise Hosting',
      'seo.hosting.subtitle': 'Manage your domain, hosting, and subscription plan.',
      'seo.hosting.custom_domain': 'Connect a Custom Domain',
      'seo.hosting.custom_domain_desc': 'Use your own domain for a more professional look (e.g., links.yourcompany.com).',
      'seo.hosting.connect_domain': 'Connect Domain',
      'seo.hosting.dns_note': "You'll need to update your DNS records after connecting. We'll provide the instructions.",
      'seo.hosting.subscription': 'Managed Hosting & Subscription',
      'seo.hosting.subscription_desc': 'Choose a plan that fits your needs. All enterprise plans include hosting.',
      'seo.hosting.current_plan': 'Current Plan',
      'seo.hosting.select_plan': 'Select Plan',
      'seo.services.title': 'SEO Services',
      'seo.services.subtitle': "Boost your page's visibility and attract more organic traffic.",
      'seo.services.keyword_analysis': 'Keyword Analysis & Optimization',
      'seo.services.keyword_analysis_desc': 'Discover high-impact keywords for your content strategy. Enter a topic to get started.',
      'seo.services.analyze': 'Analyze',
      'seo.services.keyword_results_placeholder': 'Keyword analysis results will appear here.',
      'seo.services.ai_content': 'AI Content with SEO',
      'seo.services.ai_content_desc': 'Supercharge your content creation. When you generate news articles with AI, our SEO service will automatically analyze your topic and assemble relevant long-tail keywords to seamlessly integrate into the content. This helps your articles rank better on search engines.',
      'seo.services.how_it_works': 'How it works:',
      'seo.services.step1': 'You provide a topic in the AIGC News Creator.',
      'seo.services.step2': 'Our AI analyzes the topic for primary and related keywords.',
      'seo.services.step3': 'It generates a high-quality article, naturally weaving in these keywords.',
      'seo.services.step4': 'Your content is published, optimized for search engines from the start.',
      'seo.services.go_to_news_creator': 'Go to News Creator',
    },
  },
  ja: {
    translation: {
      'add': '追加',
      'cancel': 'キャンセル',
      'save': '保存',
      'delete': '削除',
      'update': '更新',
      'edit': '編集',
      'name': '名前',
      'pro': 'プロ',
      'all': 'すべて',
      'for': '対象',
      'no_items_found': 'アイテムが見つかりません。',
      'scheduled': '予約済み',
      'unscheduled': '未予約',
      'open': '未解決',
      'resolved': '解決済み',
      'nav.page': 'ページ',
      'nav.page.link': 'リンク',
      'nav.page.media': 'メディア',
      'nav.page.design': 'デザイン',
      'nav.ai_assistant': 'AIアシスタント',
      'nav.ai_assistant.persona': 'ペルソナ',
      'nav.ai_assistant.knowledge': '知識',
      'nav.ai_assistant.sensitivity': '感度',
      'nav.analytics': 'アナリティクス',
      'nav.analytics.page': 'ページ',
      'nav.analytics.interactions': 'インタラクション',
      'nav.analytics.crm': 'CRM',
      'nav.seo': 'SEO',
      'nav.seo.short_links': '短縮リンク',
      'nav.seo.hosting': '法人ホスティング',
      'nav.seo.services': 'SEOサービス',
      'nav.aigc': 'AIGC',
      'nav.aigc.creator': 'クリエーター',
      'nav.aigc.news': 'ニュース',
      'nav.aigc.scheduler': 'スケジューラ',
      'nav.showcase': 'ショーケース',
      'nav.showcase.personal': '個人',
      'nav.showcase.enterprise': '法人',
      'sidebar.select_page': 'ページを選択',
      'sidebar.logout': 'ログアウト',
      'sidebar.light_theme': 'ライト',
      'sidebar.dark_theme': 'ダーク',
      'sidebar.language': '言語',
      'app.welcome': 'ようこそ！',
      'app.no_pages_prompt': 'まだページがありません。最初のページを作成しましょう。',
      'app.create_first_page': '最初のページを作成',
      'app.import_success': '「{{name}}」があなたのページに追加されました！編集可能です。',
      'app.videos_generated_success': '{{count}}本の動画が正常に生成されました！コンテンツスケジューラの動画ライブラリにあります。',
      'app.form_submission_success': '新しいフォーム送信を受け取りました！CRMで表示できます。',
      'app.no_page_selected': 'ページが選択されていません',
      'page_builder.title': 'マイページ',
      'page_builder.url_prompt': 'あなたの公開URL:',
      'page_builder.share': '共有',
      'page_builder.personal_mode': '個人',
      'page_builder.enterprise_mode': '法人',
      'page_builder.exit_fullscreen': '全画面表示を終了',
      'link_editor.add_block': 'ブロックを追加',
      'design_editor.templates': 'テンプレート',
      'design_editor.profile': 'プロフィール',
      'design_editor.appearance': '外観',
      'design_editor.typography': 'タイポグラフィ',
      'design_editor.buttons': 'ボタン',
      'design_editor.background': '背景',
      'design_editor.enterprise_layout': '法人レイアウト',
      'design_editor.more_themes': '他のテーマ...',
      'ai_assistant.title': 'AIアシスタント',
      'ai_assistant.subtitle': 'AIの動作と知識を設定します。',
      'ai_assistant.test_title': 'アシスタントをテスト',
      'ai_assistant.save_changes': '変更を保存',
      'ai_assistant.save_success': 'AIアシスタントの設定が正常に保存されました！',
      'analytics.page.title': 'ページ分析',
      'analytics.interactions.title': '顧客インタラクション分析',
      'analytics.crm.title': '訪問者CRM',
      'aigc.creator.title': 'ビデオクリエーター',
      'aigc.news.title': 'ニュースクリエーター',
      'aigc.scheduler.title': 'コンテンツスケジューラ',
      'auth.welcome_back': 'おかえりなさい',
      'auth.create_account': 'アカウントを作成',
      'auth.signin_prompt': 'あなたのページに進むためにサインインしてください。',
      'auth.signup_prompt': '数秒であなたのプレゼンスを構築し始めましょう。',
      'auth.email': 'メールアドレス',
      'auth.password': 'パスワード',
      'auth.processing': '処理中...',
      'auth.signin': 'サインイン',
      'auth.signup': 'サインアップ',
      'auth.no_account': 'アカウントをお持ちでないですか？',
      'auth.has_account': 'すでにアカウントをお持ちですか？',
      'modal.share.title': 'ページを共有',
      'modal.share.pc_version': 'PC版',
      'modal.share.mobile_version': 'モバイル版',
      'modal.share.copy': 'コピー',
      'modal.share.copied': 'コピーしました！',
      'modal.pages.title': 'ページを選択',
      'modal.pages.create_new': '新しいページを作成',
    }
  },
  zh: {
    translation: {
      'add': '添加',
      'cancel': '取消',
      'save': '保存',
      'delete': '删除',
      'update': '更新',
      'edit': '编辑',
      'name': '名称',
      'pro': '专业版',
      'all': '全部',
      'for': '为',
      'no_items_found': '未找到任何项目。',
      'scheduled': '已安排',
      'unscheduled': '未安排',
      'open': '待处理',
      'resolved': '已解决',
      'nav.page': '页面',
      'nav.page.link': '链接',
      'nav.page.media': '媒体',
      'nav.page.design': '设计',
      'nav.ai_assistant': 'AI 助手',
      'nav.ai_assistant.persona': '角色',
      'nav.ai_assistant.knowledge': '知识库',
      'nav.ai_assistant.sensitivity': '敏感度',
      'nav.analytics': '分析',
      'nav.analytics.page': '页面',
      'nav.analytics.interactions': '互动',
      'nav.analytics.crm': '客户关系管理',
      'nav.seo': 'SEO',
      'nav.seo.short_links': '短链接',
      'nav.seo.hosting': '企业托管',
      'nav.seo.services': 'SEO 服务',
      'nav.aigc': 'AIGC',
      'nav.aigc.creator': '创作器',
      'nav.aigc.news': '新闻',
      'nav.aigc.scheduler': '调度器',
      'nav.showcase': '展示',
      'nav.showcase.personal': '个人',
      'nav.showcase.enterprise': '企业',
      'sidebar.select_page': '选择页面',
      'sidebar.logout': '登出',
      'sidebar.light_theme': '浅色',
      'sidebar.dark_theme': '深色',
      'sidebar.language': '语言',
      'app.welcome': '欢迎！',
      'app.no_pages_prompt': '您还没有任何页面。让我们来创建您的第一个页面吧。',
      'app.create_first_page': '创建您的第一个页面',
      'app.import_success': '“{{name}}” 已添加到您的页面中！您现在可以对其进行编辑。',
      'app.videos_generated_success': '{{count}} 个视频生成成功！您可以在内容调度器的视频库中找到它们。',
      'app.form_submission_success': '收到新的表单提交！您可以在 CRM 中查看。',
      'app.no_page_selected': '未选择页面',
      'page_builder.title': '我的页面',
      'page_builder.url_prompt': '您的公开 URL:',
      'page_builder.share': '分享',
      'page_builder.personal_mode': '个人',
      'page_builder.enterprise_mode': '企业',
      'page_builder.exit_fullscreen': '退出全屏',
      'link_editor.add_block': '添加区块',
      'design_editor.templates': '模板',
      'design_editor.profile': '个人资料',
      'design_editor.appearance': '外观',
      'design_editor.typography': '字体',
      'design_editor.buttons': '按钮',
      'design_editor.background': '背景',
      'design_editor.enterprise_layout': '企业布局',
      'design_editor.more_themes': '更多主题...',
      'ai_assistant.title': 'AI 助手',
      'ai_assistant.subtitle': '配置您的 AI 的行为和知识。',
      'ai_assistant.test_title': '测试您的助手',
      'ai_assistant.save_changes': '保存更改',
      'ai_assistant.save_success': 'AI 助手设置已成功保存！',
      'analytics.page.title': '页面分析',
      'analytics.interactions.title': '客户互动分析',
      'analytics.crm.title': '访客 CRM',
      'aigc.creator.title': '视频创作器',
      'aigc.news.title': '新闻创作器',
      'aigc.scheduler.title': '内容调度器',
      'auth.welcome_back': '欢迎回来',
      'auth.create_account': '创建账户',
      'auth.signin_prompt': '登录以继续访问您的页面。',
      'auth.signup_prompt': '在几秒钟内开始建立您的在线形象。',
      'auth.email': '电子邮箱地址',
      'auth.password': '密码',
      'auth.processing': '处理中...',
      'auth.signin': '登录',
      'auth.signup': '注册',
      'auth.no_account': '还没有账户？',
      'auth.has_account': '已经有账户了？',
      'modal.share.title': '分享您的页面',
      'modal.share.pc_version': '桌面版',
      'modal.share.mobile_version': '移动版',
      'modal.share.copy': '复制',
      'modal.share.copied': '已复制！',
      'modal.pages.title': '选择一个页面',
      'modal.pages.create_new': '创建新页面',
    }
  },
  ko: {
    translation: {
      'add': '추가',
      'cancel': '취소',
      'save': '저장',
      'delete': '삭제',
      'update': '업데이트',
      'edit': '편집',
      'name': '이름',
      'pro': '프로',
      'all': '전체',
      'for': '대상',
      'no_items_found': '항목을 찾을 수 없습니다.',
      'scheduled': '예약됨',
      'unscheduled': '예약 안됨',
      'open': '진행 중',
      'resolved': '해결됨',
      'nav.page': '페이지',
      'nav.page.link': '링크',
      'nav.page.media': '미디어',
      'nav.page.design': '디자인',
      'nav.ai_assistant': 'AI 어시스턴트',
      'nav.ai_assistant.persona': '페르소나',
      'nav.ai_assistant.knowledge': '지식',
      'nav.ai_assistant.sensitivity': '민감도',
      'nav.analytics': '분석',
      'nav.analytics.page': '페이지',
      'nav.analytics.interactions': '상호작용',
      'nav.analytics.crm': 'CRM',
      'nav.seo': 'SEO',
      'nav.seo.short_links': '단축 링크',
      'nav.seo.hosting': '기업 호스팅',
      'nav.seo.services': 'SEO 서비스',
      'nav.aigc': 'AIGC',
      'nav.aigc.creator': '크리에이터',
      'nav.aigc.news': '뉴스',
      'nav.aigc.scheduler': '스케줄러',
      'nav.showcase': '쇼케이스',
      'nav.showcase.personal': '개인',
      'nav.showcase.enterprise': '기업',
      'sidebar.select_page': '페이지 선택',
      'sidebar.logout': '로그아웃',
      'sidebar.light_theme': '라이트',
      'sidebar.dark_theme': '다크',
      'sidebar.language': '언어',
      'app.welcome': '환영합니다!',
      'app.no_pages_prompt': '아직 페이지가 없습니다. 첫 페이지를 만들어 보세요.',
      'app.create_first_page': '첫 페이지 만들기',
      'app.import_success': "'{{name}}'이(가) 페이지에 추가되었습니다! 이제 편집할 수 있습니다.",
      'app.videos_generated_success': '{{count}}개의 동영상이 성공적으로 생성되었습니다! 콘텐츠 스케줄러의 비디오 라이브러리에서 찾을 수 있습니다.',
      'app.form_submission_success': '새로운 양식 제출을 받았습니다! CRM에서 볼 수 있습니다.',
      'app.no_page_selected': '선택된 페이지 없음',
      'page_builder.title': '내 페이지',
      'page_builder.url_prompt': '공개 URL:',
      'page_builder.share': '공유',
      'page_builder.personal_mode': '개인',
      'page_builder.enterprise_mode': '기업',
      'page_builder.exit_fullscreen': '전체 화면 종료',
      'link_editor.add_block': '블록 추가',
      'design_editor.templates': '템플릿',
      'design_editor.profile': '프로필',
      'design_editor.appearance': '모양',
      'design_editor.typography': '타이포그래피',
      'design_editor.buttons': '버튼',
      'design_editor.background': '배경',
      'design_editor.enterprise_layout': '기업 레이아웃',
      'design_editor.more_themes': '더 많은 테마...',
      'ai_assistant.title': 'AI 어시스턴트',
      'ai_assistant.subtitle': 'AI의 행동과 지식을 구성하세요.',
      'ai_assistant.test_title': '어시스턴트 테스트',
      'ai_assistant.save_changes': '변경 사항 저장',
      'ai_assistant.save_success': 'AI 어시스턴트 설정이 성공적으로 저장되었습니다!',
      'analytics.page.title': '페이지 분석',
      'analytics.interactions.title': '고객 상호작용 분석',
      'analytics.crm.title': '방문자 CRM',
      'aigc.creator.title': '비디오 크리에이터',
      'aigc.news.title': '뉴스 크리에이터',
      'aigc.scheduler.title': '콘텐츠 스케줄러',
      'auth.welcome_back': '다시 오신 것을 환영합니다',
      'auth.create_account': '계정 만들기',
      'auth.signin_prompt': '페이지를 계속 보려면 로그인하세요.',
      'auth.signup_prompt': '몇 초 만에 당신의 존재감을 구축하세요.',
      'auth.email': '이메일 주소',
      'auth.password': '비밀번호',
      'auth.processing': '처리 중...',
      'auth.signin': '로그인',
      'auth.signup': '가입하기',
      'auth.no_account': '계정이 없으신가요?',
      'auth.has_account': '이미 계정이 있으신가요?',
      'modal.share.title': '페이지 공유',
      'modal.share.pc_version': 'PC 버전',
      'modal.share.mobile_version': '모바일 버전',
      'modal.share.copy': '복사',
      'modal.share.copied': '복사됨!',
      'modal.pages.title': '페이지 선택',
      'modal.pages.create_new': '새 페이지 만들기',
    }
  },
};

export const dateLocales: Record<Language, Locale> = {
  en: enUS,
  ja: ja,
  zh: zhCN,
  ko: ko,
};

type TranslationContextType = {
  language: Language;
  setLanguage: (language: Language) => void;
  t: (key: string, options?: { [key: string]: string | number }) => string;
  dateLocale: Locale;
};

const LanguageContext = React.createContext<TranslationContextType | undefined>(undefined);

export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
  const [language, setLanguageState] = React.useState<Language>(() => {
    const savedLang = localStorage.getItem('greenpage_lang');
    return (savedLang && Object.keys(resources).includes(savedLang)) ? savedLang as Language : 'en';
  });

  const setLanguage = (lang: Language) => {
    localStorage.setItem('greenpage_lang', lang);
    setLanguageState(lang);
  };
  
  const t = (key: string, options?: { [key: string]: string | number }) => {
    const langResources = resources[language] || resources.en;
    let text = (langResources.translation as any)[key] || key;
    if (options) {
      Object.keys(options).forEach(k => {
        text = text.replace(new RegExp(`\\{\\{${k}\\}\\}`, 'g'), String(options[k]));
      });
    }
    return text;
  };

  const dateLocale = dateLocales[language] || enUS;

  return (
    <LanguageContext.Provider value={{ language, setLanguage, t, dateLocale }}>
      {children}
    </LanguageContext.Provider>
  );
};

export const useTranslation = () => {
  const context = React.useContext(LanguageContext);
  if (context === undefined) {
    throw new Error('useTranslation must be used within a LanguageProvider');
  }
  return context;
};
