最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

templates - Language file doesn't work (poeedit)

programmeradmin0浏览0评论

I'm trying to translate a WordPress template. I went to language files, then opened that copy with Poedit and started translating to my language (persian).

After finishing the translation, I changed the WordPress language from the dashboard, but the language didn't change in the template settings panel, it stays on English. Any idea why this happens?

These are the language instructions from functions.php:

load_theme_textdomain( 'apress', get_template_directory() . '/languages' );

I'm trying to translate a WordPress template. I went to language files, then opened that copy with Poedit and started translating to my language (persian).

After finishing the translation, I changed the WordPress language from the dashboard, but the language didn't change in the template settings panel, it stays on English. Any idea why this happens?

These are the language instructions from functions.php:

load_theme_textdomain( 'apress', get_template_directory() . '/languages' );
Share Improve this question edited May 7, 2019 at 7:29 Vishwa 3762 silver badges17 bronze badges asked May 7, 2019 at 7:11 Arash KhademlooArash Khademloo 1 5
  • 1 Where did you keep the mo file? – Nilambar Sharma Commented May 7, 2019 at 7:37
  • the mo file is in language folder – Arash Khademloo Commented May 7, 2019 at 7:56
  • 1. what is the name of your translation file. 2. Do you use load_theme_textdomain in any hook or standalone? – anton Commented May 7, 2019 at 8:13
  • it's use standalone – Arash Khademloo Commented May 7, 2019 at 8:40
  • the name of translation file is fa_IR – Arash Khademloo Commented May 7, 2019 at 8:42
Add a comment  | 

1 Answer 1

Reset to default 0

According to docs, load_theme_textdomain() function should generally be called from within the after_setup_theme action hook.

add_action( 'after_setup_theme', 'my_theme_setup' );

function my_theme_setup(){
    load_theme_textdomain( 'apress', get_template_directory() . '/languages' );
}
发布评论

评论列表(0)

  1. 暂无评论