1

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'),    
);
2
  • Is this code happening inside some function? Or it's like this in functions.php? Commented Oct 3, 2013 at 11:15
  • No, it's like this in my functions.php Commented Oct 4, 2013 at 14:06

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much Adam! That worked! For others, the solution: I wrapped the code in function options_setup() { and add_action('admin_init', 'options_setup');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.