Skip to content

Latest commit

 

History

History
322 lines (256 loc) · 8.04 KB

File metadata and controls

322 lines (256 loc) · 8.04 KB

紧急修复 v1.4.2

问题描述

在 v1.4.1 中,虽然修复了法语页面内容为空的问题,但仍然存在以下问题:

  1. Downloads 页面没有自动创建中文和法语版本
  2. Investor Relations 页面没有自动创建中文和法语版本
  3. 导致中文和法语菜单缺少对应的菜单项

根本原因

inc/multilingual-content.phprena_translate_pages() 函数中,$pages_to_translate 数组的键使用了错误的语言:

错误的配置(v1.4.1)

$pages_to_translate = [
    'Home' => [...],
    'Research' => [...],
    'Téléchargements' => [      // ❌ 错误:应该使用英文 'Downloads'
        'zh' => '下载',
        'fr' => 'Téléchargements',
    ],
    // ...
    'Relations investisseurs' => [ // ❌ 错误:应该使用英文 'Investor Relations'
        'zh' => '投资者关系',
        'fr' => 'Relations investisseurs',
    ],
    // ...
    'Forgot Password' => [
        'zh' => '忘记密码',
        'fr' => 'Passwort vergessen',  // ❌ 错误:这是德语,应该是法语
    ],
    'My Profile' => [
        'zh' => '我的资料',
        'fr' => 'Mein Profil',          // ❌ 错误:这是德语,应该是法语
    ],
];

问题分析

get_page_by_title($en_title) 函数根据英文页面标题来查找页面。因此:

  • 'Home' → 能找到英文页面 "Home"
  • 'Research' → 能找到英文页面 "Research"
  • 'Téléchargements' → 找不到(因为英文页面标题是 "Downloads")
  • 'Relations investisseurs' → 找不到(因为英文页面标题是 "Investor Relations")

修复内容

修改文件

inc/multilingual-content.php

修复的配置

$pages_to_translate = [
    'Home' => [
        'zh' => '首页',
        'fr' => 'Accueil',
    ],
    'Research' => [
        'zh' => '研究',
        'fr' => 'Recherche',
    ],
    'Downloads' => [              // ✅ 修复:使用英文标题
        'zh' => '下载',
        'fr' => 'Téléchargements',
    ],
    'Contact Information' => [
        'zh' => '联系信息',
        'fr' => 'Informations de contact',
    ],
    'Risk Warning' => [
        'zh' => '风险警告',
        'fr' => 'Avertissement sur les risques',
    ],
    'Privacy Policy' => [
        'zh' => '隐私政策',
        'fr' => 'Politique de confidentialité',
    ],
    'Investor Relations' => [     // ✅ 修复:使用英文标题
        'zh' => '投资者关系',
        'fr' => 'Relations investisseurs',
    ],
    'Member' => [
        'zh' => '会员',
        'fr' => 'Membre',
    ],
    'Register' => [
        'zh' => '注册',
        'fr' => 'Inscription',
    ],
    'Forgot Password' => [
        'zh' => '忘记密码',
        'fr' => 'Mot de passe oublié',  // ✅ 修复:改为法语
    ],
    'My Profile' => [
        'zh' => '我的资料',
        'fr' => 'Mon profil',           // ✅ 修复:改为法语
    ],
];

修复统计

页面标题修复(2 处)

  • 'Téléchargements''Downloads'
  • 'Relations investisseurs''Investor Relations'

法语翻译修复(2 处)

  • 'Passwort vergessen''Mot de passe oublié'(德语 → 法语)
  • 'Mein Profil''Mon profil'(德语 → 法语)

总计

  • 4 处修复

测试步骤

1. 清空数据并重新激活主题

重要:必须清空数据并重新激活!

# 在 WordPress 后台
1. 删除所有页面
2. 删除所有菜单
3. 停用主题
4. 上传 v1.4.2
5. 激活主题

2. 验证页面创建

检查后台 → 页面

English 页面

  • Home
  • Research
  • Downloads ✅
  • Contact Information
  • Risk Warning
  • Privacy Policy
  • Investor Relations ✅
  • Member
  • Register
  • Forgot Password
  • My Profile

简体中文页面

  • 首页
  • 研究
  • 下载 ✅(新增)
  • 联系信息
  • 风险警告
  • 隐私政策
  • 投资者关系 ✅(新增)
  • 会员
  • 注册
  • 忘记密码
  • 我的资料

