没有文本域的Wordpress主题的本地化 [英] Localization of a wordpress theme without a textdomain

查看:92
本文介绍了没有文本域的Wordpress主题的本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个没有textdomain(即e(x)而不是e(x,domain))的wordpress主题.我在/themes/My Theme/localization下的文件夹中也有.po和.mo文件(请注意my主题中的空间名称).我想激活fr_FR.我创建了fr_FR.po和.mo并更改了wp-config以添加fr_FR的语言环境.但是,我仍然无法让法语工作.我看到许多站点告诉您在functions.php的顶部添加一个load_theme_textdomain,但是我不知道我的textdomain是什么.任何帮助将不胜感激.

I have a wordpress theme without textdomain (i.e. e(x) and not e(x,domain)). I also have the .po and .mo files in a folder under /themes/My Theme/localization (Notice the space name in the my theme). I would like to activate fr_FR. I created fr_FR.po and .mo and changed the wp-config to add the locale for fr_FR. However, I am still not getting the french to work. I saw many sites telling you to add a load_theme_textdomain at the top of functions.php, but I do not know what would my textdomain be. Any help will be appreciated.

优素福

推荐答案

要使主题本地化工作,您将需要遍历主题并将域添加到每个_e()__()函数调用中.这个:

To get theme localization working, you're going to need to go through your theme and add a domain to every _e() and __() function call. this:

_e('some text');
__('some other text');

必须成为这个:

_e('some text', 'your-domain');
__('some other text', 'your-domain');

接下来,您需要在functions.php文件顶部添加以下代码:

Next you'll need to add this bit of code at the top of your functions.php file:

load_theme_textdomain( 'your-domain', TEMPLATEPATH.'/localization' );

$locale = get_locale();
$locale_file = TEMPLATEPATH."/localization/$locale.php";
if (is_readable($locale_file))
    require_once($locale_file);

您可以在这篇文章中了解更多信息.

这篇关于没有文本域的Wordpress主题的本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