How to localize this global string?

Discussion in 'PHP' started by dieorfly, Jan 6, 2013.

  1. #1
    Hi,

    I am localizing one wordpress theme. In the admin section of this theme there is an option to choose between 4 color schemes. I would like to localize these color schemes. What I did was

    - I have created a global string in appropriate php file
    $color_options = array('Default','Blue','Green','Red');

    - I have used this string as follow:

    array( "name" => "Color Scheme",
    "id" => $shortname."_color_scheme",
    "type" => "select",
    "std" => "Default",
    "desc" => "",
    "options" => $color_options),

    Is there a way how to localize those 4 color scheme options in $color_options? Every color scheme has its own css (blue.css, red.css and so on). Other web site parts which are ready to localize via CodeStyling Localization plugin use this: $themename

    Obviously I am quite new in PHP things maybe I am doing this completely wrong so I would appreciate any help.

    Thanks
     
    dieorfly, Jan 6, 2013 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    "options" => array("Red", "Green", "Blue")),
     
    EricBruggema, Jan 6, 2013 IP
  3. dieorfly

    dieorfly Active Member

    Messages:
    122
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks Erik, but the thing is I would like to localize words "Red", "Green, "Blue" and if I would just translate the words the functionality will stop working as it is linked to red.css, green.css, blue.css. I tried to rename also the css files, but it did not help that much as there are probably some other references to red, green and blue in the code.

    So I was thinking whether I could use "esc_html__" in this code so I would be able to translate it via gettext translation files (*.po/*.mo). Or maybe a similar code.

    Do you have any idea?

     
    dieorfly, Jan 6, 2013 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Use a switch statement to set the value of the CSS file based both on the language and the color.
     
    Rukbat, Jan 6, 2013 IP