Français 页面

  • Accueil
  • Recherche
  • Téléchargements ✅(新增)
  • Informations de contact
  • Avertissement sur les risques
  • Politique de confidentialité
  • Relations investisseurs ✅(新增)
  • Membre
  • Inscription
  • Mot de passe oublié ✅(修复翻译)
  • Mon profil ✅(修复翻译)

3. 验证菜单

检查后台 → 外观 → 菜单

Primary Navigation - English

  • Home
  • Research
  • Downloads ✅
  • Member

Primary Navigation - 简体中文

  • 首页
  • 研究
  • 下载 ✅(新增)
  • 会员

Primary Navigation - Français

  • Accueil
  • Recherche
  • Téléchargements ✅(新增)
  • Membre

Footer Navigation - English

  • Privacy Policy
  • Risk Warning
  • Contact Information
  • Investor Relations ✅

Footer Navigation - 简体中文

  • 隐私政策
  • 风险警告
  • 联系我们
  • 投资者关系 ✅(新增)

Footer Navigation - Français

  • Politique de confidentialité
  • Avertissement sur les risques
  • Informations de contact
  • Relations investisseurs ✅(新增)

4. 验证前台显示

英语页面 (/)

  • 顶部菜单:Home, Research, Downloads ✅, Member
  • 页脚菜单:Privacy Policy, Risk Warning, Contact Information, Investor Relations ✅
  • Downloads 页面有完整内容
  • Investor Relations 页面有完整内容

中文页面 (/zh/)

  • 顶部菜单:首页, 研究, 下载 ✅, 会员
  • 页脚菜单:隐私政策, 风险警告, 联系我们, 投资者关系 ✅
  • 下载页面有完整内容
  • 投资者关系页面有完整内容

法语页面 (/fr/)

  • 顶部菜单:Accueil, Recherche, Téléchargements ✅, Membre
  • 页脚菜单:Politique de confidentialité, Avertissement sur les risques, Informations de contact, Relations investisseurs ✅
  • Téléchargements 页面有完整内容
  • Relations investisseurs 页面有完整内容

影响范围

受影响的功能

  • ✅ Downloads 页面翻译(中文、法语)
  • ✅ Investor Relations 页面翻译(中文、法语)
  • ✅ Forgot Password 页面法语翻译
  • ✅ My Profile 页面法语翻译
  • ✅ 主导航菜单(中文、法语)
  • ✅ 页脚菜单(中文、法语)

不受影响的功能

  • ✅ 英语内容(完全正常)
  • ✅ 其他页面翻译(完全正常)
  • ✅ 翻译文件(fr_FR.po/mo)
  • ✅ Elementor 预设数据

版本信息

  • 版本号:v1.4.1 → v1.4.2
  • 发布日期:2025-10-26
  • 修复类型:紧急修复(Hotfix)
  • 严重程度:中(导致部分页面和菜单项缺失)

升级说明

从 v1.4.1 升级到 v1.4.2

重要:必须清空数据并重新激活主题!

原因:v1.4.1 没有创建 Downloads 和 Investor Relations 的翻译页面,需要重新创建。

步骤

  1. 备份数据库(如果有重要数据)
  2. 删除所有页面
  3. 删除所有菜单
  4. 停用主题
  5. 上传 v1.4.2
  6. 激活主题
  7. 手动绑定菜单(参考 MENU-SETUP-GUIDE.md

问题根源总结

v1.4.0 → v1.4.1

  • 问题$de_* 变量名和 _de() 函数调用未替换
  • 影响:法语页面内容为空
  • 修复:替换所有变量名和函数调用

v1.4.1 → v1.4.2

  • 问题$pages_to_translate 数组键使用了错误的语言
  • 影响:Downloads 和 Investor Relations 页面未翻译
  • 修复:将键改为英文页面标题

经验教训

在德语→法语迁移过程中,需要注意:

  1. ✅ 翻译文件(.po/.mo)
  2. ✅ HTML 文件
  3. ✅ Elementor 预设数据函数
  4. ✅ 变量名($de_*$fr_*
  5. ✅ 函数调用(_de()_fr()
  6. 配置数组的键(必须使用英文)← 本次修复
  7. 翻译值中的德语残留(如 "Passwort vergessen")← 本次修复

版本:v1.4.2
发布日期:2025-10-26
状态:✅ 已修复并验证