Commit eb4f4309 authored by David's avatar David

- 4.2

     - Modification de la détection de langue pour plus compatibilité avec tout les codes langues
     - Intégration d'un script de téléchargement/compilation automatique des traductions depuis Crowdin
parent 34b0259b
...@@ -7,9 +7,26 @@ RewriteEngine on ...@@ -7,9 +7,26 @@ RewriteEngine on
RewriteRule ^Autonome.php$ index.php?langue=fr&%{QUERY_STRING} [L] RewriteRule ^Autonome.php$ index.php?langue=fr&%{QUERY_STRING} [L]
RewriteRule ^StandAlone.php$ index.php?langue=en&%{QUERY_STRING} [L] RewriteRule ^StandAlone.php$ index.php?langue=en&%{QUERY_STRING} [L]
# Support de tout les codes langues :
# https://support.crowdin.com/api/language-codes/
# Spécial Montenegrin : sr-Cyrl-ME
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^sr-Cyrl-ME(.*) index.php?langue=sr-Cyrl-ME&%{QUERY_STRING}
# xx-YY
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{2}-[A-Z]{2})(.*) index.php?langue=$1&%{QUERY_STRING}
# xxx-YY
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{3}-[A-Z]{2})(.*) index.php?langue=$1&%{QUERY_STRING}
# xxx
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{3})(.*) index.php?langue=$1&%{QUERY_STRING}
# xx
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{2})(.*) index.php?langue=$1&%{QUERY_STRING} RewriteRule ^([a-z]{2})(.*) index.php?langue=$1&%{QUERY_STRING}
...@@ -49,6 +49,9 @@ Le rendre accessible depuis votre serveur http et personnaliser les valeur du fi ...@@ -49,6 +49,9 @@ Le rendre accessible depuis votre serveur http et personnaliser les valeur du fi
### Changelog ### Changelog
- 4.2
- Modification de la détection de langue pour plus compatibilité avec tout les codes langues
- Intégration d'un script de téléchargement/compilation automatique des traductions depuis Crowdin
- 4.1.2 - 4.1.2
- #4 Prise en compte des boîtiers de jonctions - #4 Prise en compte des boîtiers de jonctions
- Correcion bug - Correcion bug
......
<?php <?php
$CalcPvAutonomeVersion='4.1.2'; $CalcPvAutonomeVersion='4.2';
include_once('./lib/Fonction.php'); include_once('./lib/Fonction.php');
$config_ini = parse_ini_file('./config.ini', true); $config_ini = parse_ini_file('./config.ini', true);
$lang_ini = parse_ini_file('./lang/lang.ini',true); $lang_ini = parse_ini_file('./lang/lang.ini',true);
// Langues disponibles : // Dans les URL on utilisera les codes langues https://support.crowdin.com/api/language-codes/
foreach($lang_ini as $lang) { // On a une fonction pour retrouve le local à partir (et vis et versa)
$localeDispo[]=$lang['code'];
}
/*$
$localeDispo=array( '<b>Contribute to translation</b> (in-context)' => 'aa',
'Afrikaans (?%)' => 'af',
'Español (?%)' => 'es',
'English (100%)' => 'en',
'Français (100%)' => 'fr',
'Indonesia (?%)' => 'id',
'Italiano' => 'it',
'Nederlands <b>'._('partial translation').' (10%)</b>' => 'nl',
'Polski <b>'._('partial translation').' (10%)</b>' => 'pl',
'Pусский (10%)' => 'ru',
'Türk (73%)' => 'tr',
'український <b>'._('partial translation').' (8%)</b>' => 'uk',
);
*/
// Fonction de langue : // Fonction de langue :
function langue2locale($langue) { include('./lang/lang-dispo.php');
switch ($langue) {
// Pseudo langue pour la traduction in-context de crowdin
case 'aa':
return 'aa_ER.utf8';
break;
// Vrai langue
case 'fr':
return 'fr_FR.utf8';
break;
case 'es':
return 'es_ES.utf8';
break;
case 'es-ES':
return 'es_ES.utf8';
break;
case 'pt':
return 'pt_PT.utf8';
break;
case 'eo':
return 'eo.utf8';
break;
case 'nl':
return 'nl_NL.utf8';
break;
case 'tr':
return 'tr_TR.utf8';
break;
case 'uk':
return 'uk_UA.utf8';
break;
case 'id':
return 'id_ID.utf8';
break;
case 'af':
return 'af_ZA.utf8';
break;
case 'ru':
return 'ru_RU.utf8';
break;
case 'it':
return 'it_IT.utf8';
break;
default:
return 'en_US.utf8';
}
}
// Détection et redirection (langue toujours) // Détection et redirection (langue toujours)
if (isset($_GET['langue']) && in_array(substr($_GET['langue'], 0, 2), $localeDispo)) { if (isset($_GET['langue'])) {
$locale = langue2locale($_GET['langue']); $locale = lang2locale($_GET['langue']);
if ($_COOKIE['langue'] != $_GET['langue']) { $localeshort=locale2lang($locale);
setcookie("langue",$_GET['langue'],strtotime( '+1 year' )); if ($_COOKIE['langue'] != $localeshort) {
setcookie("langue",$localeshort,strtotime( '+1 year' ));
} }
} elseif (isset($_GET['langue']) && !in_array(substr($_GET['langue'], 0, 2), $localeDispo)) {
$locale = langue2locale('en'); // Erreur ou hack :
header('Location: '.replaceLang2url($locale));
} elseif (isset($_COOKIE['langue'])) { } elseif (isset($_COOKIE['langue'])) {
$locale = langue2locale($_COOKIE['langue']); $locale = lang2locale($_COOKIE['langue']);
$localeshort=locale2lang($_COOKIE['langue']);
header('Location: '.addLang2url($locale)); header('Location: '.addLang2url($locale));
} else { } else {
$locale = langue2locale(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)); $locale = lang2locale($_SERVER['HTTP_ACCEPT_LANGUAGE']);
$localeshort=locale2lang($_SERVER['HTTP_ACCEPT_LANGUAGE']);
header('Location: '.addLang2url($locale)); header('Location: '.addLang2url($locale));
exit(); exit();
} }
//$locale = langue2locale('es');
$localeshort=substr($locale, 0, 2);
// Définition de la langue : // Définition de la langue :
$results=putenv("LC_ALL=$locale"); $results=putenv("LC_ALL=$locale.utf8");
if (!$results) { if (!$results) {
exit ('putenv failed'); exit ('putenv failed');
} }
$results=putenv("LC_LANG=$locale"); $results=putenv("LC_LANG=$locale.utf8");
if (!$results) { if (!$results) {
exit ('putenv failed'); exit ('putenv failed');
} }
$results=putenv("LC_LANGUAGE=$locale"); $results=putenv("LC_LANGUAGE=$locale.utf8");
if (!$results) { if (!$results) {
exit ('putenv failed'); exit ('putenv failed');
} }
$results=setlocale(LC_ALL, $locale); $results=setlocale(LC_ALL, "$locale.utf8");
if (!$results) { if (!$results) {
exit ('setlocale failed: locale function is not available on this platform, or the given local does not exist in this environment'); exit ('setlocale failed: locale function is not available on this platform, or the given local does not exist in this environment');
} }
...@@ -152,7 +87,7 @@ $country = @geoip_country_code_by_name(get_ip()); ...@@ -152,7 +87,7 @@ $country = @geoip_country_code_by_name(get_ip());
ksort($lang_ini); ksort($lang_ini);
foreach($lang_ini as $lang) { foreach($lang_ini as $lang) {
$flag=''; $flag='';
if (substr($locale, 0, 2) == $lang['code']) { if ($localeshort == $lang['code']) {
$flag=' drapeauActif'; $flag=' drapeauActif';
} }
echo '<a id="href'.$lang['code'].'" href="'.replaceLang2url($lang['code']).'"><img class="drapeau'.$flag.'" src="./lib/'.$lang['code'].'.png" alt="'.$lang['code'].'" width="23" height="15" /></a>'; echo '<a id="href'.$lang['code'].'" href="'.replaceLang2url($lang['code']).'"><img class="drapeau'.$flag.'" src="./lib/'.$lang['code'].'.png" alt="'.$lang['code'].'" width="23" height="15" /></a>';
...@@ -161,10 +96,10 @@ $country = @geoip_country_code_by_name(get_ip()); ...@@ -161,10 +96,10 @@ $country = @geoip_country_code_by_name(get_ip());
$("#languesLegende").show();'; $("#languesLegende").show();';
if ($lang['code'] == 'aa') { if ($lang['code'] == 'aa') {
echo '$("#languesLegende").html("<b>Contribute to translation</b> (in-context)");'; echo '$("#languesLegende").html("<b>Contribute to translation</b> (in-context)");';
} else if ($lang['translated_progress'] < 60) { } else if ($lang['translated_progress'] < 90) {
echo '$("#languesLegende").html("<b>'.strtoupper($lang['code']).'</b> '._('partial translation').' ('.$lang['translated_progress'].'%)");'; echo '$("#languesLegende").html("<b>'.$lang['code'].'</b> '._('partial translation').' ('.$lang['translated_progress'].'%)");';
} else { } else {
echo '$("#languesLegende").html("<b>'.strtoupper($lang['code']).'</b> ('.$lang['translated_progress'].'%)");'; echo '$("#languesLegende").html("<b>'.$lang['code'].'</b> ('.$lang['translated_progress'].'%)");';
} }
echo '}) echo '})
.mouseout(function() { .mouseout(function() {
......
...@@ -3,7 +3,7 @@ msgstr "" ...@@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: calcpvautonome\n" "Project-Id-Version: calcpvautonome\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-16 14:36+0100\n" "POT-Creation-Date: 2018-02-16 14:36+0100\n"
"PO-Revision-Date: 2018-02-18 16:47-0500\n" "PO-Revision-Date: 2018-02-19 10:21-0500\n"
"Last-Translator: kepon85 <david@mercereau.info>\n" "Last-Translator: kepon85 <david@mercereau.info>\n"
"Language-Team: Afrikaans\n" "Language-Team: Afrikaans\n"
"Language: af_ZA\n" "Language: af_ZA\n"
...@@ -14,7 +14,7 @@ msgstr "" ...@@ -14,7 +14,7 @@ msgstr ""
"X-Generator: crowdin.com\n" "X-Generator: crowdin.com\n"
"X-Crowdin-Project: calcpvautonome\n" "X-Crowdin-Project: calcpvautonome\n"
"X-Crowdin-Language: af\n" "X-Crowdin-Language: af\n"
"X-Crowdin-File: /v4.0/messages.pot\n" "X-Crowdin-File: messages.pot\n"
#: CalcConsommation.php:2 #: CalcConsommation.php:2
msgid "In order to know the electric consumption (in Watts) of your devices you may" msgid "In order to know the electric consumption (in Watts) of your devices you may"
......
Name,Languages,"Translated (Words)","Target Words","Approved (Words)","Votes Made" Name,Languages,"Translated (Words)","Target Words","Approved (Words)","Votes Made"
"billoges (billog2968)",Afrikaans,1219,1312,0,0 "billoges (billog2968)",Afrikaans,1219,1312,0,0
"DavidM (kepon85)",Afrikaans,29,28,1219,0 "DavidM (kepon85)",Afrikaans,29,28,1219,0
amp8,,0,0,0,0 agusalim,,0,0,0,0
"Emre Özdiyar (incendiesq)",,0,0,0,0
"Elías Loreto (eliasjloreto)",,0,0,0,0
"Ericka Simancas (ackseriam)",,0,0,0,0 "Ericka Simancas (ackseriam)",,0,0,0,0
"ayukhamil (javhihi19091996)",,0,0,0,0 "ayukhamil (javhihi19091996)",,0,0,0,0
"Fachrur Razi (fachrurrazi)",,0,0,0,0 "Fachrur Razi (fachrurrazi)",,0,0,0,0
amp8,,0,0,0,0
ferimenn,,0,0,0,0 ferimenn,,0,0,0,0
"Bartłomiej Mathea (apocz)",,0,0,0,0
thegreenfox,,0,0,0,0 thegreenfox,,0,0,0,0
agusalim,,0,0,0,0
isacastillor,,0,0,0,0 isacastillor,,0,0,0,0
"Emre Özdiyar (incendiesq)",,0,0,0,0
"Tatjana Larina (erikaflynn) (t257233)",,0,0,0,0 "Tatjana Larina (erikaflynn) (t257233)",,0,0,0,0
Daiky69,,0,0,0,0 Daiky69,,0,0,0,0
"raja rizki (rizki271197)",,0,0,0,0 "raja rizki (rizki271197)",,0,0,0,0
"bym (bymc)",,0,0,0,0
nasruddinn,,0,0,0,0
aikochan,,0,0,0,0
aleysiaa,,0,0,0,0
"Elías Loreto (eliasjloreto)",,0,0,0,0
"Juan Raúl Hernández (jraulhernandezi)",,0,0,0,0 "Juan Raúl Hernández (jraulhernandezi)",,0,0,0,0
"Erol Yağız AYDIN (escorn)",,0,0,0,0
mirrim,,0,0,0,0 mirrim,,0,0,0,0
"Ned (nednet)",,0,0,0,0 paulcmal,,0,0,0,0
coucou39,,0,0,0,0 coucou39,,0,0,0,0
"Philippe (ppmt)",,0,0,0,0 "Philippe (ppmt)",,0,0,0,0
"Marion (guillerette)",,0,0,0,0 "Marion (guillerette)",,0,0,0,0
Mariajosi,,0,0,0,0 Mariajosi,,0,0,0,0
Nibor44,,0,0,0,0 Nibor44,,0,0,0,0
Laeth,,0,0,0,0 Laeth,,0,0,0,0
paulcmal,,0,0,0,0 "Ned (nednet)",,0,0,0,0
"Andriy Poznakhovskyy (Andrulko)",,0,0,0,0
Poussinou,,0,0,0,0 Poussinou,,0,0,0,0
"Bartłomiej Mathea (apocz)",,0,0,0,0
PifyZ,,0,0,0,0 PifyZ,,0,0,0,0
taha2002,,0,0,0,0 taha2002,,0,0,0,0
tarfayaproject,,0,0,0,0 tarfayaproject,,0,0,0,0
StarlightF,,0,0,0,0 StarlightF,,0,0,0,0
"Harun Demirel (harundemirel)",,0,0,0,0 "Harun Demirel (harundemirel)",,0,0,0,0
alfanerd,,0,0,0,0 alfanerd,,0,0,0,0
"bym (bymc)",,0,0,0,0 "Andriy Poznakhovskyy (Andrulko)",,0,0,0,0
"Erol Yağız AYDIN (escorn)",,0,0,0,0
aafeng,,0,0,0,0
This diff is collapsed.
./af
\ No newline at end of file
#!/usr/bin/php #!/usr/bin/php
<?php <?php
// David Mercereau
// Licence Beerware
// Script pour les traductions sur crowdin // Script pour les traductions sur crowdin
// - Compilation sur crowdin // - Compilation sur crowdin
// - Téléchargement // - Téléchargement des traductions
// - Compilation en .mo // - Compilation en .mo
// - Mise à jour du lang.ini pour dire merci au contributeur // - Mise à jour du lang.ini qui contient :
// - % d'avancement de la traduction
// - Liste des contributeurs (pour dire merci)
// Pré-requis : Linux, php-cli & gettext
// Identifiant du projet Crowdin (à récupérer dans l'onglet API du projet)
$projectIdentifier='calcpvautonome'; $projectIdentifier='calcpvautonome';
// API Key du projet Crowdin (seul contenu du fichier text .crowdin-key)
$projectKey=rtrim(file_get_contents('.crowdin-key')); $projectKey=rtrim(file_get_contents('.crowdin-key'));
$tradDir='./'; // Répertoire où stocker les traduction
$tradDir='.';
// % minimum de traduction faite pour apparaître
$tradMini=20;
// Langue disponible (locale<>code)
include('./lang-dispo.php');
ini_set('auto_detect_line_endings', 1); ini_set('auto_detect_line_endings', 1);
ini_set('default_socket_timeout', 5); // socket timeout, just in case ini_set('default_socket_timeout', 5);
// Build // Compilation des langues sur crowdin (éviter trop de requête comme celle-ci pour être gentil avec leur serveur...)
$request_url = 'https://api.crowdin.com/api/project/'.$projectIdentifier.'/export?key='.$projectKey; $request_url = 'https://api.crowdin.com/api/project/'.$projectIdentifier.'/export?key='.$projectKey;
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); $result = curl_exec($ch);
curl_close($ch); curl_close($ch);
// CHECK si le résultat dit <success status="built"/> ?
echo $result; echo $result;
// On liste les langues qui on un début de traduction : // On liste les langues qui on un début de traduction :
...@@ -35,24 +49,31 @@ curl_close($ch); ...@@ -35,24 +49,31 @@ curl_close($ch);
$jsonContenu=json_decode($result, true); $jsonContenu=json_decode($result, true);
$lang_ini_content=''; $lang_ini_content='';
foreach ($jsonContenu as $lang) { foreach ($jsonContenu as $lang) {
if ($lang['translated_progress'] != 0) { if ($lang['translated_progress'] > $tradMini) {
echo $lang['code'].' '.$lang['translated_progress'].'%'; echo $lang['code'].' '.$lang['translated_progress'].'%';
if (!is_dir($tradDir.'./'.$lang['code'])) { if (!is_dir($tradDir.'/'.$lang['code'])) {
echo "\n \t Un nouvelle langue a été traduite, il faut créer le répertoire et vérifier son existance dans le locale (dpkg-reconfigures locales)"; echo "\n \t Un nouvelle langue a été traduite, il faut créer le répertoire (avec le répertoire LC_MESSAGES dedans), vérifier son existance dans le locale (dpkg-reconfigures locales) et l'intégrer dans le array du lang-dispo.php";
} else { } else {
// On créer un lien symbolique du code langue vers le locale pour que le système s'y retrouve
if (!file_exists($tradDir.'/'.lang2locale($lang['code']))) {
symlink($tradDir.'/'.$lang['code'], $tradDir.'/'.lang2locale($lang['code']));
}
// On télécharge le fichier zip des langues depuis crowdin
file_put_contents($tradDir.'/'.$lang['code'].'/'.$lang['code'].'.zip', file_get_contents('https://api.crowdin.com/api/project/'.$projectIdentifier.'/download/'.$lang['code'].'.zip?key='.$projectKey)); file_put_contents($tradDir.'/'.$lang['code'].'/'.$lang['code'].'.zip', file_get_contents('https://api.crowdin.com/api/project/'.$projectIdentifier.'/download/'.$lang['code'].'.zip?key='.$projectKey));
exec('unzip -o '.$tradDir.'/'.$lang['code'].'/'.$lang['code'].'.zip -d '.$tradDir.'/'.$lang['code'], $output, $return_var); // Décompression
exec('unzip -o '.$tradDir.'/'.$lang['code'].'/'.$lang['code'].'.zip -d '.$tradDir.'/'.$lang['code'].'/LC_MESSAGES/', $output, $return_var);
if ($return_var != 0) { if ($return_var != 0) {
exit('Erreur à l\'extraction du zip : '.$return_var); exit('Erreur à l\'extraction du zip : '.$return_var);
} }
// Ménage
unlink($tradDir.'/'.$lang['code'].'/'.$lang['code'].'.zip'); unlink($tradDir.'/'.$lang['code'].'/'.$lang['code'].'.zip');
// Compilation du .po en .mo
exec('msgfmt '.$tradDir.'/'.$lang['code'].'/LC_MESSAGES/messages-'.$lang['code'].'.po -o '.$tradDir.'/'.$lang['code'].'/LC_MESSAGES/messages.mo', $output, $return_var); exec('msgfmt '.$tradDir.'/'.$lang['code'].'/LC_MESSAGES/messages-'.$lang['code'].'.po -o '.$tradDir.'/'.$lang['code'].'/LC_MESSAGES/messages.mo', $output, $return_var);
if ($return_var != 0) { if ($return_var != 0) {
exit('Erreur à la mise à jour du .mo : '.$return_var); exit('Erreur à la mise à jour du .mo : '.$return_var);
} }
// Pour les MERCI
// On récupère les traducteurs : // On demande la liste des traducteurs
$request_url = 'https://api.crowdin.com/api/project/'.$projectIdentifier.'/reports/top-members/export?key='.$projectKey.'&language='.$lang['code'].'&format=csv&json=1'; $request_url = 'https://api.crowdin.com/api/project/'.$projectIdentifier.'/reports/top-members/export?key='.$projectKey.'&language='.$lang['code'].'&format=csv&json=1';
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_URL, $request_url);
...@@ -60,6 +81,7 @@ foreach ($jsonContenu as $lang) { ...@@ -60,6 +81,7 @@ foreach ($jsonContenu as $lang) {
$result = curl_exec($ch); $result = curl_exec($ch);
curl_close($ch); curl_close($ch);
$json_array=json_decode($result, true); $json_array=json_decode($result, true);
// On télécharge la liste des traducteurs
file_put_contents($tradDir.'/'.$lang['code'].'/'.$lang['code'].'-top-members.csv', file_get_contents('https://api.crowdin.com/api/project/'.$projectIdentifier.'/reports/top-members/download?key='.$projectKey.'&hash='.$json_array['hash'])); file_put_contents($tradDir.'/'.$lang['code'].'/'.$lang['code'].'-top-members.csv', file_get_contents('https://api.crowdin.com/api/project/'.$projectIdentifier.'/reports/top-members/download?key='.$projectKey.'&hash='.$json_array['hash']));
// Analyse CSV // Analyse CSV
if (($handle = fopen($tradDir.'/'.$lang['code'].'/'.$lang['code'].'-top-members.csv', "r")) !== FALSE) { if (($handle = fopen($tradDir.'/'.$lang['code'].'/'.$lang['code'].'-top-members.csv', "r")) !== FALSE) {
...@@ -80,15 +102,6 @@ foreach ($jsonContenu as $lang) { ...@@ -80,15 +102,6 @@ foreach ($jsonContenu as $lang) {
} }
fclose($handle); fclose($handle);
} }
// Exeption pour l'espagnol (qui n'est pas en "es" mais en "es-ES"
if ($lang['code'] == 'es-ES') {
if (!is_link($tradDir.'/es')) {
symlink($tradDir.'/'.$lang['code'], $tradDir.'/es');
}
$lang['code']='es';
}
// Création du fichier ini // Création du fichier ini
$lang_ini_content.="[".$lang['code']."]\n"; $lang_ini_content.="[".$lang['code']."]\n";
$lang_ini_content.="code='".$lang['code']."'\n"; $lang_ini_content.="code='".$lang['code']."'\n";
...@@ -104,6 +117,7 @@ foreach ($jsonContenu as $lang) { ...@@ -104,6 +117,7 @@ foreach ($jsonContenu as $lang) {
} }
} }
// Ajout de la langue "aa" pseudo langue pour le mode "in-context"
$lang_ini_content.="[aa]\n"; $lang_ini_content.="[aa]\n";
$lang_ini_content.="code='aa'\n"; $lang_ini_content.="code='aa'\n";
$lang_ini_content.="translated_progress=100\n"; $lang_ini_content.="translated_progress=100\n";
...@@ -112,6 +126,7 @@ $lang_ini_content.="translator1[name]='name1'\n"; ...@@ -112,6 +126,7 @@ $lang_ini_content.="translator1[name]='name1'\n";
$lang_ini_content.="translator2[translated]=100\n"; $lang_ini_content.="translator2[translated]=100\n";
$lang_ini_content.="translator2[name]='name2'\n"; $lang_ini_content.="translator2[name]='name2'\n";
// Ajout de la langue anglaise qui est la langue native du projet
$lang_ini_content.="[en]\n"; $lang_ini_content.="[en]\n";
$lang_ini_content.="code='en'\n"; $lang_ini_content.="code='en'\n";
$lang_ini_content.="translated_progress=100\n"; $lang_ini_content.="translated_progress=100\n";
...@@ -126,8 +141,11 @@ $lang_ini_content.="translator2[name]='mirrim'\n"; ...@@ -126,8 +141,11 @@ $lang_ini_content.="translator2[name]='mirrim'\n";
$lang_ini_content.="translator2[translated]=100\n"; $lang_ini_content.="translator2[translated]=100\n";
$lang_ini_content.="translator2[name]='ppmt'\n"; $lang_ini_content.="translator2[name]='ppmt'\n";
file_put_contents($tradDir.'lang.ini', $lang_ini_content); // Ecriture
file_put_contents($tradDir.'/lang.ini', $lang_ini_content);
// Restart de php-fpm pour éviter les problème de cache
// Chez vous ça peut être directement apache si c'est du mod-php...
if (is_file('/etc/init.d/php7.0-fpm')) { if (is_file('/etc/init.d/php7.0-fpm')) {
exec('/etc/init.d/php7.0-fpm restart', $output, $return_var); exec('/etc/init.d/php7.0-fpm restart', $output, $return_var);
if ($return_var != 0) { if ($return_var != 0) {
......
#!/usr/bin/php
<?php
$projectIdentifier='calcpvautonome';
$projectKey=rtrim(file_get_contents('.crowdin-key'));
$pot='./messages.pot';
if (!is_file($pot)) {
exit('Le fichier '.$pot.' n\'existe pas');
}
ini_set('auto_detect_line_endings', 1);
ini_set('default_socket_timeout', 5); // socket timeout, just in case
$post_params = array();
$request_url = 'https://api.crowdin.com/api/project/'.$projectIdentifier.'/add-file?key='.$projectKey;
if(function_exists('curl_file_create')) {
$post_params['files[messages.pot]'] = curl_file_create($pot);
} else {
$post_params['files[messages.pot]'] = '@'.$pot;
}
/*
$post_params['type'] = 'gettext,source_phrase,translation';
if (function_exists('curl_file_create')) {
$post_params['files[messages.pot]'] = curl_file_create('./messages.pot');
} else {
$post_params['files[messages.pot]'] = '@./messages.pot';
}*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
// Build
/*
$request_url = 'https://api.crowdin.com/api/project/'.$projectIdentifier.'/export?key='.$projectKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
// CHECK si le résultat dit <success status="built"/> ?
echo $result;
*/
?>
.//es-ES
\ No newline at end of file
...@@ -3,7 +3,7 @@ msgstr "" ...@@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: calcpvautonome\n" "Project-Id-Version: calcpvautonome\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-16 14:36+0100\n" "POT-Creation-Date: 2018-02-16 14:36+0100\n"
"PO-Revision-Date: 2018-02-18 16:47-0500\n" "PO-Revision-Date: 2018-02-19 10:21-0500\n"
"Last-Translator: kepon85 <david@mercereau.info>\n" "Last-Translator: kepon85 <david@mercereau.info>\n"
"Language-Team: Spanish\n" "Language-Team: Spanish\n"
"Language: es_ES\n" "Language: es_ES\n"
...@@ -14,7 +14,7 @@ msgstr "" ...@@ -14,7 +14,7 @@ msgstr ""
"X-Generator: crowdin.com\n" "X-Generator: crowdin.com\n"
"X-Crowdin-Project: calcpvautonome\n" "X-Crowdin-Project: calcpvautonome\n"
"X-Crowdin-Language: es-ES\n" "X-Crowdin-Language: es-ES\n"
"X-Crowdin-File: /v4.0/messages.pot\n" "X-Crowdin-File: messages.pot\n"
#: CalcConsommation.php:2 #: CalcConsommation.php:2
msgid "In order to know the electric consumption (in Watts) of your devices you may" msgid "In order to know the electric consumption (in Watts) of your devices you may"
......
...@@ -3,35 +3,39 @@ Name,Languages,"Translated (Words)","Target Words","Approved (Words)","Votes Mad ...@@ -3,35 +3,39 @@ Name,Languages,"Translated (Words)","Target Words","Approved (Words)","Votes Mad
"Juan Raúl Hernández (jraulhernandezi)",Spanish,1136,1275,0,0 "Juan Raúl Hernández (jraulhernandezi)",Spanish,1136,1275,0,0
"Ericka Simancas (ackseriam)",Spanish,301,319,0,0 "Ericka Simancas (ackseriam)",Spanish,301,319,0,0
"DavidM (kepon85)",Spanish,292,314,2624,0 "DavidM (kepon85)",Spanish,292,314,2624,0
"Tatjana Larina (erikaflynn) (t257233)",,0,0,0,0 "Marion (guillerette)",,0,0,0,0
isacastillor,,0,0,0,0 isacastillor,,0,0,0,0
agusalim,,0,0,0,0
thegreenfox,,0,0,0,0
"Bartłomiej Mathea (apocz)",,0,0,0,0
amp8,,0,0,0,0
"billoges (billog2968)",,0,0,0,0
"Fachrur Razi (fachrurrazi)",,0,0,0,0 "Fachrur Razi (fachrurrazi)",,0,0,0,0
"ayukhamil (javhihi19091996)",,0,0,0,0 "billoges (billog2968)",,0,0,0,0
Daiky69,,0,0,0,0 amp8,,0,0,0,0
"raja rizki (rizki271197)",,0,0,0,0
"Emre Özdiyar (incendiesq)",,0,0,0,0
ferimenn,,0,0,0,0 ferimenn,,0,0,0,0
"Erol Yağız AYDIN (escorn)",,0,0,0,0 thegreenfox,,0,0,0,0
mirrim,,0,0,0,0 agusalim,,0,0,0,0
"Ned (nednet)",,0,0,0,0 "Tatjana Larina (erikaflynn) (t257233)",,0,0,0,0
coucou39,,0,0,0,0 coucou39,,0,0,0,0
Daiky69,,0,0,0,0
"raja rizki (rizki271197)",,0,0,0,0
"bym (bymc)",,0,0,0,0
nasruddinn,,0,0,0,0
aikochan,,0,0,0,0
aleysiaa,,0,0,0,0
"ayukhamil (javhihi19091996)",,0,0,0,0
"Philippe (ppmt)",,0,0,0,0 "Philippe (ppmt)",,0,0,0,0
"Marion (guillerette)",,0,0,0,0
Mariajosi,,0,0,0,0 Mariajosi,,0,0,0,0
taha2002,,0,0,0,0
Nibor44,,0,0,0,0 Nibor44,,0,0,0,0
Laeth,,0,0,0,0 Laeth,,0,0,0,0
"Ned (nednet)",,0,0,0,0
paulcmal,,0,0,0,0 paulcmal,,0,0,0,0
"Andriy Poznakhovskyy (Andrulko)",,0,0,0,0
Poussinou,,0,0,0,0 Poussinou,,0,0,0,0
PifyZ,,0,0,0,0 PifyZ,,0,0,0,0
taha2002,,0,0,0,0
tarfayaproject,,0,0,0,0 tarfayaproject,,0,0,0,0
"Emre Özdiyar (incendiesq)",,0,0,0,0
StarlightF,,0,0,0,0 StarlightF,,0,0,0,0
"Harun Demirel (harundemirel)",,0,0,0,0 "Harun Demirel (harundemirel)",,0,0,0,0
alfanerd,,0,0,0,0 alfanerd,,0,0,0,0
"bym (bymc)",,0,0,0,0 "Andriy Poznakhovskyy (Andrulko)",,0,0,0,0
"Erol Yağız AYDIN (escorn)",,0,0,0,0
"Bartłomiej Mathea (apocz)",,0,0,0,0
mirrim,,0,0,0,0
aafeng,,0,0,0,0
This diff is collapsed.
./es-ES
\ No newline at end of file
...@@ -3,7 +3,7 @@ msgstr "" ...@@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: calcpvautonome\n" "Project-Id-Version: calcpvautonome\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-16 14:36+0100\n" "POT-Creation-Date: 2018-02-16 14:36+0100\n"
"PO-Revision-Date: 2018-02-18 16:47-0500\n" "PO-Revision-Date: 2018-02-19 07:42-0500\n"
"Last-Translator: kepon85 <david@mercereau.info>\n" "Last-Translator: kepon85 <david@mercereau.info>\n"
"Language-Team: French\n" "Language-Team: French\n"
"Language: fr_FR\n" "Language: fr_FR\n"
...@@ -14,7 +14,7 @@ msgstr "" ...@@ -14,7 +14,7 @@ msgstr ""
"X-Generator: crowdin.com\n" "X-Generator: crowdin.com\n"
"X-Crowdin-Project: calcpvautonome\n" "X-Crowdin-Project: calcpvautonome\n"
"X-Crowdin-Language: fr\n" "X-Crowdin-Language: fr\n"
"X-Crowdin-File: /v4.0/messages.pot\n" "X-Crowdin-File: messages.pot\n"
#: CalcConsommation.php:2 #: CalcConsommation.php:2
msgid "In order to know the electric consumption (in Watts) of your devices you may" msgid "In order to know the electric consumption (in Watts) of your devices you may"
......
Name,Languages,"Translated (Words)","Target Words","Approved (Words)","Votes Made" Name,Languages,"Translated (Words)","Target Words","Approved (Words)","Votes Made"
"DavidM (kepon85)",French,2723,3037,2683,0 "DavidM (kepon85)",French,2723,3037,2683,0
amp8,,0,0,0,0 agusalim,,0,0,0,0
"Emre Özdiyar (incendiesq)",,0,0,0,0
"Elías Loreto (eliasjloreto)",,0,0,0,0
"Ericka Simancas (ackseriam)",,0,0,0,0 "Ericka Simancas (ackseriam)",,0,0,0,0
"ayukhamil (javhihi19091996)",,0,0,0,0 "ayukhamil (javhihi19091996)",,0,0,0,0
"Fachrur Razi (fachrurrazi)",,0,0,0,0