| @@ -1,368 +1,390 @@ | ||
| 1 | -<?php | |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
| 3 | -class DeeplConfiguration { | |
| 4 | - static function getAPIKey() { | |
| 5 | - return apply_filters( 'wpdeepl_' . __METHOD__, trim( get_option( 'wpdeepl_api_key' ) ) ); | |
| 6 | - } | |
| 7 | - static function getAPIServer() { | |
| 8 | - $choice = get_option( 'wpdeepl_api_server'); | |
| 9 | - if ( !$choice ) { | |
| 10 | - $choice = 'paid_api'; | |
| 11 | - } | |
| 12 | - $possibilities = self::getDeepLAPIServers(); | |
| 13 | - | |
| 14 | - if ( isset( $possibilities[$choice] ) ) { | |
| 15 | - return apply_filters( 'wpdeepl_' . __METHOD__, $possibilities[$choice]['server'], $choice, $possibilities ); | |
| 16 | - } | |
| 17 | - else { | |
| 18 | - return apply_filters( 'wpdeepl_' . __METHOD__, false, $choice, $possibilities ); | |
| 19 | - } | |
| 20 | - } | |
| 21 | - | |
| 22 | - static function getDeeplAPIServers() { | |
| 23 | - $array = array( | |
| 24 | - 'paid_api' => array( | |
| 25 | - 'server' => 'https://api.deepl.com/v2/', | |
| 26 | - 'description' => __('Regular paid API Plan (https://api.deepl.com/v2/)', 'wpdeepl') | |
| 27 | - ), | |
| 28 | - 'free_plan' => array( | |
| 29 | - 'server' => 'https://api-free.deepl.com/v2/', | |
| 30 | - 'description' => __('Free API plan (https://api-free.deepl.com)', 'wpdeepl' ) | |
| 31 | - ), | |
| 32 | - ); | |
| 33 | - return $array; | |
| 34 | - } | |
| 35 | - | |
| 36 | - static function getLocaleNameForLn( $ln, $type = 'source ' ) { | |
| 37 | - $wp_locale = get_locale(); | |
| 38 | - $languages_data = self::DefaultsAllLanguages(); | |
| 39 | - foreach( $languages_data as $locale => $locale_data ) { | |
| 40 | - $compare = $type == 'target' ? 'astarget' : 'assource'; | |
| 41 | - if( strtolower( $locale_data[$compare] ) == $ln ) { | |
| 42 | - return $locale_data['labels'][$wp_locale]; | |
| 43 | - } | |
| 44 | - } | |
| 45 | - return false; | |
| 46 | - } | |
| 47 | - | |
| 48 | - static function usingGlossaries() { | |
| 49 | - return get_option('wpdeepl_glossaries') && is_array( get_option('wpdeepl_glossaries') ); | |
| 50 | - } | |
| 51 | - | |
| 52 | - static function getLocaleNameForIsoCode2( $isocode2, $type = 'source ' ) { | |
| 53 | - $wp_locale = get_locale(); | |
| 54 | - $languages_data = self::DefaultsAllLanguages(); | |
| 55 | - foreach( $languages_data as $locale => $locale_data ) { | |
| 56 | - if( strtolower( $locale_data['isocode'] ) == $isocode2 ) { | |
| 57 | - $label = $locale_data['labels'][$wp_locale]; | |
| 58 | - $label = preg_replace('#\(.*?\)#ism', '', $label ); | |
| 59 | - return trim( $label ); | |
| 60 | - } | |
| 61 | - } | |
| 62 | - return false; | |
| 63 | - } | |
| 64 | - | |
| 65 | - static function getLogLevel() { | |
| 66 | - return apply_filters( 'wpdeepl_' . __METHOD__, get_option( 'wpdeepl_log_level') ); | |
| 67 | - } | |
| 68 | - | |
| 69 | - static function getActivePostTypes() { | |
| 70 | - $return = get_option( 'wpdeepl_metabox_post_types' ) ? get_option( 'wpdeepl_metabox_post_types' ) : array(); | |
| 71 | - $return = get_option( 'wpdeepl_pro_post_types' ) ? array_merge( $return, get_option( 'wpdeepl_pro_post_types' ) ) : $return; | |
| 72 | - | |
| 73 | - $return = array_unique( $return ); | |
| 74 | - return apply_filters( 'wpdeepl_' . __METHOD__, $return ); | |
| 75 | - | |
| 76 | - } | |
| 77 | - static function getMetaBoxPostTypes() { | |
| 78 | - $post_types = get_option( 'wpdeepl_metabox_post_types' ); | |
| 79 | - if ( empty( $post_types ) ) { | |
| 80 | - $post_types = array( 'post', 'page' ); | |
| 81 | - } | |
| 82 | - return apply_filters( 'wpdeepl_' . __METHOD__, $post_types ); | |
| 83 | - } | |
| 84 | - static function getMetaBoxDefaultBehaviour() { | |
| 85 | - return 'replace'; | |
| 86 | - return apply_filters( 'wpdeepl_' . __METHOD__, get_option( 'wpdeepl_metabox_behaviour' ) ); | |
| 87 | - } | |
| 88 | - static function getDefaultTargetLanguage() { | |
| 89 | - return apply_filters( 'wpdeepl_' . __METHOD__, get_option( 'wpdeepl_default_language' ) ); | |
| 90 | - } | |
| 91 | - | |
| 92 | - static function getDisplayedLanguages() { | |
| 93 | - $value = get_option( 'wpdeepl_displayed_languages') ; | |
| 94 | - return apply_filters( 'wpdeepl_' . __METHOD__, $value ); | |
| 95 | - } | |
| 96 | - static function getMetaBoxContext() { | |
| 97 | - $context = get_option( 'wpdeepl_metabox_context' ); | |
| 98 | - if ( empty( $context ) ) { | |
| 99 | - $context = 'side'; | |
| 100 | - } | |
| 101 | - return apply_filters( 'wpdeepl_' . __METHOD__, $context ); | |
| 102 | - } | |
| 103 | - static function getMetaBoxPriority() { | |
| 104 | - $priority = get_option( 'wpdeepl_metabox_priority' ); | |
| 105 | - if ( empty( $priority ) ) { | |
| 106 | - $priority = 'high'; | |
| 107 | - } | |
| 108 | - return apply_filters( 'wpdeepl_' . __METHOD__, $priority ); | |
| 109 | - } | |
| 110 | - | |
| 111 | - static function usingMultilingualPlugins() { | |
| 112 | - return false; | |
| 113 | - } | |
| 114 | - | |
| 115 | - static function getNonceAction() { | |
| 116 | - return apply_filters( 'wpdeepl_' . __METHOD__, 'deepl_translate_post' ); | |
| 117 | - } | |
| 118 | - | |
| 119 | - static function getActiveGlossaryFor( $source_language, $target_language) { | |
| 120 | - $source = !empty( $source_language ) ? strtolower( substr( $source_language, 0, 2 ) ) : false; | |
| 121 | - $target = !empty( $target_language ) ? strtolower( substr( $target_language, 0, 2 ) ) : false; | |
| 122 | - $active_glossary_id = false; | |
| 123 | - if( $source && $target) $active_glossary_id = get_option( 'wpdeepl_glossary_' . $source. '_' . $target ); | |
| 124 | - return apply_filters( 'wpdeepl_' . __METHOD__, $active_glossary_id ); | |
| 125 | - } | |
| 126 | - | |
| 127 | - | |
| 128 | - | |
| 129 | - | |
| 130 | -/** | |
| 131 | - * 0 = activated | |
| 132 | - * 1 = activated and setup | |
| 133 | - */ | |
| 134 | - static function isPluginInstalled() { | |
| 135 | - return get_option( 'wpdeepl_plugin_installed' ); | |
| 136 | - } | |
| 137 | - | |
| 138 | - | |
| 139 | - static function validateLang( $language_string, $output = 'assource' ) { | |
| 140 | - // output source will return 2 characters | |
| 141 | - // output source will return AA(-AA) | |
| 142 | - | |
| 143 | - $language_string = htmlspecialchars( $language_string ); | |
| 144 | - $language_string = str_replace( '-', '_', $language_string ); | |
| 145 | - | |
| 146 | - if( $language_string == 'NB' ) { | |
| 147 | - $language_string = 'NO'; | |
| 148 | - } | |
| 149 | - | |
| 150 | - $all_languages = DeeplConfiguration::DefaultsAllLanguages(); | |
| 151 | - $locale = get_locale(); | |
| 152 | - //wpdeepl_debug_display( $locale, "\n locale" ); | |
| 153 | - | |
| 154 | - | |
| 155 | - //if( $language_string == 'nn_NO' ) $language_string = 'no_NO'; | |
| 156 | - | |
| 157 | - if( strpos( $locale, '_formal' ) != false ) { | |
| 158 | - $locale = str_replace( '_formal', '', $locale ); | |
| 159 | - } | |
| 160 | - if( strpos( $locale, '_informal' ) != false ) { | |
| 161 | - $locale = str_replace( '_informal', '', $locale ); | |
| 162 | - } | |
| 163 | - | |
| 164 | - $language = false; | |
| 165 | - if( $output == 'astarget' ) { | |
| 166 | - //wpdeepl_debug_display( $all_languages[$language_string]," lang $language_string locale $locale"); wpdeepl_debug_display( $all_languages); | |
| 167 | - } | |
| 168 | - if ( isset( $all_languages[$language_string] ) ) { | |
| 169 | - $language = $all_languages[$language_string]; | |
| 170 | - } | |
| 171 | - else { | |
| 172 | - foreach ( $all_languages as $try_locale => $try_language ) { | |
| 173 | - if ( $try_language['allcaps'] == strtoupper( $language_string ) ) { | |
| 174 | - $language = $try_language; | |
| 175 | - break; | |
| 176 | - } | |
| 177 | - if ( $try_language['isocode'] == strtoupper( $language_string ) ) { | |
| 178 | - $language = $try_language; | |
| 179 | - break; | |
| 180 | - } | |
| 181 | - if( $output == 'astarget' && $try_language['astarget'] == strtoupper( $language_string ) ) { | |
| 182 | - $language = $try_language; | |
| 183 | - break; | |
| 184 | - } | |
| 185 | - } | |
| 186 | - } | |
| 187 | - | |
| 188 | - if ( !$language ) { | |
| 189 | - return false; | |
| 190 | - } | |
| 191 | - | |
| 192 | - if( $output == 'astarget' ) { | |
| 193 | - //wpdeepl_debug_display( $language, "language, locale $locale"); | |
| 194 | - } | |
| 195 | - $language['label'] = isset( $language['labels'][$locale] ) ? $language['labels'][$locale] : false; | |
| 196 | - | |
| 197 | - if ( $output == 'assource' ) { | |
| 198 | - return $language['assource']; | |
| 199 | - } | |
| 200 | - elseif ( $output == 'astarget' ) { | |
| 201 | - return $language['astarget']; | |
| 202 | - } | |
| 203 | - elseif ( $output == 'isocode' ) { | |
| 204 | - return $language['isocode']; | |
| 205 | - } | |
| 206 | - elseif ( $output == 'full' ) { | |
| 207 | - return $language; | |
| 208 | - } | |
| 209 | - elseif ( $output == 'label' ) { | |
| 210 | - | |
| 211 | - return $language['label']; | |
| 212 | - } | |
| 213 | - else { | |
| 214 | - return $language['isocode']; | |
| 215 | - } | |
| 216 | - } | |
| 217 | - static function DefaultsMetaboxBehaviours() { | |
| 218 | - $array = array( | |
| 219 | - 'replace' => __( 'Replace content', 'wpdeepl' ), | |
| 220 | - 'append' => __( 'Append to content', 'wpdeepl' ) | |
| 221 | - ); | |
| 222 | - return apply_filters( 'wpdeepl_' . __METHOD__ , $array ); | |
| 223 | - } | |
| 224 | - | |
| 225 | - static function getFormalityLevel( $target_lang = false ) { | |
| 226 | - if ( $target_lang ) { | |
| 227 | - $formality_level = get_option('wpdeepl_formality_' . $target_lang ); | |
| 228 | - } | |
| 229 | - if( !$formality_level || $formality_level == 'wpdeepl' ) { | |
| 230 | - $formality_level = get_option( 'wpdeepl_default_formality' ); | |
| 231 | - } | |
| 232 | - | |
| 233 | - /** | |
| 234 | - * . This feature currently only works for target languages DE (German), FR (French), IT (Italian), ES (Spanish), NL (Dutch), PL (Polish), PT-PT, PT-BR (Portuguese) and RU (Russian). Setting this parameter with a target language that does not support formality will fail, unless one of the prefer_... options are used. Possible options are: | |
| 235 | - * default (default) | |
| 236 | -more - for a more formal language | |
| 237 | -less - for a more informal language | |
| 238 | -prefer_more - for a more formal language if available, otherwise fallback to default formality | |
| 239 | -prefer_less - for a more informal language if available, otherwise fallback to default formality | |
| 240 | - * */ | |
| 241 | - | |
| 242 | - if( $formality_level != 'wpdeepl' ) { | |
| 243 | - $formality_level = 'prefer_' . $formality_level; | |
| 244 | - } | |
| 245 | - | |
| 246 | - return apply_filters( 'wpdeepl_' . __METHOD__, $formality_level, $target_lang ); | |
| 247 | - } | |
| 248 | - | |
| 249 | - static function getLanguagesAllowingFormality() { | |
| 250 | - // This feature currently works for target languages DE, FR, IT, ES, NL, PL, PT-PT, PT-BR, RU, JA. | |
| 251 | - return array('de_DE', 'fr_FR', 'it_IT', 'es_ES', 'es_419', 'nl_NL', 'ja_JP', 'pl_PL', 'pt_PT', 'pt_BR', 'ru_RU' ); | |
| 252 | - } | |
| 253 | - | |
| 254 | - static function DefaultsISOCodes() { | |
| 255 | - $locale = get_locale(); | |
| 256 | - $locale = str_replace( '_formal', '', $locale ); | |
| 257 | - $locale = str_replace( '_informal', '', $locale ); | |
| 258 | - $all_languages = DeeplConfiguration::DefaultsAllLanguages(); | |
| 259 | - $languages = array(); | |
| 260 | - foreach ( $all_languages as $isocode => $labels ) { | |
| 261 | - $languages[$isocode] = isset( $labels['labels']) && isset( $labels['labels'][$locale] ) ? $labels['labels'][$locale] : false; | |
| 262 | - } | |
| 263 | - return apply_filters( 'wpdeepl_' . __METHOD__ , $languages ); | |
| 264 | - } | |
| 265 | - | |
| 266 | - static function getLanguageFromIsoCode2( $isocode2, $context = 'target' ) { | |
| 267 | - $isocode2 = strtolower( $isocode2 ); | |
| 268 | - $all_languages = self::DefaultsAllLanguages(); | |
| 269 | - $key = ( $context == 'source' ) ? 'assource' : 'astarget'; | |
| 270 | - foreach( $all_languages as $lang => $language ) { | |
| 271 | - $short = substr( strtolower( $language[$key] ), 0, 2 ); | |
| 272 | - if( $short == $isocode2 ) { | |
| 273 | - return $lang; | |
| 274 | - } | |
| 275 | - } | |
| 276 | - return false; | |
| 277 | - } | |
| 278 | - | |
| 279 | - static function DefaultsAllLanguages() { | |
| 280 | - $languages = array(); | |
| 281 | - | |
| 282 | - global $wp_filesystem; | |
| 283 | - if ( empty( $wp_filesystem ) ) { | |
| 284 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); | |
| 285 | - if ( ! WP_Filesystem() ) { | |
| 286 | - return array(); // Retourne un tableau vide en cas d'échec | |
| 287 | - } | |
| 288 | - } | |
| 289 | - $file_path = wp_normalize_path( trailingslashit( WPDEEPL_PATH ) . 'languages.csv' ); | |
| 290 | - $csv_contents = $wp_filesystem->get_contents( $file_path ); | |
| 291 | - $csv_data = array(); | |
| 292 | - | |
| 293 | - if ( $csv_contents ) { | |
| 294 | - $lines = explode( "\n", $csv_contents ); | |
| 295 | - foreach ( $lines as $line ) { | |
| 296 | - // Ignorer les lignes vides | |
| 297 | - $line = trim( $line ); | |
| 298 | - if ( empty( $line ) ) { | |
| 299 | - continue; | |
| 300 | - } | |
| 301 | - $data = str_getcsv( $line, ',', '"', "\\" ); | |
| 302 | - | |
| 303 | - if ( is_array( $data ) && ! empty( $data ) ) { | |
| 304 | - $csv_data[] = $data; | |
| 305 | - } | |
| 306 | - } | |
| 307 | - } | |
| 308 | - | |
| 309 | - //wpdeepl_debug_display( $csv_data, " alors data"); | |
| 310 | - $headers = array_shift( $csv_data ); | |
| 311 | - if( $csv_data ) foreach ( $csv_data as $labels ) { | |
| 312 | - $labels = array_combine( $headers, $labels ); | |
| 313 | - | |
| 314 | - $locale = $labels['locale']; | |
| 315 | - unset( $labels['locale'] ); | |
| 316 | - | |
| 317 | - $extra_country = false; | |
| 318 | - if ( strlen( $labels['astarget'] ) > 2 ) { | |
| 319 | - $extra_country = substr( $labels['astarget'], 3 ); | |
| 320 | - } | |
| 321 | - | |
| 322 | - $languages[$locale] = array(); | |
| 323 | - foreach ( array('allcaps', 'assource', 'astarget', 'isocode' ) as $key ) { | |
| 324 | - $languages[$locale][$key] = $labels[$key]; | |
| 325 | - unset( $labels[$key] ); | |
| 326 | - } | |
| 327 | - | |
| 328 | - | |
| 329 | - if ( $extra_country ) { | |
| 330 | - foreach ( $labels as $code => $label ) { | |
| 331 | - $labels[$code] = $label . ' (' . $extra_country . ')'; | |
| 332 | - } | |
| 333 | - } | |
| 334 | - $languages[$locale]['labels'] = $labels; | |
| 335 | - } | |
| 336 | - | |
| 337 | - return apply_filters( 'wpdeepl_' . __METHOD__, $languages ); | |
| 338 | - | |
| 339 | - // used for.. something else | |
| 340 | - /* translators: strings used in extended functions. Target lang */ | |
| 341 | - $test = __('Translate to %s', 'wpdeepl' ); | |
| 342 | - /* translators: strings used in extended functions. Number of posts */ | |
| 343 | - $test = __('Translated %d posts.', 'wpdeepl'); | |
| 344 | - $test = __('Bulk translate', 'wpdeepl'); | |
| 345 | - $test = __('Content types', 'wpdeepl'); | |
| 346 | - $test = __( 'Translate contents', 'wpdeepl' ); | |
| 347 | - $test = __( 'Select which kind of content you want to be able to translate', 'wpdeepl' ); | |
| 348 | - $test = __( 'Target languages for bulk actions', 'wpdeepl' ); | |
| 349 | - $test = __( 'Show these target languages in bulk menu', 'wpdeepl' ); | |
| 350 | - } | |
| 351 | - | |
| 352 | - // might serve somewhere | |
| 353 | - static function getContentTypes() { | |
| 354 | - return apply_filters( 'wpdeepl_' . __METHOD__, get_option('wpdeepl_contents_to_translate') ); | |
| 355 | - } | |
| 356 | - static function getTargetLocales() { | |
| 357 | - return apply_filters( 'wpdeepl_' . __METHOD__, get_option( 'wpdeepl_target_locales') ); | |
| 358 | - } | |
| 359 | - | |
| 360 | - static function usingPolylang() { | |
| 361 | - return function_exists( 'pll_the_languages' ); | |
| 362 | - } | |
| 363 | - | |
| 364 | - static function getBulkTargetLanguages() { | |
| 365 | - return apply_filters( 'wpdeepl_' . __METHOD__, get_option( 'wpdeepl_bulk_target_locales' ) ); | |
| 366 | - } | |
| 367 | -} | |
| 368 | - | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +class DeepLConfiguration { | |
| 4 | + static function getAPIKey() { | |
| 5 | + return apply_filters( __METHOD__, trim( get_option( 'wpdeepl_api_key' ) ) ); | |
| 6 | + } | |
| 7 | + | |
| 8 | + static function getLogLevel() { | |
| 9 | + return apply_filters( __METHOD__, get_option( 'wpdeepl_log_level') ); | |
| 10 | + } | |
| 11 | + | |
| 12 | + static function getMetaBoxPostTypes() { | |
| 13 | + return apply_filters( __METHOD__, get_option( 'wpdeepl_metabox_post_types' ) ); | |
| 14 | + } | |
| 15 | + static function getMetaBoxDefaultBehaviour() { | |
| 16 | + return apply_filters( __METHOD__, get_option( 'wpdeepl_metabox_behaviour' ) ); | |
| 17 | + } | |
| 18 | + static function getDefaultTargetLanguage() { | |
| 19 | + return apply_filters( __METHOD__, get_option( 'wpdeepl_default_language' ) ); | |
| 20 | + } | |
| 21 | + static function getMetaBoxContext() { | |
| 22 | + return apply_filters( __METHOD__, get_option( 'wpdeepl_metabox_context' ) ); | |
| 23 | + } | |
| 24 | + static function getMetaBoxPriority() { | |
| 25 | + return apply_filters( __METHOD__, get_option( 'wpdeepl_metabox_priority' ) ); | |
| 26 | + } | |
| 27 | + | |
| 28 | + static function usingMultilingualPlugins() { | |
| 29 | + return false; | |
| 30 | + } | |
| 31 | + | |
| 32 | +/** | |
| 33 | + * 0 = activated | |
| 34 | + * 1 = activated and setup | |
| 35 | + */ | |
| 36 | + static function isPluginInstalled() { | |
| 37 | + return get_option( 'wpdeepl_plugin_installed' ); | |
| 38 | + } | |
| 39 | + | |
| 40 | + static function execWorks() { | |
| 41 | + if( exec( 'echo EXEC' ) == 'EXEC' ){ | |
| 42 | + return true; | |
| 43 | + } | |
| 44 | + return false; | |
| 45 | + } | |
| 46 | + | |
| 47 | + static function validateLang( $language_string, $output = 'assource' ) { | |
| 48 | + // output source will return 2 characters | |
| 49 | + // output source will return AA(-AA) | |
| 50 | + | |
| 51 | + $language_string = filter_var( $language_string, FILTER_SANITIZE_STRING ); | |
| 52 | + | |
| 53 | + $all_languages = DeepLConfiguration::DefaultsAllLanguages(); | |
| 54 | + | |
| 55 | + $language = false; | |
| 56 | + if( isset( $all_languages[$language_string] ) ) { | |
| 57 | + $language = $all_languages[$language_string]; | |
| 58 | + } | |
| 59 | + else { | |
| 60 | + foreach( $all_languages as $locale => $try_language ) { | |
| 61 | + if( $try_language['allcaps'] == strtoupper( $language_string ) ) { | |
| 62 | + $language = $try_language; | |
| 63 | + break; | |
| 64 | + } | |
| 65 | + if( $try_language['isocode'] == strtoupper( $language_string ) ) { | |
| 66 | + $language = $try_language; | |
| 67 | + break; | |
| 68 | + } | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + if( !$language ) { | |
| 73 | + return false; | |
| 74 | + } | |
| 75 | + | |
| 76 | + if( $output == 'assource' ) { | |
| 77 | + return $language['assource']; | |
| 78 | + } | |
| 79 | + elseif( $output == 'astarget' ) { | |
| 80 | + return $language['astarget']; | |
| 81 | + } | |
| 82 | + elseif( $output == 'isocode' ) { | |
| 83 | + return $language['isocode']; | |
| 84 | + } | |
| 85 | + else { | |
| 86 | + return $language['isocode']; | |
| 87 | + } | |
| 88 | + } | |
| 89 | + static function DefaultsMetaboxBehaviours() { | |
| 90 | + $array = array( | |
| 91 | + 'replace' => __( 'Replace content', 'wpdeepl' ), | |
| 92 | + 'append' => __( 'Append to content', 'wpdeepl' ) | |
| 93 | + ); | |
| 94 | + return apply_filters( __METHOD__ , $array ); | |
| 95 | + } | |
| 96 | + static function DefaultsISOCodes() { | |
| 97 | + $locale = get_locale(); | |
| 98 | + $all_languages = DeepLConfiguration::DefaultsAllLanguages(); | |
| 99 | + $languages = array(); | |
| 100 | + foreach( $all_languages as $isocode => $labels ) { | |
| 101 | + $languages[$isocode] = $labels['labels'][$locale]; | |
| 102 | + } | |
| 103 | + return apply_filters( __METHOD__ , $languages ); | |
| 104 | + } | |
| 105 | + | |
| 106 | + static function DefaultsAllLanguages() { | |
| 107 | + $languages = array( | |
| 108 | + 'fr_FR' => array( | |
| 109 | + 'labels' => array( | |
| 110 | + 'fr_FR' => 'français', | |
| 111 | + 'en_GB' => 'french', | |
| 112 | + 'en_US' => 'french', | |
| 113 | + 'de_DE' => 'französisch', | |
| 114 | + 'es_ES' => 'francés', | |
| 115 | + 'it_IT' => 'francese', | |
| 116 | + 'nl_NL' => 'frans', | |
| 117 | + 'pl_PL' => 'francuski', | |
| 118 | + 'ru_RU' => 'Французский', | |
| 119 | + | |
| 120 | + 'pt_PT' => 'inglês', | |
| 121 | + 'pt_BR' => 'inglês', | |
| 122 | + 'ja_JP' => '英語', | |
| 123 | + 'cn_ZH' => '英国人的' | |
| 124 | + ), | |
| 125 | + 'assource' => 'FR', | |
| 126 | + 'astarget' => 'FR', | |
| 127 | + 'allcaps' => 'FR_FR', | |
| 128 | + 'isocode' => 'FR', | |
| 129 | + ), | |
| 130 | + 'en_GB' => array( | |
| 131 | + 'labels' => array( | |
| 132 | + 'fr_FR' => 'anglais', | |
| 133 | + 'en_GB' => 'english', | |
| 134 | + 'en_US' => 'english', | |
| 135 | + 'de_DE' => 'englisch', | |
| 136 | + 'es_ES' => 'inglès', | |
| 137 | + 'it_IT' => 'inglese', | |
| 138 | + 'nl_NL' => 'engels', | |
| 139 | + 'pl_PL' => 'anglik', | |
| 140 | + 'ru_RU' => 'английски', | |
| 141 | + 'pt_PT' => 'Inglês', | |
| 142 | + 'pt_BR' => 'Inglês', | |
| 143 | + 'ja_JP' => 'イギリス英語', | |
| 144 | + 'cn_ZH' => '英式英语' | |
| 145 | + ), | |
| 146 | + 'assource' => 'EN', | |
| 147 | + 'astarget' => 'EN-GB', | |
| 148 | + 'allcaps' => 'EN_GB', | |
| 149 | + 'isocode' => 'EN', | |
| 150 | + ), | |
| 151 | + 'en_US' => array( | |
| 152 | + 'labels' => array( | |
| 153 | + 'fr_FR' => 'anglais', | |
| 154 | + 'en_GB' => 'english', | |
| 155 | + 'en_US' => 'english', | |
| 156 | + 'de_DE' => 'englisch', | |
| 157 | + 'es_ES' => 'inglès', | |
| 158 | + 'it_IT' => 'inglese', | |
| 159 | + 'nl_NL' => 'engels', | |
| 160 | + 'pl_PL' => 'anglik', | |
| 161 | + 'ru_RU' => 'английски', | |
| 162 | + 'pt_PT' => 'Inglês', | |
| 163 | + 'pt_BR' => 'Inglês', | |
| 164 | + 'ja_JP' => 'イギリス英語', | |
| 165 | + 'cn_ZH' => '英式英语' | |
| 166 | + ), | |
| 167 | + 'assource' => 'EN', | |
| 168 | + 'astarget' => 'EN-US', | |
| 169 | + 'allcaps' => 'EN_US', | |
| 170 | + 'isocode' => 'EN', | |
| 171 | + ), | |
| 172 | + 'de_DE' => array( | |
| 173 | + 'labels' => array( | |
| 174 | + 'fr_FR' => 'allemand', | |
| 175 | + 'en_GB' => 'german', | |
| 176 | + 'en_US' => 'german', | |
| 177 | + 'de_DE' => 'deutsch', | |
| 178 | + 'es_ES' => 'alemán', | |
| 179 | + 'it_IT' => 'allemando', | |
| 180 | + 'nl_NL' => 'allemandrijk', | |
| 181 | + 'pl_PL' => 'niemiec', | |
| 182 | + 'ru_RU' => 'немецки', | |
| 183 | + 'pt_PT' => 'Alemão', | |
| 184 | + 'pt_BR' => 'Alemão', | |
| 185 | + 'ja_JP' => 'ドイツ語', | |
| 186 | + 'cn_ZH' => '德国' | |
| 187 | + ), | |
| 188 | + 'assource' => 'DE', | |
| 189 | + 'astarget' => 'DE', | |
| 190 | + 'allcaps' => 'DE_DE', | |
| 191 | + 'isocode' => 'DE', | |
| 192 | + ), | |
| 193 | + 'es_ES' => array( | |
| 194 | + 'labels' => array( | |
| 195 | + 'fr_FR' => 'espagnol', | |
| 196 | + 'en_GB' => 'spanish', | |
| 197 | + 'en_US' => 'spanish', | |
| 198 | + 'de_DE' => 'spanisch', | |
| 199 | + 'es_ES' => 'castellano', | |
| 200 | + 'it_IT' => 'spagnola', | |
| 201 | + 'nl_NL' => 'spaans', | |
| 202 | + 'pl_PL' => 'hiszpanin', | |
| 203 | + 'ru_RU' => 'испански', | |
| 204 | + 'pt_PT' => 'Espanhol', | |
| 205 | + 'pt_BR' => 'Espanhol', | |
| 206 | + 'ja_JP' => 'スペイン語', | |
| 207 | + 'cn_ZH' => '西班牙语' | |
| 208 | + ), | |
| 209 | + 'assource' => 'ES', | |
| 210 | + 'astarget' => 'ES', | |
| 211 | + 'allcaps' => 'ES_ES', | |
| 212 | + 'isocode' => 'ES', | |
| 213 | + ), | |
| 214 | + 'it_IT' => array( | |
| 215 | + 'labels' => array( | |
| 216 | + 'fr_FR' => 'italien', | |
| 217 | + 'en_GB' => 'italian', | |
| 218 | + 'en_US' => 'italian', | |
| 219 | + 'de_DE' => 'italienisch', | |
| 220 | + 'es_ES' => 'italiano', | |
| 221 | + 'it_IT' => 'italiano', | |
| 222 | + 'nl_NL' => 'italiaan', | |
| 223 | + 'pl_PL' => 'włoch', | |
| 224 | + 'ru_RU' => 'итальянски', | |
| 225 | + 'pt_PT' => 'Italiano', | |
| 226 | + 'pt_BR' => 'Italiano', | |
| 227 | + 'ja_JP' => 'イタリア語', | |
| 228 | + 'cn_ZH' => '意大利' | |
| 229 | + ), | |
| 230 | + 'assource' => 'IT', | |
| 231 | + 'astarget' => 'IT', | |
| 232 | + 'allcaps' => 'IT_IT', | |
| 233 | + 'isocode' => 'IT', | |
| 234 | + ), | |
| 235 | + 'nl_NL' => array( | |
| 236 | + 'labels' => array( | |
| 237 | + 'fr_FR' => 'néerlandais', | |
| 238 | + 'en_GB' => 'dutch', | |
| 239 | + 'en_US' => 'dutch', | |
| 240 | + 'de_DE' => 'holländisch', | |
| 241 | + 'es_ES' => 'neerlandés', | |
| 242 | + 'it_IT' => 'olandese', | |
| 243 | + 'nl_NL' => 'hollands', | |
| 244 | + 'pl_PL' => 'holender', | |
| 245 | + 'ru_RU' => 'голландски', | |
| 246 | + 'pt_PT' => 'Holandês', | |
| 247 | + 'pt_BR' => 'Holandês', | |
| 248 | + 'ja_JP' => '蘭語', | |
| 249 | + 'cn_ZH' => '荷兰语' | |
| 250 | + ), | |
| 251 | + 'assource' => 'NL', | |
| 252 | + 'astarget' => 'NL', | |
| 253 | + 'allcaps' => 'NL_NL', | |
| 254 | + 'isocode' => 'NL', | |
| 255 | + ), | |
| 256 | + | |
| 257 | + 'pl_PL' => array( | |
| 258 | + 'labels' => array( | |
| 259 | + 'fr_FR' => 'polonais', | |
| 260 | + 'en_GB' => 'polish', | |
| 261 | + 'en_US' => 'polish', | |
| 262 | + 'de_DE' => 'polnisch', | |
| 263 | + 'es_ES' => 'polaco', | |
| 264 | + 'it_IT' => 'polacca', | |
| 265 | + 'nl_NL' => 'pools', | |
| 266 | + 'pl_PL' => 'polak', | |
| 267 | + 'ru_RU' => 'польски', | |
| 268 | + 'pt_PT' => 'Polaco', | |
| 269 | + 'pt_BR' => 'Polonês', | |
| 270 | + 'ja_JP' => 'ポーランド語', | |
| 271 | + 'cn_ZH' => '波兰语' | |
| 272 | + ), | |
| 273 | + 'assource' => 'PL', | |
| 274 | + 'astarget' => 'PL', | |
| 275 | + 'allcaps' => 'PL_PL', | |
| 276 | + 'isocode' => 'PL', | |
| 277 | + ), | |
| 278 | + 'ru_RU' => array( | |
| 279 | + 'labels' => array( | |
| 280 | + 'fr_FR' => 'russe', | |
| 281 | + 'en_GB' => 'russian', | |
| 282 | + 'en_US' => 'russian', | |
| 283 | + 'de_DE' => 'russisch', | |
| 284 | + 'es_ES' => 'ruso', | |
| 285 | + 'it_IT' => 'russo', | |
| 286 | + 'nl_NL' => 'russisch', | |
| 287 | + 'pl_PL' => 'rosjanin', | |
| 288 | + 'ru_RU' => 'русский', | |
| 289 | + 'pt_PT' => 'Russo', | |
| 290 | + 'pt_BR' => 'Russo', | |
| 291 | + 'ja_JP' => 'ロシア語', | |
| 292 | + 'cn_ZH' => '俄语' | |
| 293 | + ), | |
| 294 | + 'assource' => 'RU', | |
| 295 | + 'astarget' => 'RU', | |
| 296 | + 'allcaps' => 'RU_RU', | |
| 297 | + 'isocode' => 'RU', | |
| 298 | + ), | |
| 299 | + | |
| 300 | + | |
| 301 | + 'pt_PT' => array( | |
| 302 | + 'labels' => array( | |
| 303 | + 'fr_FR' => 'portugais', | |
| 304 | + 'en_GB' => 'Portuguese', | |
| 305 | + 'en_US' => 'Portuguese', | |
| 306 | + 'de_DE' => 'Portugiesisch', | |
| 307 | + 'es_ES' => 'Portugués', | |
| 308 | + 'it_IT' => 'Portoghese', | |
| 309 | + 'nl_NL' => 'Portugees', | |
| 310 | + 'pl_PL' => 'Portugalski', | |
| 311 | + 'ru_RU' => 'Португальский', | |
| 312 | + 'pt_PT' => 'Português', | |
| 313 | + 'pt_BR' => 'Português Brasileiro', | |
| 314 | + 'ja_JP' => 'ポルトガル語', | |
| 315 | + 'cn_ZH' => '葡萄牙语' | |
| 316 | + ), | |
| 317 | + 'assource' => 'PT', | |
| 318 | + 'astarget' => 'PT-PT', | |
| 319 | + 'allcaps' => 'PT_PT', | |
| 320 | + 'isocode' => 'PT', | |
| 321 | + ), | |
| 322 | + 'pt_BR' => array( | |
| 323 | + 'labels' => array( | |
| 324 | + 'fr_FR' => 'portugais du Brésil', | |
| 325 | + 'en_GB' => 'Brazilian Portuguese', | |
| 326 | + 'en_US' => 'Brazilian Portuguese', | |
| 327 | + 'de_DE' => 'Brasilianisches Portugiesisch', | |
| 328 | + 'es_ES' => 'Portugués de Brasil', | |
| 329 | + 'it_IT' => 'Portoghese brasiliano', | |
| 330 | + 'nl_NL' => 'Braziliaans Portugees', | |
| 331 | + 'pl_PL' => 'Brazylijczyk-Portugalczyk', | |
| 332 | + 'ru_RU' => 'бразильский португальский', | |
| 333 | + 'pt_PT' => 'Português', | |
| 334 | + 'pt_BR' => 'Português do Brasil', | |
| 335 | + 'ja_JP' => 'ブラジルポルトガル語', | |
| 336 | + 'cn_ZH' => '巴西葡萄牙语' | |
| 337 | + ), | |
| 338 | + 'assource' => 'PT', | |
| 339 | + 'astarget' => 'PT-BR', | |
| 340 | + 'allcaps' => 'PT_BR', | |
| 341 | + 'isocode' => 'PT', | |
| 342 | + ), | |
| 343 | + | |
| 344 | + 'ja_JP' => array( | |
| 345 | + 'labels' => array( | |
| 346 | + 'fr_FR' => 'japonais', | |
| 347 | + 'en_GB' => 'japanese', | |
| 348 | + 'en_US' => 'japanese', | |
| 349 | + 'de_DE' => 'Japanisch', | |
| 350 | + 'es_ES' => 'Japonés', | |
| 351 | + 'it_IT' => 'Giapponese', | |
| 352 | + 'nl_NL' => 'Japans', | |
| 353 | + 'pl_PL' => 'Japończyk', | |
| 354 | + 'ru_RU' => 'Японский', | |
| 355 | + 'pt_PT' => 'Japonês', | |
| 356 | + 'pt_BR' => 'Japonês', | |
| 357 | + 'ja_JP' => 'にほんご', | |
| 358 | + 'cn_ZH' => '日文', | |
| 359 | + ), | |
| 360 | + 'assource' => 'JP', | |
| 361 | + 'astarget' => 'JP', | |
| 362 | + 'allcaps' => 'JA_JP', | |
| 363 | + 'isocode' => 'JP', | |
| 364 | + ), | |
| 365 | + 'cn_ZH' => array( | |
| 366 | + 'labels' => array( | |
| 367 | + 'fr_FR' => 'chinois simplifié', | |
| 368 | + 'en_GB' => 'simplified chinese', | |
| 369 | + 'en_US' => 'simplified chinese', | |
| 370 | + 'de_DE' => 'chinesische', | |
| 371 | + 'es_ES' => 'lengua china', | |
| 372 | + 'it_IT' => 'cinese', | |
| 373 | + 'nl_NL' => 'chinese taal', | |
| 374 | + 'pl_PL' => 'Język chiński', | |
| 375 | + 'ru_RU' => 'китайский язык', | |
| 376 | + 'pt_PT' => 'Chinês', | |
| 377 | + 'pt_BR' => 'Chinês', | |
| 378 | + 'ja_JP' => 'ちゅうごくご', | |
| 379 | + 'cn_ZH' => '中文' | |
| 380 | + ), | |
| 381 | + 'assource' => 'ZH', | |
| 382 | + 'astarget' => 'ZH', | |
| 383 | + 'allcaps' => 'CN_ZH', | |
| 384 | + 'isocode' => 'ZH', | |
| 385 | + ), | |
| 386 | + ); | |
| 387 | + return apply_filters( __METHOD__, $languages ); | |
| 388 | + } | |
| 389 | +} | |
| 390 | + | |