首页 > 解决方案 > Wordpress 网站翻译 - 翻译字符串的严重困难

问题描述

我没有丰富的经验,在 wordpress 中翻译门户网站时遇到了很大的困难。尽管进行了所有测试,但有些字符串无法翻译:

  1. 在文件夹中的各种 .po 文件中搜索字符串的所有匹配项后,直接使用 Loco Translate 翻译主题

  2. 在functions.php中强制翻译

    add_filter('gettext', 'translate_text'); 
    add_filter('ngettext', 'translate_text');
    
    function translate_text($translated) { 
      $translated = str_ireplace('mystring', 'mystrintraslated', $translated); 
      return $translated; 
    }
  1. 修改所有出现的源,以查看更改是否影响了站点:
    public function single_dummy_post() {
        bp_theme_compat_reset_post(
            array(
                'ID'             => 0,
                'post_title'     => __( 'mystringtranslated', 'mytheme),
                'post_author'    => 0,
                'post_date'      => 0,
                'post_content'   => '',
                'post_type'      => 'page',
                'post_status'    => 'publish',
                'is_page'        => true,
                'comment_status' => 'closed',
            )
        );
    }

更改后还清除缓存。

无事可做,网站保持不变。我还能尝试做什么?

标签: wordpresstranslation

解决方案


推荐阅读