php - 我想了解主题开发中的翻译功能
问题描述
我很困惑在主题开发中使用翻译功能,特别是使用默认值。
在customizer.php 中
$wp_customize->add_setting('section_title', array( 'default' => 'TESTIMONIALS', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('section_title',array( 'type' => 'text', 'label' => __('Title','theme-food'), 'section' => 'main_section', 'setting' => 'section_title', ));
在这行 'default' => 'TESTIMONIALS' 中,我将使用哪个函数?__ , _e 或任何其他。
当我回显时在 main.php 文件中 ---------- echo esc_html(get_theme_mod('section_title', __('TESTIMONIALS', 'theme-food'));
'TESTIMONIALS' 是 'section_title' 的默认值,那么在默认值之前使用哪个函数是正确的?__ , _e 或任何其他。
解决方案
默认情况下,您不需要使用翻译功能。如果你愿意,你也可以翻译它们。的值default
应该是string
. 您将了解如何在下面提到的这些链接中使字符串可翻译,并且您将对 WordPress 翻译有一个清晰的认识。
的值default
最初并不存储在数据库中。
重要链接:
推荐阅读
- asp.net - 我无法使用非 80 端口的公共 IP 访问 IIS 网站
- python - 如何找到第三个“。” 在一个字符串中,然后改变它后面的字符的值
- c++ - 将标准输出捕获到 zip 并使用 CTRL-C 中断会产生损坏的 zip 文件
- javascript - 来自 v-for 的动态数据使用插槽显示在导入的模态中
- mongoose - 使用 FindByIdAndUpdate 提出请求
- css - 如果其他项目被删除,移动类不会应用于过渡组中的剩余项目
- oop - OOP 观察者模式:从主体外部调用 notifyListener
- angular - 在 2 个日期之间键入脚本过滤
- regex - 如何使用正则表达式复制最后一个字符
- python - fbprohet 的“复活节”/“假期”问题