You are here

function gtranslate_admin in Translate Drupal with GTranslate 7

Same name and namespace in other branches
  1. 6 gtranslate.module \gtranslate_admin()
1 string reference to 'gtranslate_admin'
gtranslate_menu in ./gtranslate.module

File

./gtranslate.module, line 447

Code

function gtranslate_admin() {
  $languages = array(
    'en' => 'English',
    'ar' => 'Arabic',
    'bg' => 'Bulgarian',
    'zh-CN' => 'Chinese (Simplified)',
    'zh-TW' => 'Chinese (Traditional)',
    'hr' => 'Croatian',
    'cs' => 'Czech',
    'da' => 'Danish',
    'nl' => 'Dutch',
    'fi' => 'Finnish',
    'fr' => 'French',
    'de' => 'German',
    'el' => 'Greek',
    'hi' => 'Hindi',
    'it' => 'Italian',
    'ja' => 'Japanese',
    'ko' => 'Korean',
    'no' => 'Norwegian',
    'pl' => 'Polish',
    'pt' => 'Portuguese',
    'ro' => 'Romanian',
    'ru' => 'Russian',
    'es' => 'Spanish',
    'sv' => 'Swedish',
    'ca' => 'Catalan',
    'tl' => 'Filipino',
    'iw' => 'Hebrew',
    'id' => 'Indonesian',
    'lv' => 'Latvian',
    'lt' => 'Lithuanian',
    'sr' => 'Serbian',
    'sk' => 'Slovak',
    'sl' => 'Slovenian',
    'uk' => 'Ukrainian',
    'vi' => 'Vietnamese',
    'sq' => 'Albanian',
    'et' => 'Estonian',
    'gl' => 'Galician',
    'hu' => 'Hungarian',
    'mt' => 'Maltese',
    'th' => 'Thai',
    'tr' => 'Turkish',
    'fa' => 'Persian',
    'af' => 'Afrikaans',
    'ms' => 'Malay',
    'sw' => 'Swahili',
    'ga' => 'Irish',
    'cy' => 'Welsh',
    'be' => 'Belarusian',
    'is' => 'Icelandic',
    'mk' => 'Macedonian',
    'yi' => 'Yiddish',
    'hy' => 'Armenian',
    'az' => 'Azerbaijani',
    'eu' => 'Basque',
    'ka' => 'Georgian',
    'ht' => 'Haitian Creole',
    'ur' => 'Urdu',
    'bn' => 'Bengali',
    'bs' => 'Bosnian',
    'ceb' => 'Cebuano',
    'eo' => 'Esperanto',
    'gu' => 'Gujarati',
    'ha' => 'Hausa',
    'hmn' => 'Hmong',
    'ig' => 'Igbo',
    'jw' => 'Javanese',
    'kn' => 'Kannada',
    'km' => 'Khmer',
    'lo' => 'Lao',
    'la' => 'Latin',
    'mi' => 'Maori',
    'mr' => 'Marathi',
    'mn' => 'Mongolian',
    'ne' => 'Nepali',
    'pa' => 'Punjabi',
    'so' => 'Somali',
    'ta' => 'Tamil',
    'te' => 'Telugu',
    'yo' => 'Yoruba',
    'zu' => 'Zulu',
    'my' => 'Myanmar (Burmese)',
    'ny' => 'Chichewa',
    'kk' => 'Kazakh',
    'mg' => 'Malagasy',
    'ml' => 'Malayalam',
    'si' => 'Sinhala',
    'st' => 'Sesotho',
    'su' => 'Sudanese',
    'tg' => 'Tajik',
    'uz' => 'Uzbek',
    'am' => 'Amharic',
    'co' => 'Corsican',
    'haw' => 'Hawaiian',
    'ku' => 'Kurdish (Kurmanji)',
    'ky' => 'Kyrgyz',
    'lb' => 'Luxembourgish',
    'ps' => 'Pashto',
    'sm' => 'Samoan',
    'gd' => 'Scottish Gaelic',
    'sn' => 'Shona',
    'sd' => 'Sindhi',
    'fy' => 'Frisian',
    'xh' => 'Xhosa',
  );

  // Move the default language to the first position and sort
  asort($languages);
  $languages = array_merge(array(
    variable_get('gtranslate_main_lang', 'en') => $languages[variable_get('gtranslate_main_lang', 'en')],
  ), $languages);
  $form['general'] = array(
    '#type' => 'fieldset',
    '#title' => t('General Configuration'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['general']['gtranslate_look'] = array(
    '#type' => 'select',
    '#title' => t('Look'),
    '#default_value' => variable_get('gtranslate_look', 'flags_dropdown'),
    '#size' => 1,
    '#options' => array(
      'flags_dropdown' => 'Flags and dropdown',
      'flags' => 'Flags',
      'dropdown' => 'Dropdown',
      'dropdown_with_flags' => 'Nice dropdown with flags',
    ),
    '#description' => t("Select the look of the module."),
    '#required' => TRUE,
  );
  $form['general']['gtranslate_main_lang'] = array(
    '#type' => 'select',
    '#title' => t('Main Language'),
    '#default_value' => variable_get('gtranslate_main_lang', 'en'),
    '#size' => 1,
    '#options' => $languages,
    '#description' => t("Your sites main language"),
    '#required' => TRUE,
  );
  $form['general']['gtranslate_pro'] = array(
    '#type' => 'checkbox',
    '#title' => t('Sub-directory URL structure'),
    '#default_value' => variable_get('gtranslate_pro', 0),
    '#description' => t('Example: http://example.com/<b>ru</b>/. This feature is available only in paid plans: <a href="https://gtranslate.io/?xyz=1002#pricing" target="_blank">https://gtranslate.io/#pricing</a>'),
  );
  $form['general']['gtranslate_enterprise'] = array(
    '#type' => 'checkbox',
    '#title' => t('Sub-domain URL structure'),
    '#default_value' => variable_get('gtranslate_enterprise', 0),
    '#description' => t('Example: http://<b>es.</b>example.com/. This feature is available only in paid plans: <a href="https://gtranslate.io/?xyz=1002#pricing" target="_blank">https://gtranslate.io/#pricing</a>'),
  );
  $form['general']['gtranslate_flag_size'] = array(
    '#type' => 'radios',
    '#title' => t('Flag Size'),
    '#default_value' => variable_get('gtranslate_flag_size', '16'),
    '#options' => array(
      '16' => '16px',
      '24' => '24px',
      '32' => '32px',
    ),
    '#description' => t("Select the flag size in pixels."),
    '#required' => TRUE,
  );
  $form['general']['gtranslate_new_window'] = array(
    '#type' => 'checkbox',
    '#title' => t('Open translated page in a new window'),
    '#default_value' => variable_get('gtranslate_new_window', 0),
    '#description' => t("The translated page will appear in a new window."),
  );
  $form['general']['gtranslate_analytics'] = array(
    '#type' => 'checkbox',
    '#title' => t('Analytics'),
    '#default_value' => variable_get('gtranslate_analytics', 0),
    '#description' => t("If you have Google Analytics _gaq code on your site you can enable this which will allow you to see translation events in Google Analytics -&gt; Content -&gt; Event Tracking."),
  );
  $form['language'] = array(
    '#type' => 'fieldset',
    '#title' => t('Language Configuration'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $languages_flags = array(
    'en',
    'fr',
    'de',
    'it',
    'pt',
    'ru',
    'es',
  );
  $languages_noflags = array(
    'my' => 'Myanmar (Burmese)',
    'ny' => 'Chichewa',
    'kk' => 'Kazakh',
    'mg' => 'Malagasy',
    'ml' => 'Malayalam',
    'si' => 'Sinhala',
    'st' => 'Sesotho',
    'su' => 'Sudanese',
    'tg' => 'Tajik',
    'uz' => 'Uzbek',
    'am' => 'Amharic',
    'co' => 'Corsican',
    'haw' => 'Hawaiian',
    'ku' => 'Kurdish (Kurmanji)',
    'ky' => 'Kyrgyz',
    'lb' => 'Luxembourgish',
    'ps' => 'Pashto',
    'sm' => 'Samoan',
    'gd' => 'Scottish Gaelic',
    'sn' => 'Shona',
    'sd' => 'Sindhi',
    'fy' => 'Frisian',
    'xh' => 'Xhosa',
  );
  foreach ($languages as $lang => $language) {
    $form['language']["gtranslate_{$lang}"] = array(
      '#type' => 'radios',
      '#title' => t("Show {$language}"),
      '#default_value' => variable_get("gtranslate_{$lang}", in_array($lang, $languages_flags) ? 2 : (in_array($lang, $languages_noflags) ? 0 : 1)),
      '#options' => array(
        1 => 'Yes',
        0 => 'No',
        2 => 'As a flag',
      ),
      '#description' => t("Show {$language} in the language list"),
      '#required' => TRUE,
    );
  }
  return system_settings_form($form);
}