doulong4169 2014-08-22 16:18
浏览 45
已采纳

Wordpress主题国际化

I just created my own theme so that I could developpe wordpress site faster. But now I got to make it multi-lang. Here is what I have done until now.

1 : I changed all the text in my theme for : _e("my_text","my_theme") and __("my_text","my_theme")

2 : I generated .po and .mo file with poedit (autogenerated base on key-word and relative path) (named my_theme_fr_FR.po and my_theme_fr_FR.mo)

3 : I made all the traduction I needed and saved the file back

4 : I saved them in my languages folder (in my theme)

5 : I uploaded all my theme to be sure

6 : I verify by ftp that all the files were there

7 : I add a hook in functions.php

function custom_theme_setup() {
    load_theme_textdomain("my_theme", get_template_directory()."/languages/");
} // end custom_theme_setup
add_action('after_setup_theme', 'custom_theme_setup');

In theory my theme is supposed to be ready, but when I tried to execute it (even if I change the WPLANG to fr_FR in wp-config.php) everything is still in english. The admin of wp changed to fr_FR (because I got the .mo) but the text in the front end is still in english...

I followed the tutorial : http://code.tutsplus.com/tutorials/translating-your-theme--wp-25014 but still nothing work...

I'm wondering what I did wrong... Any help would be great. Thank in advance.

  • 写回答

1条回答 默认 最新

  • dougaojue8185 2014-08-22 20:15
    关注

    The languages files (.mo) must be written my_theme-fr_FR.mo not my_theme_fr_FR.mo (notice the '-')

    Plus, they must be in the directory wp-content/languages/themes/ not in wp-content/themes/my_theme/languages/

    Hope this help someone

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大