Skip to content
This repository

Fully translation support #34

Merged
merged 1 commit into from about 2 years ago

2 participants

M.Satrya Devin Price
M.Satrya
  1. Updated the translation support
  2. In functions.php, recommended to use get_template_directory_uri() rather than get_bloginfo('template_directory')
Devin Price
Owner

Thanks. I finally got the plugin version translation ready, so it'll be good to get this one too.

It would probably be better if the textdomain could be a variable so a developer could quickly change it, but I feel like there are some security issues with that. I'm going to read up on it a little more. Do you know anything about doing that?

Devin Price
Owner

Nope, can't use variables: http://markjaquith.wordpress.com/2011/10/06/translating-wordpress-plugins-and-themes-dont-get-clever/

However, since optionsframework is everywhere, might be better to use a string like "optionsframeworktheme" or "optionstextdomain". I merge and update when I have a minute.

M.Satrya

Wow, I don't know about using variable for translation is a bad idea..

Devin Price devinsays merged commit f8eda75 into from
Devin Price
Owner

Cool. This was just updated. Thanks for all your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 22, 2012
M.Satrya satrya fully translation support 8de4fea
This page is out of date. Refresh to see the latest.
14 admin/options-framework.php
@@ -164,7 +164,13 @@ function optionsframework_setdefaults() {
164 164 if ( !function_exists( 'optionsframework_add_page' ) ) {
165 165
166 166 function optionsframework_add_page() {
167   - $of_page = add_theme_page('Theme Options', 'Theme Options', 'edit_theme_options', 'options-framework','optionsframework_page');
  167 + $of_page = add_theme_page(
  168 + __('Theme Options', 'optionsframework'),
  169 + __('Theme Options', 'optionsframework'),
  170 + 'edit_theme_options',
  171 + 'options-framework',
  172 + 'optionsframework_page'
  173 + );
168 174
169 175 // Load the required CSS and javscript
170 176 add_action('admin_enqueue_scripts', 'optionsframework_load_scripts');
@@ -233,8 +239,8 @@ function optionsframework_page() {
233 239 <?php optionsframework_fields(); /* Settings */ ?>
234 240
235 241 <div id="optionsframework-submit">
236   - <input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options' ); ?>" />
237   - <input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!' ) ); ?>' );" />
  242 + <input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options', 'optionsframework' ); ?>" />
  243 + <input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults', 'optionsframework' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!', 'optionsframework' ) ); ?>' );" />
238 244 <div class="clear"></div>
239 245 </div>
240 246 </form>
@@ -363,7 +369,7 @@ function optionsframework_adminbar() {
363 369 $wp_admin_bar->add_menu( array(
364 370 'parent' => 'appearance',
365 371 'id' => 'of_theme_options',
366   - 'title' => __( 'Theme Options' ),
  372 + 'title' => __( 'Theme Options', 'optionsframework' ),
367 373 'href' => admin_url( 'themes.php?page=options-framework' )
368 374 ));
369 375 }
4 admin/options-medialibrary-uploader.php
@@ -23,7 +23,7 @@
23 23 function optionsframework_mlu_init () {
24 24 register_post_type( 'optionsframework', array(
25 25 'labels' => array(
26   - 'name' => __( 'Options Framework Internal Container' ),
  26 + 'name' => __( 'Options Framework Internal Container', 'optionsframework' ),
27 27 ),
28 28 'public' => true,
29 29 'show_ui' => false,
@@ -125,7 +125,7 @@ function optionsframework_medialibrary_uploader( $_id, $_value, $_mode = 'full',
125 125
126 126 if ( $value ) { $class = ' has-file'; }
127 127 $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="'.$name.'" value="' . $value . '" />' . "\n";
128   - $output .= '<input id="upload_' . $id . '" class="upload_button button" type="button" value="' . __( 'Upload' ) . '" rel="' . $int . '" />' . "\n";
  128 + $output .= '<input id="upload_' . $id . '" class="upload_button button" type="button" value="' . __( 'Upload', 'optionsframework' ) . '" rel="' . $int . '" />' . "\n";
129 129
130 130 if ( $_desc != '' ) {
131 131 $output .= '<span class="of_metabox_desc">' . $_desc . '</span>' . "\n";
38 admin/options-sanitize.php
@@ -215,10 +215,10 @@ function of_sanitize_font_face( $value ) {
215 215 */
216 216 function of_recognized_background_repeat() {
217 217 $default = array(
218   - 'no-repeat' => 'No Repeat',
219   - 'repeat-x' => 'Repeat Horizontally',
220   - 'repeat-y' => 'Repeat Vertically',
221   - 'repeat' => 'Repeat All',
  218 + 'no-repeat' => __('No Repeat', 'optionsframework'),
  219 + 'repeat-x' => __('Repeat Horizontally', 'optionsframework'),
  220 + 'repeat-y' => __('Repeat Vertically', 'optionsframework'),
  221 + 'repeat' => __('Repeat All', 'optionsframework')
222 222 );
223 223 return apply_filters( 'of_recognized_background_repeat', $default );
224 224 }
@@ -231,15 +231,15 @@ function of_recognized_background_repeat() {
231 231 */
232 232 function of_recognized_background_position() {
233 233 $default = array(
234   - 'top left' => 'Top Left',
235   - 'top center' => 'Top Center',
236   - 'top right' => 'Top Right',
237   - 'center left' => 'Middle Left',
238   - 'center center' => 'Middle Center',
239   - 'center right' => 'Middle Right',
240   - 'bottom left' => 'Bottom Left',
241   - 'bottom center' => 'Bottom Center',
242   - 'bottom right' => 'Bottom Right'
  234 + 'top left' => __('Top Left', 'optionsframework'),
  235 + 'top center' => __('Top Center', 'optionsframework'),
  236 + 'top right' => __('Top Right', 'optionsframework'),
  237 + 'center left' => __('Middle Left', 'optionsframework'),
  238 + 'center center' => __('Middle Center', 'optionsframework'),
  239 + 'center right' => __('Middle Right', 'optionsframework'),
  240 + 'bottom left' => __('Bottom Left', 'optionsframework'),
  241 + 'bottom center' => __('Bottom Center', 'optionsframework'),
  242 + 'bottom right' => __('Bottom Right', 'optionsframework')
243 243 );
244 244 return apply_filters( 'of_recognized_background_position', $default );
245 245 }
@@ -252,8 +252,8 @@ function of_recognized_background_position() {
252 252 */
253 253 function of_recognized_background_attachment() {
254 254 $default = array(
255   - 'scroll' => 'Scroll Normally',
256   - 'fixed' => 'Fixed in Place'
  255 + 'scroll' => __('Scroll Normally', 'optionsframework'),
  256 + 'fixed' => __('Fixed in Place', 'optionsframework')
257 257 );
258 258 return apply_filters( 'of_recognized_background_attachment', $default );
259 259 }
@@ -327,10 +327,10 @@ function of_recognized_font_faces() {
327 327 */
328 328 function of_recognized_font_styles() {
329 329 $default = array(
330   - 'normal' => 'Normal',
331   - 'italic' => 'Italic',
332   - 'bold' => 'Bold',
333   - 'bold italic' => 'Bold Italic'
  330 + 'normal' => __('Normal', 'optionsframework'),
  331 + 'italic' => __('Italic', 'optionsframework'),
  332 + 'bold' => __('Bold', 'optionsframework'),
  333 + 'bold italic' => __('Bold Italic', 'optionsframework')
334 334 );
335 335 return apply_filters( 'of_recognized_font_styles', $default );
336 336 }
2  functions.php
@@ -8,6 +8,6 @@
8 8 */
9 9
10 10 if ( !function_exists( 'optionsframework_init' ) ) {
11   - define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_bloginfo('template_directory') . '/admin/' );
  11 + define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/admin/' );
12 12 require_once dirname( __FILE__ ) . '/admin/options-framework.php';
13 13 }
206 options.php
@@ -10,7 +10,7 @@ function optionsframework_option_name() {
10 10 // This gets the theme name from the stylesheet (lowercase and without spaces)
11 11 $themename = get_theme_data(STYLESHEETPATH . '/style.css');
12 12 $themename = $themename['Name'];
13   - $themename = preg_replace("/\W/", "", strtolower($themename) );
  13 + $themename = preg_replace('/\W/', '', strtolower($themename) );
14 14
15 15 $optionsframework_settings = get_option('optionsframework');
16 16 $optionsframework_settings['id'] = $themename;
@@ -19,20 +19,20 @@ function optionsframework_option_name() {
19 19
20 20 /**
21 21 * Defines an array of options that will be used to generate the settings page and be saved in the database.
22   - * When creating the "id" fields, make sure to use all lowercase and no spaces.
  22 + * When creating the 'id' fields, make sure to use all lowercase and no spaces.
23 23 *
24 24 */
25 25
26 26 function optionsframework_options() {
27 27
28 28 // Test data
29   - $test_array = array("one" => "One","two" => "Two","three" => "Three","four" => "Four","five" => "Five");
  29 + $test_array = array('one' => __('One', 'optionsframework'), 'two' => __('Two', 'optionsframework'), 'three' => __('Three', 'optionsframework'), 'four' => __('Four', 'optionsframework'), 'five' => __('Five', 'optionsframework'));
30 30
31 31 // Multicheck Array
32   - $multicheck_array = array("one" => "French Toast", "two" => "Pancake", "three" => "Omelette", "four" => "Crepe", "five" => "Waffle");
  32 + $multicheck_array = array('one' => __('French Toast', 'optionsframework'), 'two' => __('Pancake', 'optionsframework'), 'three' => __('Omelette', 'optionsframework'), 'four' => __('Crepe', 'optionsframework'), 'five' => __('Waffle', 'optionsframework'));
33 33
34 34 // Multicheck Defaults
35   - $multicheck_defaults = array("one" => "1","five" => "1");
  35 + $multicheck_defaults = array('one' => '1','five' => '1');
36 36
37 37 // Background Defaults
38 38
@@ -59,127 +59,127 @@ function optionsframework_options() {
59 59
60 60 $options = array();
61 61
62   - $options[] = array( "name" => "Basic Settings",
63   - "type" => "heading");
  62 + $options[] = array( 'name' => __('Basic Settings', 'optionsframework'),
  63 + 'type' => 'heading');
64 64
65   - $options[] = array( "name" => "Input Text Mini",
66   - "desc" => "A mini text input field.",
67   - "id" => "example_text_mini",
68   - "std" => "Default",
69   - "class" => "mini",
70   - "type" => "text");
  65 + $options[] = array( 'name' => __('Input Text Mini', 'optionsframework'),
  66 + 'desc' => __('A mini text input field.', 'optionsframework'),
  67 + 'id' => 'example_text_mini',
  68 + 'std' => 'Default',
  69 + 'class' => 'mini',
  70 + 'type' => 'text');
71 71
72   - $options[] = array( "name" => "Input Text",
73   - "desc" => "A text input field.",
74   - "id" => "example_text",
75   - "std" => "Default Value",
76   - "type" => "text");
  72 + $options[] = array( 'name' => __('Input Text', 'optionsframework'),
  73 + 'desc' => __('A text input field.', 'optionsframework'),
  74 + 'id' => 'example_text',
  75 + 'std' => 'Default Value',
  76 + 'type' => 'text');
77 77
78   - $options[] = array( "name" => "Textarea",
79   - "desc" => "Textarea description.",
80   - "id" => "example_textarea",
81   - "std" => "Default Text",
82   - "type" => "textarea");
  78 + $options[] = array( 'name' => __('Textarea', 'optionsframework'),
  79 + 'desc' => __('Textarea description.', 'optionsframework'),
  80 + 'id' => 'example_textarea',
  81 + 'std' => 'Default Text',
  82 + 'type' => 'textarea');
83 83
84   - $options[] = array( "name" => "Input Select Small",
85   - "desc" => "Small Select Box.",
86   - "id" => "example_select",
87   - "std" => "three",
88   - "type" => "select",
89   - "class" => "mini", //mini, tiny, small
90   - "options" => $test_array);
  84 + $options[] = array( 'name' => __('Input Select Small', 'optionsframework'),
  85 + 'desc' => __('Small Select Box.', 'optionsframework'),
  86 + 'id' => 'example_select',
  87 + 'std' => 'three',
  88 + 'type' => 'select',
  89 + 'class' => 'mini', //mini, tiny, small
  90 + 'options' => $test_array);
91 91
92   - $options[] = array( "name" => "Input Select Wide",
93   - "desc" => "A wider select box.",
94   - "id" => "example_select_wide",
95   - "std" => "two",
96   - "type" => "select",
97   - "options" => $test_array);
  92 + $options[] = array( 'name' => __('Input Select Wide', 'optionsframework'),
  93 + 'desc' => __('A wider select box.', 'optionsframework'),
  94 + 'id' => 'example_select_wide',
  95 + 'std' => 'two',
  96 + 'type' => 'select',
  97 + 'options' => $test_array);
98 98
99   - $options[] = array( "name" => "Select a Category",
100   - "desc" => "Passed an array of categories with cat_ID and cat_name",
101   - "id" => "example_select_categories",
102   - "type" => "select",
103   - "options" => $options_categories);
  99 + $options[] = array( 'name' => __('Select a Category', 'optionsframework'),
  100 + 'desc' => __('Passed an array of categories with cat_ID and cat_name', 'optionsframework'),
  101 + 'id' => 'example_select_categories',
  102 + 'type' => 'select',
  103 + 'options' => $options_categories);
104 104
105   - $options[] = array( "name" => "Select a Page",
106   - "desc" => "Passed an pages with ID and post_title",
107   - "id" => "example_select_pages",
108   - "type" => "select",
109   - "options" => $options_pages);
  105 + $options[] = array( 'name' => __('Select a Page', 'optionsframework'),
  106 + 'desc' => __('Passed an pages with ID and post_title', 'optionsframework'),
  107 + 'id' => 'example_select_pages',
  108 + 'type' => 'select',
  109 + 'options' => $options_pages);
110 110
111   - $options[] = array( "name" => "Input Radio (one)",
112   - "desc" => "Radio select with default options 'one'.",
113   - "id" => "example_radio",
114   - "std" => "one",
115   - "type" => "radio",
116   - "options" => $test_array);
  111 + $options[] = array( 'name' => __('Input Radio (one)', 'optionsframework'),
  112 + 'desc' => __('Radio select with default options "one".', 'optionsframework'),
  113 + 'id' => 'example_radio',
  114 + 'std' => 'one',
  115 + 'type' => 'radio',
  116 + 'options' => $test_array);
117 117
118   - $options[] = array( "name" => "Example Info",
119   - "desc" => "This is just some example information you can put in the panel.",
120   - "type" => "info");
  118 + $options[] = array( 'name' => __('Example Info', 'optionsframework'),
  119 + 'desc' => __('This is just some example information you can put in the panel.', 'optionsframework'),
  120 + 'type' => 'info');
121 121
122   - $options[] = array( "name" => "Input Checkbox",
123   - "desc" => "Example checkbox, defaults to true.",
124   - "id" => "example_checkbox",
125   - "std" => "1",
126   - "type" => "checkbox");
  122 + $options[] = array( 'name' => __('Input Checkbox', 'optionsframework'),
  123 + 'desc' => __('Example checkbox, defaults to true.', 'optionsframework'),
  124 + 'id' => 'example_checkbox',
  125 + 'std' => '1',
  126 + 'type' => 'checkbox');
127 127
128   - $options[] = array( "name" => "Advanced Settings",
129   - "type" => "heading");
  128 + $options[] = array( 'name' => __('Advanced Settings', 'optionsframework'),
  129 + 'type' => 'heading');
130 130
131   - $options[] = array( "name" => "Check to Show a Hidden Text Input",
132   - "desc" => "Click here and see what happens.",
133   - "id" => "example_showhidden",
134   - "type" => "checkbox");
  131 + $options[] = array( 'name' => __('Check to Show a Hidden Text Input', 'optionsframework'),
  132 + 'desc' => __('Click here and see what happens.', 'optionsframework'),
  133 + 'id' => 'example_showhidden',
  134 + 'type' => 'checkbox');
135 135
136   - $options[] = array( "name" => "Hidden Text Input",
137   - "desc" => "This option is hidden unless activated by a checkbox click.",
138   - "id" => "example_text_hidden",
139   - "std" => "Hello",
140   - "class" => "hidden",
141   - "type" => "text");
  136 + $options[] = array( 'name' => __('Hidden Text Input', 'optionsframework'),
  137 + 'desc' => __('This option is hidden unless activated by a checkbox click.', 'optionsframework'),
  138 + 'id' => 'example_text_hidden',
  139 + 'std' => 'Hello',
  140 + 'class' => 'hidden',
  141 + 'type' => 'text');
142 142
143   - $options[] = array( "name" => "Uploader Test",
144   - "desc" => "This creates a full size uploader that previews the image.",
145   - "id" => "example_uploader",
146   - "type" => "upload");
  143 + $options[] = array( 'name' => __('Uploader Test', 'optionsframework'),
  144 + 'desc' => __('This creates a full size uploader that previews the image.', 'optionsframework'),
  145 + 'id' => 'example_uploader',
  146 + 'type' => 'upload');
147 147
148   - $options[] = array( "name" => "Example Image Selector",
149   - "desc" => "Images for layout.",
150   - "id" => "example_images",
151   - "std" => "2c-l-fixed",
152   - "type" => "images",
153   - "options" => array(
  148 + $options[] = array( 'name' => __('Example Image Selector', 'optionsframework'),
  149 + 'desc' => __('Images for layout.', 'optionsframework'),
  150 + 'id' => 'example_images',
  151 + 'std' => '2c-l-fixed',
  152 + 'type' => 'images',
  153 + 'options' => array(
154 154 '1col-fixed' => $imagepath . '1col.png',
155 155 '2c-l-fixed' => $imagepath . '2cl.png',
156 156 '2c-r-fixed' => $imagepath . '2cr.png')
157 157 );
158 158
159   - $options[] = array( "name" => "Example Background",
160   - "desc" => "Change the background CSS.",
161   - "id" => "example_background",
162   - "std" => $background_defaults,
163   - "type" => "background");
  159 + $options[] = array( 'name' => __('Example Background', 'optionsframework'),
  160 + 'desc' => __('Change the background CSS.', 'optionsframework'),
  161 + 'id' => 'example_background',
  162 + 'std' => $background_defaults,
  163 + 'type' => 'background');
164 164
165   - $options[] = array( "name" => "Multicheck",
166   - "desc" => "Multicheck description.",
167   - "id" => "example_multicheck",
168   - "std" => $multicheck_defaults, // These items get checked by default
169   - "type" => "multicheck",
170   - "options" => $multicheck_array);
  165 + $options[] = array( 'name' => __('Multicheck', 'optionsframework'),
  166 + 'desc' => __('Multicheck description.', 'optionsframework'),
  167 + 'id' => 'example_multicheck',
  168 + 'std' => $multicheck_defaults, // These items get checked by default
  169 + 'type' => 'multicheck',
  170 + 'options' => $multicheck_array);
171 171
172   - $options[] = array( "name" => "Colorpicker",
173   - "desc" => "No color selected by default.",
174   - "id" => "example_colorpicker",
175   - "std" => "",
176   - "type" => "color");
  172 + $options[] = array( 'name' => __('Colorpicker', 'optionsframework'),
  173 + 'desc' => __('No color selected by default.', 'optionsframework'),
  174 + 'id' => 'example_colorpicker',
  175 + 'std' => '',
  176 + 'type' => 'color');
177 177
178   - $options[] = array( "name" => "Typography",
179   - "desc" => "Example typography.",
180   - "id" => "example_typography",
181   - "std" => array('size' => '12px','face' => 'verdana','style' => 'bold italic','color' => '#123456'),
182   - "type" => "typography");
  178 + $options[] = array( 'name' => __('Typography', 'optionsframework'),
  179 + 'desc' => __('Example typography.', 'optionsframework'),
  180 + 'id' => 'example_typography',
  181 + 'std' => array('size' => '12px','face' => 'verdana','style' => 'bold italic','color' => '#123456'),
  182 + 'type' => 'typography');
183 183 return $options;
184 184 }
185 185

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.