我想了解主题开发中的翻译功能

I want to know about translation functions in theme development

我对在主题开发中使用翻译功能感到困惑,特别是使用默认值。

  1. 在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 或任何其他。

  2. 在main.php文件中回显-------- echo esc_html(get_theme_mod('section_title', __('TESTIMONIALS', 'theme-food'));

'TESTIMONIALS' 是 'section_title' 的默认值, 那么在默认值之前使用哪个函数是正确的? __ , _e 或任何其他。

默认情况下,您不需要使用翻译功能。如果你愿意,你也可以翻译它们。 default 的值应为 string。您将在下面提到的这些链接中找到如何使字符串可翻译,并且您将对 WordPress 翻译有一个清晰的认识。

default 的值最初并未存储在数据库中。

重要链接:

https://developer.wordpress.org/reference/functions/__/

https://codex.wordpress.org/I18n_for_WordPress_Developers