简体   繁体   English

WordPress在数组中翻译字符串

[英]WordPress translate string in array

I have created a WordPress theme options page in which all options/settings are in an array. 我创建了一个WordPress主题选项页面,其中所有选项/设置都在一个数组中。 Now those strings in the arrays refuse to be translated. 现在,数组中的字符串拒绝翻译。

How can I get it so that the strings in my arrays will be translated? 我怎样才能得到它以便我的数组中的字符串将被翻译?

// create theme options
global $cc_options;
$cc_options = array (

// General settings
    array(  'name'      => __('General', 'cc_language'),
            'slug'      => 'general',
            'status'    => 'active',
            'type'      => 'section'),

    array(  'name'      => __('Setup some general settings for the website.', 'cc_language'),
            'type'      => 'section_desc'),

    array(  'type'      => 'open'),

    array(  'name'      => __('Breadcrumbs', 'cc_language'),
            'type'      => 'section_category'),

    array(  'name'      => __('Enable breadcrumbs', 'cc_language'),
            'desc'      => __('Check to enable breadcrumbs on pages and posts.', 'cc_language'),
            'id'        => 'breadcrumbs',
            'type'      => 'checkbox',
            'std'       => 'true'),

    array(  'type'      => 'close'),    
);

Your options array needs to be defined after wordpress has initalized its translation routines. 在wordpress使其翻译例程初始化之后,需要定义您的选项数组。 Try putting the declaration in an init action hook. 尝试将声明放在init动作钩子中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM