Rolf
Rolf

Reputation: 105

WordPress translate string in array

I have created a WordPress theme options page in which all options/settings are in an array. 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'),    
);

Upvotes: 1

Views: 2373

Answers (1)

Adam Erstelle
Adam Erstelle

Reputation: 2513

Your options array needs to be defined after wordpress has initalized its translation routines. Try putting the declaration in an init action hook.

Upvotes: 4

Related Questions