Skip to content
This repository
Browse code

allow setting of language via business general settings page

  • Loading branch information...
commit 128df54f8c1cf879e67e97c33cfb4624685882d6 1 parent ece32bc
Theo Savage tcrsavage authored
30 core_options/tf.options-business-general.php
@@ -24,7 +24,25 @@ function themeforce_business_page() {
24 24 $options_cuisine = array('Afghan', 'African', 'American ( New )', 'American ( Traditional )', 'Argentine', 'Asian Fusion', 'Barbeque', 'Basque', 'Belgian', 'Brasseries', 'Brazilian', 'Breakfast & Brunch', 'British', 'Buffets', 'Burgers', 'Burmese', 'Cafes', 'Cajun/Creole', 'Cambodian', 'Caribbean', 'Cheesesteaks', 'Chicken Wings', 'Chinese', 'Creperies', 'Cuban', 'Delis', 'Diners', 'Ethiopian', 'Fast Food', 'Filipino', 'Fish & Chips', 'Fondue', 'Food Stands', 'French', 'Gastropubs', 'German', 'Gluten-Free', 'Greek', 'Halal', 'Hawaiian', 'Himalayan/Nepalese', 'Hot Dogs', 'Hungarian', 'Indian', 'Indonesian', 'Irish', 'Italian', 'Japanese', 'Korean', 'Kosher', 'Latin American', 'Live/Raw Food', 'Malaysian', 'Mediterranean', 'Mexican', 'Middle Eastern', 'Modern European', 'Mongolian', 'Moroccan', 'Pakistani', 'Persian/Iranian', 'Peruvian', 'Pizza', 'Polish', 'Portuguese', 'Russian', 'Sandwiches', 'Scandinavian', 'Seafood', 'Singaporean', 'Soul Food', 'Soup', 'Southern', 'Spanish', 'Steakhouses', 'Sushi Bars', 'Taiwanese', 'Tapas Bars', 'Tapas/Small Plates', 'Tex-Mex', 'Thai', 'Turkish', 'Ukrainian', 'Vegan', 'Vegetarian', 'Vietnamese');
25 25 $options_pricerange = array ( '$', '$$', '$$$', '$$$$' );
26 26 $options_yesno = array ( __('yes', 'themeforce'), __('no', 'themeforce') );
27   -
  27 +
  28 + //The language code and corresponding string needs to be added here for every new language file added
  29 + $supported_languages = array(
  30 + 'nl_NL' => __( 'Dutch', 'themeforce' ),
  31 + 'de_DE' => __( 'German', 'themeforce' ),
  32 + 'es_ES' => __( 'Spanish', 'themeforce' ),
  33 + 'sv_SE' => __( 'Swedish', 'themeforce' ),
  34 + 'pt_PT' => __( 'Portuguese', 'themeforce' ),
  35 + );
  36 +
  37 + //Work out what to display in terms of language options
  38 + $options_language = array( 'en_US'=> __( 'English', 'themeforce' ) );
  39 +
  40 + $language_files = get_available_languages();
  41 + foreach ( $supported_languages as $key => $language_code ){
  42 + if ( in_array( $key, $language_files ) )
  43 + $options_language[$key] = $language_code;
  44 + }
  45 +
28 46 // Options
29 47
30 48 $options = array (
@@ -106,6 +124,16 @@ function themeforce_business_page() {
106 124 'std' => '',
107 125 'type' => 'text'),
108 126
  127 + array( 'name' => __('Language', 'themeforce'),
  128 + 'desc' => __('Please select your preferred language', 'themeforce'),
  129 + 'id' => 'tf_language',
  130 + 'std' => '',
  131 + 'type' => 'select',
  132 + 'class' => 'tiny', //mini, tiny, small
  133 + 'use_keys' => true,
  134 + 'options' => $options_language ),
  135 +
  136 +
109 137 );
110 138
111 139 $options = apply_filters( 'tf_options_general', $options );
8 core_options/tf.options-master.php
@@ -169,8 +169,8 @@ function tf_display_settings( $options ) {
169 169 <th><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label></th>
170 170 <td>
171 171 <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
172   - <?php foreach ($value['options'] as $option) { ?>
173   - <option <?php selected( $option, get_option( $value['id'] ) ) ?>><?php echo $option; ?></option><?php } ?>
  172 + <?php foreach ($value['options'] as $key => $option) { ?>
  173 + <option value="<?php echo ( $value['use_keys'] ) ? $key : $option; ?>" <?php selected( ( $value['use_keys'] ) ? $key : $option, get_option( $value['id'] ) ) ?>><?php echo $option; ?></option><?php } ?>
174 174 </select>
175 175 <br /><span class="desc"><?php echo $value['desc'] ?></span>
176 176 </td>
@@ -187,8 +187,8 @@ function tf_display_settings( $options ) {
187 187 <th><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label></th>
188 188 <td>
189 189 <select name="<?php echo $value['id']; ?>[]" class="chzn-select" multiple id="<?php echo $value['id']; ?>">
190   - <?php foreach ($value['options'] as $option) { ?>
191   - <option <?php selected( in_array( $option, $current_values ) ) ?>><?php echo $option; ?></option><?php } ?>
  190 + <?php foreach ($value['options'] as $key => $option) { ?>
  191 + <option value="<?php echo ( $value['use_keys'] ) ? $key : $option; ?>" <?php selected( in_array( ( $value['use_keys'] ) ? $key : $option, $current_values ) ) ?>><?php echo $option; ?></option><?php } ?>
192 192 </select>
193 193 <br /><span class="desc"><?php echo $value['desc'] ?></span>
194 194 </td>

0 comments on commit 128df54

Please sign in to comment.
Something went wrong with that request. Please try again.