Changeset 100689 in spip-zone
- Timestamp:
- Nov 26, 2016, 6:00:31 PM (3 years ago)
- Location:
- _plugins_/rainette/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/rainette/trunk/inc/charger_meteo.php
r97957 r100689 19 19 * périodicité est compatible avec le service; cette fonction ne retourne donc que des erreurs de chargement. 20 20 * 21 * @uses service2cache() 21 22 * @uses service2donnees() 22 23 * @uses indice2risque_uv() … … 89 90 90 91 // Construire le nom du fichier cache 91 $cacher = "${service}_service2cache";92 $cache = $cacher($lieu, $mode, $periodicite, $configuration);92 include_spip('inc/rainette_normaliser'); 93 $cache = service2cache($service, $lieu, $mode, $periodicite, $configuration); 93 94 94 95 // Déterminer le système d'unité utilisé dans le cache et celui requis par la configuration. … … 148 149 // -2- complément du tableau avec les données propres à chaque service 149 150 // -3- complément du tableau avec les données communes à tous les services 150 include_spip('inc/rainette_normaliser');151 151 foreach ($flux as $_index_jour => $_flux_jour) { 152 152 // Pour les informations et les conditions les données récupérées concernent toute la même "période". -
_plugins_/rainette/trunk/inc/rainette_debusquer.php
r100580 r100689 182 182 return $texte; 183 183 } 184 185 186 function trouver_langue_manquante() { 187 include_spip('inc/lang_liste'); 188 include_spip('inc/rainette_normaliser'); 189 foreach ($GLOBALS['codes_langues'] as $code => $langue) { 190 if (!array_key_exists($code, $GLOBALS['rainette_config']['langues_alternatives'])) { 191 echo "code manquant $code<br />"; 192 } 193 } 194 } -
_plugins_/rainette/trunk/inc/rainette_normaliser.php
r100584 r100689 26 26 $GLOBALS['rainette_config']['infos'] = array( 27 27 // Lieu 28 'ville' 29 'pays' 30 'pays_iso2' 31 'region' 28 'ville' => array('origine' => 'service', 'type_php' => 'string', 'type_unite' => '', 'groupe' => 'donnees_lieu'), 29 'pays' => array('origine' => 'service', 'type_php' => 'string', 'type_unite' => '', 'groupe' => 'donnees_lieu'), 30 'pays_iso2' => array('origine' => 'service', 'type_php' => 'string', 'type_unite' => '', 'groupe' => 'donnees_lieu'), 31 'region' => array('origine' => 'service', 'type_php' => 'string', 'type_unite' => '', 'groupe' => 'donnees_lieu'), 32 32 // Coordonnées géographiques 33 'longitude' 34 'latitude' 33 'longitude' => array('origine' => 'service', 'type_php' => 'float', 'type_unite' => 'angle', 'groupe' => 'donnees_coordonnees'), 34 'latitude' => array('origine' => 'service', 'type_php' => 'float', 'type_unite' => 'angle', 'groupe' => 'donnees_coordonnees'), 35 35 ); 36 36 … … 102 102 24 => array(24, 12), 103 103 12 => array(12), 104 1 => array(1, 3,6)104 1 => array(1, 3, 6) 105 105 ); 106 106 107 $GLOBALS['rainette_config']['langues_alternatives'] = array( 108 'aa' => array(), // afar 109 'ab' => array(), // abkhaze 110 'af' => array('en'), // afrikaans 111 'am' => array(), // amharique 112 'an' => array('es'), // aragonais 113 'ar' => array(), // arabe 114 'as' => array(), // assamais 115 'ast' => array('es'), // asturien - iso 639-2 116 'ay' => array(), // aymara 117 'az' => array('ru'), // azeri 118 'ba' => array(), // bashkir 119 'be' => array('ru'), // bielorusse 120 'ber_tam' => array('ar'), // berbère 121 'ber_tam_tfng' => array('ar'), // berbère tifinagh 122 'bg' => array(), // bulgare 123 'bh' => array(), // langues biharis 124 'bi' => array(), // bichlamar 125 'bm' => array(), // bambara 126 'bn' => array(), // bengali 127 'bo' => array(), // tibétain 128 'br' => array('fr'), // breton 129 'bs' => array(), // bosniaque 130 'ca' => array('es'), // catalan 131 'co' => array('fr'), // corse 132 'cpf' => array('fr'), // créole réunionais 133 'cpf_dom' => array('es'), // créole ??? 134 'cpf_hat' => array('fr'), // créole haïtien 135 'cs' => array(), // tchèque 136 'cy' => array('en'), // gallois 137 'da' => array(), // danois 138 'de' => array(), // allemand 139 'dz' => array(), // dzongkha 140 'el' => array(), // grec moderne 141 'en' => array(), // anglais 142 'en_hx' => array('en'), // anglais hacker 143 'en_sm' => array('en'), // anglais smurf 144 'eo' => array(), // esperanto 145 'es' => array(), // espagnol 146 'es_co' => array('es'), // espagnol colombien 147 'es_mx_pop' => array('es'), // espagnol mexicain 148 'et' => array(), // estonien 149 'eu' => array('fr'), // basque 150 'fa' => array(), // persan (farsi) 151 'ff' => array(), // peul 152 'fi' => array('sv'), // finnois 153 'fj' => array('en'), // fidjien 154 'fo' => array('da'), // féroïen 155 'fon' => array(), // fon 156 'fr' => array(), // français 157 'fr_fem' => array('fr'), // français féminin 158 'fr_sc' => array('fr'), // français schtroumpf 159 'fr_lpc' => array('fr'), // français langue parlée 160 'fr_lsf' => array('fr'), // français langue des signes 161 'fr_spl' => array('fr'), // français simplifié 162 'fr_tu' => array('fr'), // français copain 163 'fy' => array('de'), // frison occidental 164 'ga' => array('en'), // irlandais 165 'gd' => array('en'), // gaélique écossais 166 'gl' => array('es'), // galicien 167 'gn' => array(), // guarani 168 'grc' => array('el'), // grec ancien 169 'gu' => array(), // goudjrati 170 'ha' => array(), // haoussa 171 'hac' => array('ku'), // Kurdish-Horami 172 'hbo' => array('il'), // hebreu classique ou biblique 173 'he' => array(), // hébreu 174 'hi' => array(), // hindi 175 'hr' => array(), // croate 176 'hu' => array(), // hongrois 177 'hy' => array(), // armenien 178 'ia' => array(), // interlingua (langue auxiliaire internationale) 179 'id' => array(), // indonésien 180 'ie' => array(), // interlingue 181 'ik' => array(), // inupiaq 182 'is' => array(), // islandais 183 'it' => array(), // italien 184 'it_fem' => array('it'), // italien féminin 185 'iu' => array(), // inuktitut 186 'ja' => array(), // japonais 187 'jv' => array(), // javanais 188 'ka' => array(), // géorgien 189 'kk' => array(), // kazakh 190 'kl' => array('da'), // groenlandais 191 'km' => array(), // khmer central 192 'kn' => array(), // Kannada 193 'ko' => array(), // coréen 194 'kok' => array(), // konkani (macrolangage) 195 'ks' => array(), // kashmiri 196 'ku' => array(), // kurde 197 'ky' => array(), // kirghiz 198 'la' => array('fr'), // latin 199 'lb' => array('fr'), // luxembourgeois 200 'ln' => array(), // lingala 201 'lo' => array(), // lao 202 'lt' => array(), // lituanien 203 'lu' => array(), // luba-katanga 204 'lv' => array(), // letton 205 'man' => array(), // mandingue 206 'mfv' => array(), // manjaque - iso-639-3 207 'mg' => array('fr'), // malgache 208 'mi' => array(), // maori 209 'mk' => array(), // macédonien 210 'ml' => array(), // malayalam 211 'mn' => array('zh'), // mongol 212 'mo' => array('ro'), // moldave ??? normalement c'est ro comme le roumain 213 'mos' => array(), // moré - iso 639-2 214 'mr' => array(), // marathe 215 'ms' => array(), // malais 216 'mt' => array('en'), // maltais 217 'my' => array(), // birman 218 'na' => array(), // nauruan 219 'nap' => array('it'), // napolitain - iso 639-2 220 'ne' => array(), // népalais 221 'nqo' => array(), // n’ko - iso 639-3 222 'nl' => array(), // néerlandais 223 'no' => array(), // norvégien 224 'nb' => array('no'), // norvégien bokmål 225 'nn' => array('no'), // norvégien nynorsk 226 'oc' => array('fr'), // occitan 227 'oc_lnc' => array('oc', 'fr'), // occitan languedocien 228 'oc_ni' => array('oc', 'fr'), // occitan niçard 229 'oc_ni_la' => array('oc', 'fr'), // occitan niçard larg 230 'oc_ni_mis' => array('oc', 'fr'), // occitan niçard mistralenc 231 'oc_prv' => array('oc', 'fr'), // occitan provençal 232 'oc_gsc' => array('oc', 'fr'), // occitan gascon 233 'oc_lms' => array('oc', 'fr'), // occitan limousin 234 'oc_auv' => array('oc', 'fr'), // occitan auvergnat 235 'oc_va' => array('oc', 'fr'), // occitan vivaro-alpin 236 'om' => array(), // galla 237 'or' => array(), // oriya 238 'pa' => array(), // pendjabi 239 'pbb' => array(), // Nasa Yuwe (páez) - iso 639-3 240 'pl' => array(), // polonais 241 'prs' => array(), // Dari (Afghanistan) - iso 639-3 242 'ps' => array(), // pachto 243 'pt' => array(), // portugais 244 'pt_br' => array('pt'), // portugais brésilien 245 'qu' => array('es'), // quechua 246 'rm' => array('fr'), // romanche 247 'rn' => array(), // rundi 248 'ro' => array(), // roumain 249 'roa' => array('fr'), // langues romanes (ch'ti) - iso 639-2 250 'ru' => array(), // russe 251 'rw' => array(), // rwanda 252 'sa' => array(), // sanskrit 253 'sc' => array('it'), // sarde 254 'scn' => array('it'), // sicilien - iso 639-2 255 'sd' => array(), // sindhi 256 'sg' => array(), // sango 257 'sh' => array('sh'), // serbo-croate 258 'sh_latn' => array('sh'), // serbo-croate latin 259 'sh_cyrl' => array('sh'), // serbo-croate cyrillique 260 'si' => array(), // singhalais 261 'sk' => array(), // slovaque 262 'sl' => array(), // slovène 263 'sm' => array('en'), // samoan 264 'sn' => array(), // shona 265 'so' => array(), // somali 266 'sq' => array(), // albanais 267 'sr' => array(), // serbe 268 'src' => array('it'), // sarde logoudorien - iso 639-3 269 'sro' => array('it'), // sarde campidanien - iso 639-3 270 'ss' => array(), // swati 271 'st' => array(), // sotho du Sud 272 'su' => array(), // soundanais 273 'sv' => array(), // suédois 274 'sw' => array(), // swahili 275 'ta' => array(), // tamoul 276 'te' => array(), // télougou 277 'tg' => array(), // tadjik 278 'th' => array(), // thaï 279 'ti' => array(), // tigrigna 280 'tk' => array(), // turkmène 281 'tl' => array(), // tagalog 282 'tn' => array(), // tswana 283 'to' => array('en'), // tongan (Îles Tonga) 284 'tr' => array(), // turc 285 'ts' => array(), // tsonga 286 'tt' => array(), // tatar 287 'tw' => array(), // twi 288 'ty' => array('fr'), // tahitien 289 'ug' => array(), // ouïgour 290 'uk' => array('ru'), // ukrainien 291 'ur' => array(), // ourdou 292 'uz' => array(), // ouszbek 293 'vi' => array(), // vietnamien 294 'vo' => array(), // volapük 295 'wa' => array('fr'), // wallon 296 'wo' => array(), // wolof 297 'xh' => array(), // xhosa 298 'yi' => array('he'), // yiddish 299 'yo' => array(), // yoruba 300 'za' => array('zh'), // zhuang 301 'zh' => array(), // chinois (ecriture simplifiee) 302 'zh_tw' => array('zh'), // chinois taiwan (ecriture traditionnelle) 303 'zu' => array() // zoulou 304 ); 107 305 108 306 … … 125 323 foreach (array_keys($GLOBALS['rainette_config'][$mode]) as $_donnee) { 126 324 if ((($periode == -1) 127 and (empty($GLOBALS['rainette_config'][$mode][$_donnee]['rangement']) 128 or ($GLOBALS['rainette_config'][$mode][$_donnee]['rangement'] == 'jour'))) 129 or (($periode > -1) and ($GLOBALS['rainette_config'][$mode][$_donnee]['rangement'] == 'heure'))) { 325 and (empty($GLOBALS['rainette_config'][$mode][$_donnee]['rangement']) 326 or ($GLOBALS['rainette_config'][$mode][$_donnee]['rangement'] == 'jour'))) 327 or (($periode > -1) and ($GLOBALS['rainette_config'][$mode][$_donnee]['rangement'] == 'heure')) 328 ) { 130 329 if ($GLOBALS['rainette_config'][$mode][$_donnee]['origine'] == 'service') { 131 330 // La donnée est fournie par le service. Elle n'est jamais calculée par le plugin … … 289 488 290 489 if (isset($GLOBALS['rainette_config']['periodicite'][$type_modele]) 291 and in_array($periodicite, $GLOBALS['rainette_config']['periodicite'][$type_modele])) { 490 and in_array($periodicite, $GLOBALS['rainette_config']['periodicite'][$type_modele]) 491 ) { 292 492 $compatible = true; 293 493 } 294 494 295 495 return $compatible; 496 } 497 498 499 /** 500 * Construit le nom du cache en fonction du servide, du lieu, du type de données et de la langue utilisée par le site. 501 * 502 * @param string $service 503 * Le nom abrégé du service : 504 * - `weather` pour le weather.com, la valeur par défaut car elle ne nécessite aucune inscription 505 * - `wwo` pour World Weather Online 506 * - `wunderground` pour Wunderground 507 * - `owm` pour Open Weather Map 508 * @param string $lieu 509 * Lieu pour lequel on requiert le nom du cache. 510 * @param string $mode 511 * Type de données météorologiques. Les valeurs possibles sont `infos`, `conditions` ou `previsions`. 512 * @param int $periodicite 513 * La périodicité horaire des prévisions : 514 * - `24`, `12`, `6`, `3` ou `1`, pour le mode `previsions` 515 * - `0`, pour les modes `conditions` et `infos` 516 * @param array $config_service 517 * Configuration complète du service, statique et utilisateur. 518 * 519 * @return string 520 * Chemin complet du fichier cache. 521 */ 522 function service2cache($service, $lieu, $mode, $periodicite, $config_service) { 523 524 // Identification de la langue du resume. 525 $code_langue = trouver_langue_service($service, $config_service); 526 527 // Construction du chemin du fichier cache 528 $fichier_cache = normaliser_cache($service, $lieu, $mode, $periodicite, $code_langue); 529 530 return $fichier_cache; 531 } 532 533 534 function trouver_langue_service($service, $config_service) { 535 536 if ($config_service['condition'] == $service) { 537 // Langue SPIP : soit celle de la page soit celle en cours pour l'affichage 538 // TODO : cela a-t-il du sens ? 539 $langue_spip = $GLOBALS['lang'] ? $GLOBALS['lang'] : $GLOBALS['spip_lang']; 540 541 // On cherche si le service fournit la langue utilisée par le site. 542 // -- Pour cela on utilise la configuration du service qui fournit un tableau des langues disponibles 543 // sous le format [code de langue du service] = code de langue spip. 544 $langue_service = array_search($langue_spip, $config_service['langues']['disponibles']); 545 if ($langue_service === false) { 546 // La langue utilisée par SPIP n'est pas supportée par le service. 547 // -- On cherche si il existe une langue SPIP utilisable meilleure que la langue par défaut du service. 548 // -- Pour ce faire on a défini pour chaque code de langue spip, un ou deux codes de langue SPIP à utiliser 549 // en cas d'absence de la langue concernée dans un ordre de priorité (index 0, puis index 1). 550 $langue_service = $config_service['langues']['defaut']; 551 if ($GLOBALS['rainette_config']['langues_alternatives'][$langue_spip]) { 552 foreach ($GLOBALS['rainette_config']['langues_alternatives'][$langue_spip] as $_langue_alternative) { 553 $langue_service = array_search($_langue_alternative, $config_service['langues']['disponibles']); 554 if ($langue_service !== false) { 555 break; 556 } 557 } 558 } 559 } 560 } else { 561 $langue_service = $config_service['langues']['defaut']; 562 } 563 564 return $langue_service; 565 } 566 567 568 function normaliser_cache($service, $lieu, $mode, $periodicite, $code_langue) { 569 570 // Création et/ou détermination du dossier de destination du cache en fonction du service 571 $dossier_cache = sous_repertoire(_DIR_CACHE, 'rainette'); 572 $dossier_cache = sous_repertoire($dossier_cache, $service); 573 574 // Le nom du fichier cache est composé comme suit, chaque élement étant séparé par un underscore : 575 // -- le nom du lieu normalisé (sans espace et dont tous les caractères non alphanumériques sont remplacés par un tiret 576 // -- le nom du mode (infos, conditions ou previsions) accolé à la périodicité du cache pour les prévisions uniquement 577 // -- la langue du résumé si il existe ou rien si aucune traduction n'est fournie par le service 578 list($lieu_normalise,) = normaliser_lieu($lieu); 579 $fichier_cache = $dossier_cache 580 . str_replace(array(' ', ',', '+', '.', '/'), '-', $lieu_normalise) 581 . '_' . $mode 582 . ($periodicite ? strval($periodicite) : '') 583 . ($code_langue ? '_' . strtolower($code_langue) : '') 584 . '.txt'; 585 586 return $fichier_cache; 296 587 } 297 588 … … 321 612 return array($lieu_normalise, $format_lieu); 322 613 } 323 324 325 function normaliser_cache($service, $lieu, $mode, $periodicite, $code_langue) {326 327 // Création et/ou détermination du dossier de destination du cache en fonction du service328 $dossier_cache = sous_repertoire(_DIR_CACHE, 'rainette');329 $dossier_cache = sous_repertoire($dossier_cache, $service);330 331 // Le nom du fichier cache est composé comme suit, chaque élement étant séparé par un underscore :332 // -- le nom du lieu normalisé (sans espace et dont tous les caractères non alphanumériques sont remplacés par un tiret333 // -- le nom du mode (infos, conditions ou previsions) accolé à la périodicité du cache pour les prévisions uniquement334 // -- la langue du résumé si il existe ou rien si aucune traduction n'est fournie par le service335 list($lieu_normalise,) = normaliser_lieu($lieu);336 $fichier_cache = $dossier_cache337 . str_replace(array(' ', ',', '+', '.', '/'), '-', $lieu_normalise)338 . '_' . $mode339 . ($periodicite ? strval($periodicite) : '')340 . ($code_langue ? '_' . strtolower($code_langue) : '')341 . '.txt';342 343 return $fichier_cache;344 } -
_plugins_/rainette/trunk/paquet.xml
r100584 r100689 2 2 prefix="rainette" 3 3 categorie="divers" 4 version="3.0.1 7"4 version="3.0.18" 5 5 etat="test" 6 6 compatibilite="]3.1.3;3.2.*]" -
_plugins_/rainette/trunk/services/owm.php
r100584 r100689 32 32 'lien' => 'http://openweathermap.org/', 33 33 ), 34 'langue_service' => 'EN' 34 'langues' => array( 35 'disponibles' => array( 36 'bg' => 'bg', 37 'ca' => 'ca', 38 'de' => 'de', 39 'en' => 'en', 40 'es' => 'es', 41 'fi' => 'fi', 42 'fr' => 'fr', 43 'hr' => 'hr', 44 'it' => 'it', 45 'nl' => 'nl', 46 'pl' => 'pl', 47 'pt' => 'pt', 48 'ro' => 'ro', 49 'ru' => 'ru', 50 'sv' => 'sv', 51 'tr' => 'tr', 52 'uk' => 'uk', 53 'zh' => 'zh', 54 'zh_tw' => 'zh_tw', 55 ), 56 'defaut' => 'en' 57 ) 35 58 ); 36 59 … … 155 178 } 156 179 157 /**158 * @param string $lieu159 * @param string $mode160 * @param $periodicite161 * @param $configuration162 *163 * @return string164 */165 function owm_service2cache($lieu, $mode, $periodicite, $configuration) {166 167 // Identification de la langue du resume.168 $code_langue = ($configuration['condition'] == 'owm')169 ? langue2code_owm($GLOBALS['spip_lang'])170 : $configuration['langue_service'];171 172 // Construction du chemin du fichier cache173 include_spip('inc/rainette_normaliser');174 $fichier_cache = normaliser_cache('owm', $lieu, $mode, $periodicite, $code_langue);175 176 return $fichier_cache;177 }178 180 179 181 /** … … 196 198 // Le choix de la langue n'a d'interet que si on utilise le resume natif du service. Si ce n'est pas le cas 197 199 // on ne la precise pas et on laisse l'API renvoyer la langue par defaut 198 $code_langue = ($configuration['condition'] == 'owm') 199 ? langue2code_owm($GLOBALS['spip_lang']) 200 : $configuration['langue_service']; 200 include_spip('inc/rainette_normaliser'); 201 $code_langue = trouver_langue_service('owm', $configuration); 201 202 202 203 // On normalise le lieu et on récupère son format. 203 204 // Le service accepte la format ville,pays et le format latitude,longitude 204 include_spip('inc/rainette_normaliser');205 205 list($lieu_normalise, $format_lieu) = normaliser_lieu($lieu); 206 206 if ($format_lieu == 'latitude_longitude') { … … 226 226 } 227 227 228 228 229 /** 229 230 * @param array $tableau … … 237 238 return $tableau; 238 239 } 240 239 241 240 242 /** … … 392 394 return $icone; 393 395 } 394 395 /**396 * @param $langue397 *398 * @return string399 */400 function langue2code_owm($langue) {401 static $langue2owm = array(402 'aa' => array('', ''), // afar403 'ab' => array('', ''), // abkhaze404 'af' => array('', ''), // afrikaans405 'am' => array('', ''), // amharique406 'an' => array('', 'sp'), // aragonais407 'ar' => array('', ''), // arabe408 'as' => array('', ''), // assamais409 'ast' => array('', 'sp'), // asturien - iso 639-2410 'ay' => array('', ''), // aymara411 'az' => array('', 'ru'), // azeri412 'ba' => array('', ''), // bashkir413 'be' => array('', 'ru'), // bielorusse414 'ber_tam' => array('', ''), // berbère415 'ber_tam_tfng' => array('', ''), // berbère tifinagh416 'bg' => array('bg', ''), // bulgare417 'bh' => array('', ''), // langues biharis418 'bi' => array('', ''), // bichlamar419 'bm' => array('', ''), // bambara420 'bn' => array('', ''), // bengali421 'bo' => array('', ''), // tibétain422 'br' => array('', 'fr'), // breton423 'bs' => array('', ''), // bosniaque424 'ca' => array('', 'sp'), // catalan425 'co' => array('', 'fr'), // corse426 'cpf' => array('', 'fr'), // créole réunionais427 'cpf_dom' => array('', 'sp'), // créole ???428 'cpf_hat' => array('', 'fr'), // créole haïtien429 'cs' => array('cz', ''), // tchèque430 'cy' => array('', 'en'), // gallois431 'da' => array('', ''), // danois432 'de' => array('de', ''), // allemand433 'dz' => array('', ''), // dzongkha434 'el' => array('', ''), // grec moderne435 'en' => array('en', ''), // anglais436 'en_hx' => array('', 'en'), // anglais hacker437 'en_sm' => array('', 'en'), // anglais smurf438 'eo' => array('', ''), // esperanto439 'es' => array('sp', ''), // espagnol440 'es_co' => array('', 'sp'), // espagnol colombien441 'es_mx_pop' => array('', 'sp'), // espagnol mexicain442 'et' => array('', ''), // estonien443 'eu' => array('', 'fr'), // basque444 'fa' => array('', ''), // persan (farsi)445 'ff' => array('', ''), // peul446 'fi' => array('fi', ''), // finnois447 'fj' => array('', 'en'), // fidjien448 'fo' => array('', ''), // féroïen449 'fon' => array('', ''), // fon450 'fr' => array('fr', ''), // français451 'fr_sc' => array('', 'fr'), // français schtroumpf452 'fr_lpc' => array('', 'fr'), // français langue parlée453 'fr_lsf' => array('', 'fr'), // français langue des signes454 'fr_spl' => array('', 'fr'), // français simplifié455 'fr_tu' => array('', 'fr'), // français copain456 'fy' => array('', 'de'), // frison occidental457 'ga' => array('', 'en'), // irlandais458 'gd' => array('', 'en'), // gaélique écossais459 'gl' => array('', 'sp'), // galicien460 'gn' => array('', ''), // guarani461 'grc' => array('', ''), // grec ancien462 'gu' => array('', ''), // goudjrati463 'ha' => array('', ''), // haoussa464 'hac' => array('', ''), // Kurdish-Horami465 'hbo' => array('', ''), // hebreu classique ou biblique466 'he' => array('', ''), // hébreu467 'hi' => array('', ''), // hindi468 'hr' => array('', ''), // croate469 'hu' => array('', ''), // hongrois470 'hy' => array('', ''), // armenien471 'ia' => array('', ''), // interlingua (langue auxiliaire internationale)472 'id' => array('', ''), // indonésien473 'ie' => array('', ''), // interlingue474 'ik' => array('', ''), // inupiaq475 'is' => array('', ''), // islandais476 'it' => array('it', ''), // italien477 'it_fem' => array('', 'it'), // italien féminin478 'iu' => array('', ''), // inuktitut479 'ja' => array('', ''), // japonais480 'jv' => array('', ''), // javanais481 'ka' => array('', ''), // géorgien482 'kk' => array('', ''), // kazakh483 'kl' => array('', ''), // groenlandais484 'km' => array('', ''), // khmer central485 'kn' => array('', ''), // Kannada486 'ko' => array('', ''), // coréen487 'ks' => array('', ''), // kashmiri488 'ku' => array('', ''), // kurde489 'ky' => array('', ''), // kirghiz490 'la' => array('', ''), // latin491 'lb' => array('', 'fr'), // luxembourgeois492 'ln' => array('', ''), // lingala493 'lo' => array('', ''), // lao494 'lt' => array('', ''), // lituanien495 'lu' => array('', ''), // luba-katanga496 'lv' => array('', ''), // letton497 'man' => array('', ''), // mandingue498 'mfv' => array('', ''), // manjaque - iso-639-3499 'mg' => array('', ''), // malgache500 'mi' => array('', ''), // maori501 'mk' => array('', ''), // macédonien502 'ml' => array('', ''), // malayalam503 'mn' => array('', ''), // mongol504 'mo' => array('', 'ro'), // moldave ??? normalement c'est ro comme le roumain505 'mos' => array('', ''), // moré - iso 639-2506 'mr' => array('', ''), // marathe507 'ms' => array('', ''), // malais508 'mt' => array('', 'en'), // maltais509 'my' => array('', ''), // birman510 'na' => array('', ''), // nauruan511 'nap' => array('', 'it'), // napolitain - iso 639-2512 'ne' => array('', ''), // népalais513 'nqo' => array('', ''), // n’ko - iso 639-3514 'nl' => array('nl', ''), // néerlandais515 'no' => array('', ''), // norvégien516 'nb' => array('', ''), // norvégien bokmål517 'nn' => array('', ''), // norvégien nynorsk518 'oc' => array('', 'fr'), // occitan519 'oc_lnc' => array('', 'fr'), // occitan languedocien520 'oc_ni' => array('', 'fr'), // occitan niçard521 'oc_ni_la' => array('', 'fr'), // occitan niçard522 'oc_prv' => array('', 'fr'), // occitan provençal523 'oc_gsc' => array('', 'fr'), // occitan gascon524 'oc_lms' => array('', 'fr'), // occitan limousin525 'oc_auv' => array('', 'fr'), // occitan auvergnat526 'oc_va' => array('', 'fr'), // occitan vivaro-alpin527 'om' => array('', ''), // galla528 'or' => array('', ''), // oriya529 'pa' => array('', ''), // pendjabi530 'pbb' => array('', ''), // Nasa Yuwe (páez) - iso 639-3531 'pl' => array('pl', ''), // polonais532 'ps' => array('', ''), // pachto533 'pt' => array('pt', ''), // portugais534 'pt_br' => array('', 'pt'), // portugais brésilien535 'qu' => array('', ''), // quechua536 'rm' => array('', ''), // romanche537 'rn' => array('', ''), // rundi538 'ro' => array('ro', ''), // roumain539 'roa' => array('', 'fr'), // langues romanes (ch'ti) - iso 639-2540 'ru' => array('ru', ''), // russe541 'rw' => array('', ''), // rwanda542 'sa' => array('', ''), // sanskrit543 'sc' => array('', 'it'), // sarde544 'scn' => array('', 'it'), // sicilien - iso 639-2545 'sd' => array('', ''), // sindhi546 'sg' => array('', ''), // sango547 'sh' => array('', ''), // serbo-croate548 'sh_latn' => array('', ''), // serbo-croate latin549 'sh_cyrl' => array('', ''), // serbo-croate cyrillique550 'si' => array('', ''), // singhalais551 'sk' => array('', ''), // slovaque552 'sl' => array('', ''), // slovène553 'sm' => array('', 'en'), // samoan554 'sn' => array('', ''), // shona555 'so' => array('', ''), // somali556 'sq' => array('', ''), // albanais557 'sr' => array('', ''), // serbe558 'src' => array('', 'it'), // sarde logoudorien - iso 639-3559 'sro' => array('', 'it'), // sarde campidanien - iso 639-3560 'ss' => array('', ''), // swati561 'st' => array('', ''), // sotho du Sud562 'su' => array('', ''), // soundanais563 'sv' => array('se', ''), // suédois564 'sw' => array('', ''), // swahili565 'ta' => array('', ''), // tamoul566 'te' => array('', ''), // télougou567 'tg' => array('', ''), // tadjik568 'th' => array('', ''), // thaï569 'ti' => array('', ''), // tigrigna570 'tk' => array('', ''), // turkmène571 'tl' => array('', ''), // tagalog572 'tn' => array('', ''), // tswana573 'to' => array('', ''), // tongan (Îles Tonga)574 'tr' => array('tr', ''), // turc575 'ts' => array('', ''), // tsonga576 'tt' => array('', ''), // tatar577 'tw' => array('', ''), // twi578 'ty' => array('', 'fr'), // tahitien579 'ug' => array('', ''), // ouïgour580 'uk' => array('ua', ''), // ukrainien581 'ur' => array('', ''), // ourdou582 'uz' => array('', ''), // ouszbek583 'vi' => array('', ''), // vietnamien584 'vo' => array('', ''), // volapük585 'wa' => array('', 'fr'), // wallon586 'wo' => array('', ''), // wolof587 'xh' => array('', ''), // xhosa588 'yi' => array('', ''), // yiddish589 'yo' => array('', ''), // yoruba590 'za' => array('', 'zh_cn'), // zhuang591 'zh' => array('zh_cn', ''), // chinois (ecriture simplifiee)592 'zh_tw' => array('zh_tw', ''), // chinois taiwan (ecriture traditionnelle)593 'zu' => array('', '') // zoulou594 );595 596 $code = $GLOBALS['rainette_owm_config']['service']['langue_service'];597 if (array_key_exists($langue, $langue2owm)) {598 if ($c0 = $langue2owm[$langue][0]) {599 $code = strtolower($c0);600 } elseif ($c1 = $langue2owm[$langue][1]) {601 $code = strtolower($c1);602 }603 }604 605 return $code;606 } -
_plugins_/rainette/trunk/services/weather.php
r100584 r100689 29 29 'lien' => 'http://www.weather.com/', 30 30 ), 31 'langue_service' => 'en' 31 'langues' => array( 32 'disponibles' => array(), 33 'defaut' => 'en' 34 ) 32 35 ); 33 36 … … 151 154 * @return string 152 155 */ 153 function weather_service2cache($lieu, $mode, $periodicite, $configuration) {154 155 // Identification de la langue du resume : pas de traduction pour ce service156 // le résumé est toujours en anglais.157 $code_langue = $configuration['langue_service'];158 159 // Construction du chemin du fichier cache160 include_spip('inc/rainette_normaliser');161 $fichier_cache = normaliser_cache('weather', $lieu, $mode, $periodicite, $code_langue);162 return $fichier_cache;163 }164 165 166 /**167 * @param $lieu168 * @param $mode169 * @param $periodicite170 * @param $configuration171 *172 * @return string173 */174 156 function weather_service2url($lieu, $mode, $periodicite, $configuration) { 175 157 -
_plugins_/rainette/trunk/services/wunderground.php
r100584 r100689 27 27 // Ces valeurs sont applicables à tous les modes. 28 28 $GLOBALS['rainette_wunderground_config']['service'] = array( 29 'defauts' 29 'defauts' => array( 30 30 'inscription' => '', 31 31 'unite' => 'm', … … 33 33 'theme' => 'a', 34 34 ), 35 'credits' => array( 36 'titre' => null, 37 'logo' => 'wunderground-126.png', 38 'lien' => 'http://www.wunderground.com/', 39 ), 40 'langue_service' => 'EN' 35 'credits' => array( 36 'titre' => null, 37 'logo' => 'wunderground-126.png', 38 'lien' => 'http://www.wunderground.com/', 39 ), 40 'langues' => array( 41 'disponibles' => array( 42 'AF' => 'af', 43 'AR' => 'ar', 44 'AZ' => 'az', 45 'BY' => 'be', 46 'BU' => 'bg', 47 'CA' => 'ca', 48 'HT' => 'cpf_hat', 49 'CZ' => 'cs', 50 'CY' => 'cy', 51 'DK' => 'da', 52 'DL' => 'de', 53 'GR' => 'el', 54 'EN' => 'en', 55 'EO' => 'eo', 56 'SP' => 'es', 57 'ET' => 'et', 58 'EU' => 'eu', 59 'FA' => 'fa', 60 'FI' => 'fi', 61 'FR' => 'fr', 62 'IR' => 'ga', 63 'GZ' => 'gl', 64 'GU' => 'gu', 65 'IL' => 'he', 66 'HI' => 'hi', 67 'CR' => 'hr', 68 'HU' => 'hu', 69 'HY' => 'hy', 70 'ID' => 'id', 71 'IS' => 'is', 72 'IT' => 'it', 73 'JP' => 'ja', 74 'JW' => 'jv', 75 'KA' => 'ka', 76 'KM' => 'km', 77 'KR' => 'ko', 78 'KU' => 'ku', 79 'LA' => 'la', 80 'LT' => 'lt', 81 'LV' => 'lv', 82 'GM' => 'man', 83 'MI' => 'mi', 84 'MK' => 'mk', 85 'MN' => 'mn', 86 'MR' => 'mr', 87 'MT' => 'mt', 88 'MY' => 'my', 89 'NL' => 'nl', 90 'NO' => 'no', 91 'OC' => 'oc', 92 'PA' => 'pa', 93 'PL' => 'pl', 94 'PS' => 'ps', 95 'BR' => 'pt', 96 'RO' => 'ro', 97 'RU' => 'ru', 98 'SK' => 'sk', 99 'SL' => 'sl', 100 'AL' => 'sq', 101 'SR' => 'sr', 102 'SW' => 'sv', 103 'SI' => 'sw', 104 'TH' => 'th', 105 'TK' => 'tk', 106 'TL' => 'tl', 107 'TR' => 'tr', 108 'TT' => 'tt', 109 'UA' => 'uk', 110 'UZ' => 'uz', 111 'VU' => 'vi', 112 'SN' => 'wo', 113 'YI' => 'yi', 114 'CN' => 'zh', 115 'TW' => 'zh_tw', 116 ), 117 'defaut' => 'EN' 118 ) 41 119 ); 42 120 … … 161 239 162 240 /** 163 * Construit le nom du cache en fonction du lieu, du type de données et de la langue utilisée par le site.164 *165 * @api166 *167 * @param string $lieu168 * Lieu pour lequel on requiert le nom du cache.169 * @param string $mode170 * Type de données météorologiques. Les valeurs possibles sont `infos`, `conditions` ou `previsions`.171 * @param int $periodicite172 * La périodicité horaire des prévisions :173 * - `24`, ou `1`, pour le mode `previsions`174 * - `0`, pour les modes `conditions` et `infos`175 * @param array $configuration176 * Configuration complète du service, statique et utilisateur.177 *178 * @return string179 * Chemin complet du fichier cache.180 */181 function wunderground_service2cache($lieu, $mode, $periodicite, $configuration) {182 183 // Identification de la langue du resume.184 $code_langue = ($configuration['condition'] == 'wunderground')185 ? langue2code_wunderground($GLOBALS['spip_lang'])186 : $configuration['langue_service'];187 188 // Construction du chemin du fichier cache189 include_spip('inc/rainette_normaliser');190 $fichier_cache = normaliser_cache('wunderground', $lieu, $mode, $periodicite, $code_langue);191 192 return $fichier_cache;193 }194 195 /**196 241 * Contruit l'url de la requête en fonction du lieu, du mode et de la périodicité demandés. 197 242 * … … 251 296 // Le choix de la langue n'a d'interet que si on utilise le resume natif du service. Si ce n'est pas 252 297 // le cas on demande à l'API de renvoyer la langue par defaut 253 $code_langue = ($configuration['condition'] == 'wunderground') 254 ? langue2code_wunderground($GLOBALS['spip_lang']) 255 : $configuration['langue_service']; 298 $code_langue = trouver_langue_service('wunderground', $configuration); 256 299 257 300 $url = _RAINETTE_WUNDERGROUND_URL_BASE_REQUETE … … 452 495 return $icone; 453 496 } 454 455 /**456 * @param $langue457 *458 * @return string459 */460 function langue2code_wunderground($langue) {461 static $langue2wunderground = array(462 'aa' => array('', ''), // afar463 'ab' => array('', ''), // abkhaze464 'af' => array('AF', ''), // afrikaans465 'am' => array('', ''), // amharique466 'an' => array('', 'SP'), // aragonais467 'ar' => array('AR', ''), // arabe468 'as' => array('', ''), // assamais469 'ast' => array('', 'SP'), // asturien - iso 639-2470 'ay' => array('', ''), // aymara471 'az' => array('AZ', ''), // azeri472 'ba' => array('', ''), // bashkir473 'be' => array('BY', ''), // bielorusse474 'ber_tam' => array('', ''), // berbère475 'ber_tam_tfng' => array('', ''), // berbère tifinagh476 'bg' => array('BU', ''), // bulgare477 'bh' => array('', ''), // langues biharis478 'bi' => array('', ''), // bichlamar479 'bm' => array('', ''), // bambara480 'bn' => array('', ''), // bengali481 'bo' => array('', ''), // tibétain482 'br' => array('', 'FR'), // breton483 'bs' => array('', ''), // bosniaque484 'ca' => array('CA', ''), // catalan485 'co' => array('', 'FR'), // corse486 'cpf' => array('', 'FR'), // créole réunionais487 'cpf_dom' => array('', 'FR'), // créole ???488 'cpf_hat' => array('HT', ''), // créole haïtien489 'cs' => array('CZ', ''), // tchèque490 'cy' => array('CY', ''), // gallois491 'da' => array('DK', ''), // danois492 'de' => array('DL', ''), // allemand493 'dz' => array('', ''), // dzongkha494 'el' => array('GR', ''), // grec moderne495 'en' => array('EN', ''), // anglais496 'en_hx' => array('', 'EN'), // anglais hacker497 'en_sm' => array('', 'EN'), // anglais smurf498 'eo' => array('EO', ''), // esperanto499 'es' => array('SP', ''), // espagnol500 'es_co' => array('', 'SP'), // espagnol colombien501 'es_mx_pop' => array('', 'SP'), // espagnol mexicain502 'et' => array('ET', ''), // estonien503 'eu' => array('EU', ''), // basque504 'fa' => array('FA', ''), // persan (farsi)505 'ff' => array('', ''), // peul506 'fi' => array('FI', ''), // finnois507 'fj' => array('', 'EN'), // fidjien508 'fo' => array('', 'DK'), // féroïen509 'fon' => array('', ''), // fon510 'fr' => array('FR', ''), // français511 'fr_sc' => array('', 'FR'), // français schtroumpf512 'fr_lpc' => array('', 'FR'), // français langue parlée513 'fr_lsf' => array('', 'FR'), // français langue des signes514 'fr_spl' => array('', 'FR'), // français simplifié515 'fr_tu' => array('', 'FR'), // français copain516 'fy' => array('', 'DL'), // frison occidental517 'ga' => array('IR', ''), // irlandais518 'gd' => array('', 'EN'), // gaélique écossais519 'gl' => array('GZ', ''), // galicien520 'gn' => array('', ''), // guarani521 'grc' => array('', 'GR'), // grec ancien522 'gu' => array('GU', ''), // goudjrati523 'ha' => array('', ''), // haoussa524 'hac' => array('', 'KU'), // Kurdish-Horami525 'hbo' => array('', 'IL'), // hebreu classique ou biblique526 'he' => array('IL', ''), // hébreu527 'hi' => array('HI', ''), // hindi528 'hr' => array('CR', ''), // croate529 'hu' => array('HU', ''), // hongrois530 'hy' => array('HY', ''), // armenien531 'ia' => array('', ''), // interlingua (langue auxiliaire internationale)532 'id' => array('ID', ''), // indonésien533 'ie' => array('', ''), // interlingue534 'ik' => array('', ''), // inupiaq535 'is' => array('IS', ''), // islandais536 'it' => array('IT', ''), // italien537 'it_fem' => array('', 'IT'), // italien féminin538 'iu' => array('', ''), // inuktitut539 'ja' => array('JP', ''), // japonais540 'jv' => array('JW', ''), // javanais541 'ka' => array('KA', ''), // géorgien542 'kk' => array('', ''), // kazakh543 'kl' => array('', 'DK'), // groenlandais544 'km' => array('KM', ''), // khmer central545 'kn' => array('', ''), // Kannada546 'ko' => array('KR', ''), // coréen547 'ks' => array('', ''), // kashmiri548 'ku' => array('KU', ''), // kurde549 'ky' => array('', ''), // kirghiz550 'la' => array('LA', ''), // latin551 'lb' => array('', 'FR'), // luxembourgeois552 'ln' => array('', ''), // lingala553 'lo' => array('', ''), // lao554 'lt' => array('LT', ''), // lituanien555 'lu' => array('', ''), // luba-katanga556 'lv' => array('LV', ''), // letton557 'man' => array('GM', ''), // mandingue558 'mfv' => array('', ''), // manjaque - iso-639-3559 'mg' => array('', ''), // malgache560 'mi' => array('MI', ''), // maori561 'mk' => array('MK', ''), // macédonien562 'ml' => array('', ''), // malayalam563 'mn' => array('MN', ''), // mongol564 'mo' => array('', 'RO'), // moldave ??? normalement c'est ro comme le roumain565 'mos' => array('', ''), // moré - iso 639-2566 'mr' => array('MR', ''), // marathe567 'ms' => array('', ''), // malais568 'mt' => array('MT', ''), // maltais569 'my' => array('MY', ''), // birman570 'na' => array('', ''), // nauruan571 'nap' => array('', 'IT'), // napolitain - iso 639-2572 'ne' => array('', ''), // népalais573 'nqo' => array('', ''), // n’ko - iso 639-3574 'nl' => array('NL', ''), // néerlandais575 'no' => array('NO', ''), // norvégien576 'nb' => array('', 'NO'), // norvégien bokmål577 'nn' => array('', 'NO'), // norvégien nynorsk578 'oc' => array('OC', ''), // occitan579 'oc_lnc' => array('', 'OC'), // occitan languedocien580 'oc_ni' => array('', 'OC'), // occitan niçard581 'oc_ni_la' => array('', 'OC'), // occitan niçard582 'oc_prv' => array('', 'OC'), // occitan provençal583 'oc_gsc' => array('', 'OC'), // occitan gascon584 'oc_lms' => array('', 'OC'), // occitan limousin585 'oc_auv' => array('', 'OC'), // occitan auvergnat586 'oc_va' => array('', 'OC'), // occitan vivaro-alpin587 'om' => array('', ''), // galla588 'or' => array('', ''), // oriya589 'pa' => array('PA', ''), // pendjabi590 'pbb' => array('', ''), // Nasa Yuwe (páez) - iso 639-3591 'pl' => array('PL', ''), // polonais592 'ps' => array('PS', ''), // pachto593 'pt' => array('BR', ''), // portugais594 'pt_br' => array('', 'BR'), // portugais brésilien595 'qu' => array('', ''), // quechua596 'rm' => array('', ''), // romanche597 'rn' => array('', ''), // rundi598 'ro' => array('RO', ''), // roumain599 'roa' => array('chti', ''), // langues romanes (ch'ti) - iso 639-2600 'ru' => array('RU', ''), // russe601 'rw' => array('', ''), // rwanda602 'sa' => array('', ''), // sanskrit603 'sc' => array('', 'IT'), // sarde604 'scn' => array('', 'IT'), // sicilien - iso 639-2605 'sd' => array('', ''), // sindhi606 'sg' => array('', ''), // sango607 'sh' => array('', 'SR'), // serbo-croate608 'sh_latn' => array('', 'SR'), // serbo-croate latin609 'sh_cyrl' => array('', 'SR'), // serbo-croate cyrillique610 'si' => array('', ''), // singhalais611 'sk' => array('SK', ''), // slovaque612 'sl' => array('SL', ''), // slovène613 'sm' => array('', ''), // samoan614 'sn' => array('', ''), // shona615 'so' => array('', ''), // somali616 'sq' => array('AL', ''), // albanais617 'sr' => array('SR', ''), // serbe618 'src' => array('', 'IT'), // sarde logoudorien - iso 639-3619 'sro' => array('', 'IT'), // sarde campidanien - iso 639-3620 'ss' => array('', ''), // swati621 'st' => array('', ''), // sotho du Sud622 'su' => array('', ''), // soundanais623 'sv' => array('SW', ''), // suédois624 'sw' => array('SI', ''), // swahili625 'ta' => array('', ''), // tamoul626 'te' => array('', ''), // télougou627 'tg' => array('', ''), // tadjik628 'th' => array('TH', ''), // thaï629 'ti' => array('', ''), // tigrigna630 'tk' => array('TK', ''), // turkmène631 'tl' => array('TL', ''), // tagalog632 'tn' => array('', ''), // tswana633 'to' => array('', ''), // tongan (Îles Tonga)634 'tr' => array('TR', ''), // turc635 'ts' => array('', ''), // tsonga636 'tt' => array('TT', ''), // tatar637 'tw' => array('', ''), // twi638 'ty' => array('', 'FR'), // tahitien639 'ug' => array('', ''), // ouïgour640 'uk' => array('UA', ''), // ukrainien641 'ur' => array('', ''), // ourdou642 'uz' => array('UZ', ''), // ouszbek643 'vi' => array('VU', ''), // vietnamien644 'vo' => array('', ''), // volapük645 'wa' => array('', 'FR'), // wallon646 'wo' => array('SN', ''), // wolof647 'xh' => array('', ''), // xhosa648 'yi' => array('YI', ''), // yiddish649 'yo' => array('', ''), // yoruba650 'za' => array('', 'CN'), // zhuang651 'zh' => array('CN', ''), // chinois (ecriture simplifiee)652 'zh_tw' => array('TW', ''), // chinois taiwan (ecriture traditionnelle)653 'zu' => array('', '') // zoulou654 );655 656 $code = $GLOBALS['rainette_wunderground_config']['service']['langue_service'];657 if (array_key_exists($langue, $langue2wunderground)) {658 if ($c0 = $langue2wunderground[$langue][0]) {659 $code = strtoupper($c0);660 } elseif ($c1 = $langue2wunderground[$langue][1]) {661 $code = strtoupper($c1);662 }663 }664 665 return $code;666 } -
_plugins_/rainette/trunk/services/wwo.php
r100584 r100689 30 30 'lien' => 'http://www.worldweatheronline.com/', 31 31 ), 32 'langue_service' => 'en', 32 'langues' => array( 33 'disponibles' => array( 34 'ar' => 'ar', 35 'bg' => 'bg', 36 'bn' => 'bn', 37 'cs' => 'cs', 38 'da' => 'da', 39 'de' => 'de', 40 'el' => 'el', 41 'en' => 'en', 42 'es' => 'es', 43 'fi' => 'fi', 44 'fr' => 'fr', 45 'hi' => 'hi', 46 'hu' => 'hu', 47 'it' => 'it', 48 'ja' => 'ja', 49 'jv' => 'jv', 50 'ko' => 'ko', 51 'mr' => 'mr', 52 'nl' => 'nl', 53 'pa' => 'pa', 54 'pl' => 'pl', 55 'pt' => 'pt', 56 'ro' => 'ro', 57 'ru' => 'ru', 58 'si' => 'si', 59 'sk' => 'sk', 60 'sr' => 'sr', 61 'sv' => 'sv', 62 'ta' => 'ta', 63 'te' => 'te', 64 'tr' => 'tr', 65 'uk' => 'uk', 66 'ur' => 'ur', 67 'vi' => 'vi', 68 'zh' => 'zh', 69 'zh_tw' => 'zh_tw', 70 'zu' => 'zu', 71 ), 72 'defaut' => 'en' 73 ) 33 74 ); 34 75 … … 162 203 163 204 /** 164 * Construit le nom du cache en fonction du lieu, du type de données et de la langue utilisée par le site.165 *166 * @api167 *168 * @param string $lieu169 * Lieu pour lequel on requiert le nom du cache.170 * @param string $mode171 * Type de données météorologiques. Les valeurs possibles sont `infos`, `conditions` ou `previsions`.172 * @param int $periodicite173 * La périodicité horaire des prévisions :174 * - `24`, `12`, `6`, `3` ou `1`, pour le mode `previsions`175 * - `0`, pour les modes `conditions` et `infos`176 * @param array $configuration177 * Configuration complète du service, statique et utilisateur.178 *179 * @return string180 * Chemin complet du fichier cache.181 */182 function wwo_service2cache($lieu, $mode, $periodicite, $configuration) {183 184 // Identification de la langue du resume.185 $code_langue = ($configuration['condition'] == 'wwo')186 ? langue2code_wwo($GLOBALS['spip_lang'])187 : $configuration['langue_service'];188 189 // Construction du chemin du fichier cache190 include_spip('inc/rainette_normaliser');191 $fichier_cache = normaliser_cache('wwo', $lieu, $mode, $periodicite, $code_langue);192 193 return $fichier_cache;194 }195 196 197 /**198 205 * Construit l'url de la requête correspondant au lieu, au type de données et à la configuration utilisateur 199 206 * du service (par exemple, le code d'inscription, le format des résultats...). … … 219 226 220 227 // Identification de la langue du resume. 221 $code_langue = ($configuration['condition'] == 'wwo') 222 ? langue2code_wwo($GLOBALS['spip_lang']) 223 : $configuration['langue_service']; 228 include_spip('inc/rainette_normaliser'); 229 $code_langue = trouver_langue_service('wwo', $configuration); 224 230 225 231 // On normalise le lieu et on récupère son format. 226 232 // Le service accepte la format ville,pays, le format latitude,longitude et le format adresse IP. 227 233 // Néanmoins, la query a toujours la même forme; il n'est donc pas nécessaire de gérer le format. 228 include_spip('inc/rainette_normaliser');229 234 list($lieu_normalise,) = normaliser_lieu($lieu); 230 235 … … 379 384 } 380 385 } 381 }382 383 /**384 * @param $langue385 *386 * @return string387 */388 function langue2code_wwo($langue) {389 static $langue2wwo = array(390 'aa' => array('', ''), // afar391 'ab' => array('', ''), // abkhaze392 'af' => array('', ''), // afrikaans393 'am' => array('', ''), // amharique394 'an' => array('', 'es'), // aragonais395 'ar' => array('ar', ''), // arabe396 'as' => array('', ''), // assamais397 'ast' => array('', 'es'), // asturien - iso 639-2398 'ay' => array('', ''), // aymara399 'az' => array('', ''), // azeri400 'ba' => array('', ''), // bashkir401 'be' => array('', ''), // bielorusse402 'ber_tam' => array('', ''), // berbère403 'ber_tam_tfng' => array('', ''), // berbère tifinagh404 'bg' => array('bg', ''), // bulgare405 'bh' => array('', ''), // langues biharis406 'bi' => array('', ''), // bichlamar407 'bm' => array('', ''), // bambara408 'bn' => array('bn', ''), // bengali409 'bo' => array('', ''), // tibétain410 'br' => array('', 'fr'), // breton411 'bs' => array('', ''), // bosniaque412 'ca' => array('', 'es'), // catalan413 'co' => array('', 'fr'), // corse414 'cpf' => array('', 'fr'), // créole réunionais415 'cpf_dom' => array('', 'fr'), // créole ???416 'cpf_hat' => array('', ''), // créole haïtien417 'cs' => array('cs', ''), // tchèque418 'cy' => array('', 'en'), // gallois419 'da' => array('', ''), // danois420 'de' => array('de', ''), // allemand421 'dz' => array('', ''), // dzongkha422 'el' => array('el', ''), // grec moderne423 'en' => array('en', ''), // anglais424 'en_hx' => array('', 'en'), // anglais hacker425 'en_sm' => array('', 'en'), // anglais smurf426 'eo' => array('', ''), // esperanto427 'es' => array('es', ''), // espagnol428 'es_co' => array('', 'es'), // espagnol colombien429 'es_mx_pop' => array('', 'es'), // espagnol mexicain430 'et' => array('', ''), // estonien431 'eu' => array('', ''), // basque432 'fa' => array('', ''), // persan (farsi)433 'ff' => array('', ''), // peul434 'fi' => array('fi', ''), // finnois435 'fj' => array('', ''), // fidjien436 'fo' => array('', ''), // féroïen437 'fon' => array('', ''), // fon438 'fr' => array('fr', ''), // français439 'fr_sc' => array('', 'fr'), // français schtroumpf440 'fr_lpc' => array('', 'fr'), // français langue parlée441 'fr_lsf' => array('', 'fr'), // français langue des signes442 'fr_spl' => array('', 'fr'), // français simplifié443 'fr_tu' => array('', 'fr'), // français copain444 'fy' => array('', 'de'), // frison occidental445 'ga' => array('', 'en'), // irlandais446 'gd' => array('', 'en'), // gaélique écossais447 'gl' => array('', 'es'), // galicien448 'gn' => array('', ''), // guarani449 'grc' => array('', 'el'), // grec ancien450 'gu' => array('', ''), // goudjrati451 'ha' => array('', ''), // haoussa452 'hac' => array('', ''), // Kurdish-Horami453 'hbo' => array('', ''), // hebreu classique ou biblique454 'he' => array('', ''), // hébreu455 'hi' => array('hi', ''), // hindi456 'hr' => array('', ''), // croate457 'hu' => array('hu', ''), // hongrois458 'hy' => array('', ''), // armenien459 'ia' => array('', ''), // interlingua (langue auxiliaire internationale)460 'id' => array('', ''), // indonésien461 'ie' => array('', ''), // interlingue462 'ik' => array('', ''), // inupiaq463 'is' => array('', ''), // islandais464 'it' => array('it', ''), // italien465 'it_fem' => array('', 'it'), // italien féminin466 'iu' => array('', ''), // inuktitut467 'ja' => array('ja', ''), // japonais468 'jv' => array('jv', ''), // javanais469 'ka' => array('', ''), // géorgien470 'kk' => array('', ''), // kazakh471 'kl' => array('', ''), // groenlandais472 'km' => array('', ''), // khmer central473 'kn' => array('', ''), // Kannada474 'ko' => array('ko', ''), // coréen475 'ks' => array('', ''), // kashmiri476 'ku' => array('', ''), // kurde477 'ky' => array('', ''), // kirghiz478 'la' => array('', ''), // latin479 'lb' => array('', 'fr'), // luxembourgeois480 'ln' => array('', ''), // lingala481 'lo' => array('', ''), // lao482 'lt' => array('', ''), // lituanien483 'lu' => array('', ''), // luba-katanga484 'lv' => array('', ''), // letton485 'man' => array('', ''), // mandingue486 'mfv' => array('', ''), // manjaque - iso-639-3487 'mg' => array('', ''), // malgache488 'mi' => array('', ''), // maori489 'mk' => array('', ''), // macédonien490 'ml' => array('', ''), // malayalam491 'mn' => array('', ''), // mongol492 'mo' => array('', 'ro'), // moldave ??? normalement c'est ro comme le roumain493 'mos' => array('', ''), // moré - iso 639-2494 'mr' => array('mr', ''), // marathe495 'ms' => array('', ''), // malais496 'mt' => array('', ''), // maltais497 'my' => array('', ''), // birman498 'na' => array('', ''), // nauruan499 'nap' => array('', 'it'), // napolitain - iso 639-2500 'ne' => array('', ''), // népalais501 'nqo' => array('', ''), // n’ko - iso 639-3502 'nl' => array('nl', ''), // néerlandais503 'no' => array('', ''), // norvégien504 'nb' => array('', ''), // norvégien bokmål505 'nn' => array('', ''), // norvégien nynorsk506 'oc' => array('', 'fr'), // occitan507 'oc_lnc' => array('', 'fr'), // occitan languedocien508 'oc_ni' => array('', 'fr'), // occitan niçard509 'oc_ni_la' => array('', 'fr'), // occitan niçard510 'oc_prv' => array('', 'fr'), // occitan provençal511 'oc_gsc' => array('', 'fr'), // occitan gascon512 'oc_lms' => array('', 'fr'), // occitan limousin513 'oc_auv' => array('', 'fr'), // occitan auvergnat514 'oc_va' => array('', 'fr'), // occitan vivaro-alpin515 'om' => array('', ''), // galla516 'or' => array('', ''), // oriya517 'pa' => array('pa', ''), // pendjabi518 'pbb' => array('', ''), // Nasa Yuwe (páez) - iso 639-3519 'pl' => array('pl', ''), // polonais520 'ps' => array('', ''), // pachto521 'pt' => array('pt', ''), // portugais522 'pt_br' => array('', 'pt'), // portugais brésilien523 'qu' => array('', 'es'), // quechua524 'rm' => array('', 'fr'), // romanche525 'rn' => array('', ''), // rundi526 'ro' => array('ro', ''), // roumain527 'roa' => array('', 'fr'), // langues romanes (ch'ti) - iso 639-2528 'ru' => array('ru', ''), // russe529 'rw' => array('', ''), // rwanda530 'sa' => array('', ''), // sanskrit531 'sc' => array('', 'it'), // sarde532 'scn' => array('', 'it'), // sicilien - iso 639-2533 'sd' => array('', ''), // sindhi534 'sg' => array('', ''), // sango535 'sh' => array('', 'sr'), // serbo-croate536 'sh_latn' => array('', 'sr'), // serbo-croate latin537 'sh_cyrl' => array('', 'sr'), // serbo-croate cyrillique538 'si' => array('si', ''), // singhalais539 'sk' => array('sk', ''), // slovaque540 'sl' => array('', ''), // slovène541 'sm' => array('', ''), // samoan542 'sn' => array('', ''), // shona543 'so' => array('', ''), // somali544 'sq' => array('', ''), // albanais545 'sr' => array('sr', ''), // serbe546 'src' => array('', 'it'), // sarde logoudorien - iso 639-3547 'sro' => array('', 'it'), // sarde campidanien - iso 639-3548 'ss' => array('', ''), // swati549 'st' => array('', ''), // sotho du Sud550 'su' => array('', ''), // soundanais551 'sv' => array('sv', ''), // suédois552 'sw' => array('', ''), // swahili553 'ta' => array('ta', ''), // tamoul554 'te' => array('te', ''), // télougou555 'tg' => array('', ''), // tadjik556 'th' => array('', ''), // thaï557 'ti' => array('', ''), // tigrigna558 'tk' => array('', ''), // turkmène559 'tl' => array('', ''), // tagalog560 'tn' => array('', ''), // tswana561 'to' => array('', ''), // tongan (Îles Tonga)562 'tr' => array('tr', ''), // turc563 'ts' => array('', ''), // tsonga564 'tt' => array('', ''), // tatar565 'tw' => array('', ''), // twi566 'ty' => array('', 'fr'), // tahitien567 'ug' => array('', ''), // ouïgour568 'uk' => array('uk', ''), // ukrainien569 'ur' => array('ur', ''), // ourdou570 'uz' => array('', ''), // ouszbek571 'vi' => array('vi', ''), // vietnamien572 'vo' => array('', ''), // volapük573 'wa' => array('', 'fr'), // wallon574 'wo' => array('', ''), // wolof575 'xh' => array('', ''), // xhosa576 'yi' => array('', ''), // yiddish577 'yo' => array('', ''), // yoruba578 'za' => array('', 'zh'), // zhuang579 'zh' => array('zh', ''), // chinois (ecriture simplifiee)580 'zh_tw' => array('zh_tw', ''), // chinois taiwan (ecriture traditionnelle)581 'zu' => array('zu', '') // zoulou582 );583 584 $code = $GLOBALS['rainette_wwo_config']['service']['langue_service'];585 if (array_key_exists($langue, $langue2wwo)) {586 if ($c0 = $langue2wwo[$langue][0]) {587 $code = strtolower($c0);588 } elseif ($c1 = $langue2wwo[$langue][1]) {589 $code = strtolower($c1);590 }591 }592 593 return $code;594 386 } 595 387
Note: See TracChangeset
for help on using the changeset viewer.