diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index e2be9b9..669dd55 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -34,34 +34,34 @@ class SettingsForm extends ConfigFormBase { $form['responsive_menu'] = array( '#type' => 'fieldset', - '#title' => t('Responsive menu'), + '#title' => $this->t('Responsive menu'), ); $form['responsive_menu']['horizontal_menu'] = array( '#type' => 'select', - '#title' => t('Choose which Drupal menu will be rendered as a horizontal menu at the breakpoint width'), + '#title' => $this->t('Choose which Drupal menu will be rendered as a horizontal menu at the breakpoint width'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('horizontal_menu'), '#options' => $this->getMenuOptions(), ); $form['responsive_menu']['horizontal_depth'] = array( '#type' => 'select', - '#title' => t('A maximum menu depth that the horizontal menu should display'), + '#title' => $this->t('A maximum menu depth that the horizontal menu should display'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('horizontal_depth'), '#options' => array_combine(array(1, 2, 3, 4, 5, 6, 7, 8, 9), array(1, 2, 3, 4, 5, 6, 7, 8, 9)), - '#description' => t('The mobile menu will always allow all depths to be navigated to. This only controls what menu depth you want to display on the horizontal menu. It can be useful if you want a single row of items because you are handling secondary level and lower in a separate block.'), + '#description' => $this->t('The mobile menu will always allow all depths to be navigated to. This only controls what menu depth you want to display on the horizontal menu. It can be useful if you want a single row of items because you are handling secondary level and lower in a separate block.'), ); $form['responsive_menu']['off_canvas'] = array( '#type' => 'fieldset', - '#title' => t('Off canvas'), + '#title' => $this->t('Off canvas'), ); $form['responsive_menu']['off_canvas']['off_canvas_menus'] = array( '#type' => 'textfield', - '#title' => t('Enter the name(s) of Drupal menus to be rendered in an off-canvas menu'), - '#description' => t('Enter the names of menus in a comma delimited format. If more than one menu is entered the menu items will be merged together. This is useful if you have a main menu and a utility menu that display separately at wider screen sizes but should be merged into a single menu at smaller screen sizes. Note that the menus will be merged in the entered order.'), + '#title' => $this->t('Enter the name(s) of Drupal menus to be rendered in an off-canvas menu'), + '#description' => $this->t('Enter the names of menus in a comma delimited format. If more than one menu is entered the menu items will be merged together. This is useful if you have a main menu and a utility menu that display separately at wider screen sizes but should be merged into a single menu at smaller screen sizes. Note that the menus will be merged in the entered order.'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('off_canvas_menus'), ); $form['responsive_menu']['horizontal_wrapping_element'] = array( '#type' => 'select', - '#title' => t('Choose the HTML element to wrap the menu block in'), + '#title' => $this->t('Choose the HTML element to wrap the menu block in'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('horizontal_wrapping_element'), '#options' => array( 'nav' => 'nav', @@ -70,15 +70,15 @@ class SettingsForm extends ConfigFormBase { ); $form['responsive_menu']['use_breakpoint'] = array( '#type' => 'checkbox', - '#title' => t('Use a breakpoint'), - '#description' => t("Unchecking this will disable the breakpoint and your mobile menu icon block will always display (assuming you have placed it on the page). This can be useful if you always want to display the mobile menu icon and don't want a horizontal menu at all, or if you want to control the visibility and breakpoints in your theme's css. Note that the horizontal menu block, if placed, will only be visible if this is checked."), + '#title' => $this->t('Use a breakpoint'), + '#description' => $this->t("Unchecking this will disable the breakpoint and your mobile menu icon block will always display (assuming you have placed it on the page). This can be useful if you always want to display the mobile menu icon and don't want a horizontal menu at all, or if you want to control the visibility and breakpoints in your theme's css. Note that the horizontal menu block, if placed, will only be visible if this is checked."), '#default_value' => \Drupal::config('responsive_menu.settings')->get('use_breakpoint'), ); // Breakpoints. $queries = responsive_menu_get_breakpoints(); $form['responsive_menu']['horizontal_breakpoint'] = array( '#type' => 'select', - '#title' => t('Choose a breakpoint to trigger the desktop format menu at'), + '#title' => $this->t('Choose a breakpoint to trigger the desktop format menu at'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('horizontal_breakpoint'), '#options' => $queries, '#states' => array( @@ -89,7 +89,7 @@ class SettingsForm extends ConfigFormBase { ); if (empty($queries)) { $form['responsive_menu']['horizontal_breakpoint']['#disabled'] = TRUE; - $form['responsive_menu']['horizontal_breakpoint']['#description'] = '
' . t('You must configure at least one @breakpoint to see any options. Until then the select widget above is disabled.', array( + $form['responsive_menu']['horizontal_breakpoint']['#description'] = '
' . $this->t('You must configure at least one @breakpoint to see any options. Until then the select widget above is disabled.', array( '@breakpoint' => \Drupal::l('breakpoint', Url::fromUri('https://www.drupal.org/documentation/modules/breakpoint')), )) . '
'; @@ -97,48 +97,48 @@ class SettingsForm extends ConfigFormBase { // Whether to load the base css. $form['responsive_menu']['css'] = array( '#type' => 'checkbox', - '#title' => t("Load the responsive_menu module's css"), - '#description' => t('It might be that you want to override all of the css that comes with the responsive_menu module in which case you can disable the loading of the css here and include it instead in your theme.'), + '#title' => $this->t("Load the responsive_menu module's css"), + '#description' => $this->t('It might be that you want to override all of the css that comes with the responsive_menu module in which case you can disable the loading of the css here and include it instead in your theme.'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('include_css'), ); // Left or right positioned panel. $form['responsive_menu']['position'] = array( '#type' => 'select', '#options' => array( - 'left' => t('Left'), - 'right' => t('Right'), + 'left' => $this->t('Left'), + 'right' => $this->t('Right'), ), - '#title' => t('Which side the mobile menu panel should slide out from'), + '#title' => $this->t('Which side the mobile menu panel should slide out from'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('off_canvas_position'), ); // The theme of the slideout panel. $form['responsive_menu']['theme'] = array( '#type' => 'select', '#options' => array( - 'theme-light' => t('Light'), - 'theme-dark' => t('Dark'), - 'theme-black' => t('Black'), - 'theme-white' => t('White'), + 'theme-light' => $this->t('Light'), + 'theme-dark' => $this->t('Dark'), + 'theme-black' => $this->t('Black'), + 'theme-white' => $this->t('White'), ), - '#title' => t('Which mmenu theme to use'), + '#title' => $this->t('Which mmenu theme to use'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('off_canvas_theme'), ); // A javascript enhancements fieldset. $form['responsive_menu']['js'] = array( '#type' => 'fieldset', - '#title' => t('Javascript enhancements'), + '#title' => $this->t('Javascript enhancements'), ); $form['responsive_menu']['js']['superfish'] = array( '#type' => 'checkbox', - '#title' => t('Apply Superfish to the horizontal menu'), - '#description' => t('Adds the @superfish library functionality to the horizontal menu. This enhances the menu with better support for hovering and support for mobiles.', array( + '#title' => $this->t('Apply Superfish to the horizontal menu'), + '#description' => $this->t('Adds the @superfish library functionality to the horizontal menu. This enhances the menu with better support for hovering and support for mobiles.', array( '@superfish' => \Drupal::l('Superfish', Url::fromUri('https://github.com/joeldbirch/superfish')), )), '#default_value' => \Drupal::config('responsive_menu.settings')->get('horizontal_superfish'), ); $form['responsive_menu']['js']['superfish_options'] = array( '#type' => 'fieldset', - '#title' => t('Superfish options'), + '#title' => $this->t('Superfish options'), '#states' => array( 'visible' => array( ':input[name="superfish"]' => array('checked' => TRUE), @@ -147,26 +147,26 @@ class SettingsForm extends ConfigFormBase { ); $form['responsive_menu']['js']['superfish_options']['superfish_delay'] = array( '#type' => 'textfield', - '#title' => t('Delay'), - '#description' => t('The amount of time in milliseconds a menu will remain after the mouse leaves it.'), + '#title' => $this->t('Delay'), + '#description' => $this->t('The amount of time in milliseconds a menu will remain after the mouse leaves it.'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('horizontal_superfish_delay'), ); $form['responsive_menu']['js']['superfish_options']['superfish_speed'] = array( '#type' => 'textfield', - '#title' => t('Speed'), - '#description' => t('The amount of time in milliseconds it takes for a menu to reach 100% opacity when it opens.'), + '#title' => $this->t('Speed'), + '#description' => $this->t('The amount of time in milliseconds it takes for a menu to reach 100% opacity when it opens.'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('horizontal_superfish_speed'), ); $form['responsive_menu']['js']['superfish_options']['superfish_speed_out'] = array( '#type' => 'textfield', - '#title' => t('Speed out'), - '#description' => t('The amount of time in milliseconds it takes for a menu to reach 0% opacity when it closes.'), + '#title' => $this->t('Speed out'), + '#description' => $this->t('The amount of time in milliseconds it takes for a menu to reach 0% opacity when it closes.'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('horizontal_superfish_speed_out'), ); $form['responsive_menu']['js']['superfish_options']['superfish_hoverintent'] = array( '#type' => 'checkbox', - '#title' => t('Use hoverintent'), - '#description' => t("Whether to use the @hoverintent plugin with superfish. This library is included in the superfish download and doesn't require separate installation.", array( + '#title' => $this->t('Use hoverintent'), + '#description' => $this->t("Whether to use the @hoverintent plugin with superfish. This library is included in the superfish download and doesn't require separate installation.", array( '@hoverintent' => \Drupal::l('hoverIntent', Url::fromUri('http://cherne.net/brian/resources/jquery.hoverIntent.html')), )), '#default_value' => \Drupal::config('responsive_menu.settings')->get('horizontal_superfish_hoverintent'), @@ -174,15 +174,15 @@ class SettingsForm extends ConfigFormBase { // Whether the optional superfish library is to be used. if (!file_exists(DRUPAL_ROOT . '/libraries/superfish/dist/js/superfish.min.js')) { $form['responsive_menu']['js']['superfish']['#disabled'] = TRUE; - $form['responsive_menu']['js']['superfish']['#description'] .= '
' . t('You need to download the @superfish library and place it in a /libraries directory. Until then the superfish option is disabled.', array( + $form['responsive_menu']['js']['superfish']['#description'] .= '
' . $this->t('You need to download the @superfish library and place it in a /libraries directory. Until then the superfish option is disabled.', array( '@superfish' => \Drupal::l('superfish', Url::fromUri('https://github.com/joeldbirch/superfish/archive/master.zip')), )) . ''; } // The hammer js library is optional. $form['responsive_menu']['js']['hammerjs'] = array( '#type' => 'checkbox', - '#title' => t('Add swipe gestures'), - '#description' => t('Adds the hammer.js library to enhance the mobile experience with swipe gestures to open or close the menu.'), + '#title' => $this->t('Add swipe gestures'), + '#description' => $this->t('Adds the hammer.js library to enhance the mobile experience with swipe gestures to open or close the menu.'), '#default_value' => \Drupal::config('responsive_menu.settings')->get('hammerjs'), ); // If the libraries module isn't installed or if the hammer.min.js @@ -190,7 +190,7 @@ class SettingsForm extends ConfigFormBase { // and display an appropriate message. if (!file_exists(DRUPAL_ROOT . '/libraries/hammerjs/hammer.min.js')) { $form['responsive_menu']['js']['hammerjs']['#disabled'] = TRUE; - $form['responsive_menu']['js']['hammerjs']['#description'] .= '
' . t('You must download the @hammer file and place it in a hammerjs directory in /libraries. Until then the hammerjs option is disabled.', array( + $form['responsive_menu']['js']['hammerjs']['#description'] .= '
' . $this->t('You must download the @hammer file and place it in a hammerjs directory in /libraries. Until then the hammerjs option is disabled.', array( '@hammer' => \Drupal::l('hammer.min.js', Url::fromUri('http://hammerjs.github.io/dist/hammer.min.js')), )) . ''; }