Skip to content
Open
Prev Previous commit
Next Next commit
move at beginning translation function
move at beginning french function in index.php and some french translation
  • Loading branch information
jcliment27 committed Aug 19, 2016
commit bfdd112e8077b711bafed11087e0af7c64885386
42 changes: 24 additions & 18 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ function stripslashes_deep($value) { $value = is_array($value) ? array_map('stri
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}

// Manage translation
$js_lang_file="";


if (isset($language)) {
if (file_exists("lang/".$language.".php")) {
include "lang/".$language.".php";
}
if (file_exists("lang/".$language.".js")) {
$js_lang_file="lang/".$language.".js";
}
}

/*Take a string in paramater and if a translation exist return the string translated*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

he she it ....

function translate($str, $modifier = null) {
global $lang;
if (isset($lang[$str])) return $lang[$str];
return $str;
}

// trafic_limiter : Make sure the IP address makes at most 1 request every 10 seconds.
// Will return false if IP address made a call less than 10 seconds ago.
function trafic_limiter_canPass($ip)
Expand Down Expand Up @@ -311,9 +331,11 @@ function deletePaste($pasteid)
exit;
}


/* Process a paste deletion request.
Returns an array ('',$ERRORMESSAGE,$STATUS)
*/

function processPasteDelete($pasteid,$deletetoken)
{
if (preg_match('/\A[a-f\d]{16}\z/',$pasteid)) // Is this a valid paste identifier ?
Expand All @@ -336,7 +358,8 @@ function processPasteDelete($pasteid,$deletetoken)

// Paste exists and deletion token is valid: Delete the paste.
deletePaste($pasteid);
return array('','','Paste was properly deleted.');
//return array('','','Paste was properly deleted.');
return array('','',translate('Paste was properly deleted.'));
}

/* Process a paste fetch request.
Expand Down Expand Up @@ -429,23 +452,6 @@ function processPasteFetch($pasteid)
$page->assign('ERRORMESSAGE',$ERRORMESSAGE);
$page->assign('STATUS',$STATUS);

// Manage translation
$js_lang_file="";

function translate($str, $modifier = null) {
global $lang;
if (isset($lang[$str])) return $lang[$str];
return $str;
}

if (isset($language)) {
if (file_exists("lang/".$language.".php")) {
include "lang/".$language.".php";
}
if (file_exists("lang/".$language.".js")) {
$js_lang_file="lang/".$language.".js";
}
}
$page->assign('lang_file',$js_lang_file);

$page->draw('page');
Expand Down
8 changes: 4 additions & 4 deletions js/zerobin.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ function displayMessages(key, comments) {
function open_reply(source, commentid) {
$('div.reply').remove(); // Remove any other reply area.
source.after('<div class="reply">'
+ '<input type="text" id="nickname" title="Optional nickname..." value="Optional nickname..." />'
+ '<input type="text" id="nickname" title="Optional nickname..." value="'+translate('Optional nickname')+'..." />'
+ '<textarea id="replymessage" class="replymessage" cols="80" rows="7"></textarea>'
+ '<br><button id="replybutton" onclick="send_comment(\'' + commentid + '\');return false;">Post comment</button>'
+ '<br><button id="replybutton" onclick="send_comment(\'' + commentid + '\');return false;">'+translate('Post comment')+'</button>'
+ '<div id="replystatus">&nbsp;</div>'
+ '</div>');
$('input#nickname').focus(function() {
Expand Down Expand Up @@ -366,8 +366,8 @@ function send_data() {
var deleteUrl = scriptLocation() + "?pasteid=" + data.id + '&deletetoken=' + data.deletetoken;
showStatus('');

$('div#pastelink').html('Your paste is <a id="pasteurl" href="' + url + '">' + url + '</a> <span id="copyhint">(Hit CTRL+C to copy)</span>');
$('div#deletelink').html('<a href="' + deleteUrl + '">Delete link</a>');
$('div#pastelink').html(translate('Your paste is')+' <a id="pasteurl" href="' + url + '">' + url + '</a> <span id="copyhint">('+translate('Hit CTRL+C to copy')+')</span>');
$('div#deletelink').html('<a href="' + deleteUrl + '">'+translate('Delete link')+'</a>');
$('div#pasteresult').show();
selectText('pasteurl'); // We pre-select the link so that the user only has to CTRL+C the link.

Expand Down
9 changes: 7 additions & 2 deletions lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ lang["hour"]="heure";
lang["day"]="jour";
lang["month"]="mois";
lang["Could not decrypt data (Wrong key ?)"]="Impossible de déchiffrer les données (Mauvaise clé ?)";
lang['This document will expire in']="Ce document expirera dans";
lang['FOR YOUR EYES ONLY. Don\'t close this window, this message can\'t be displayed again.']="POUR VOS YEUX SEULEMENT. Ne fermez pas cette fenêtre, ce message ne pourra être ré-affiché";
lang["This document will expire in"]="Ce document expirera dans";
lang["FOR YOUR EYES ONLY. Don\'t close this window, this message can\'t be displayed again."]="POUR VOS YEUX SEULEMENT. Ne fermez pas cette fenêtre, ce message ne pourra être ré-affiché";
lang["Add comment"]="Ajouter un commentaire";
lang["Optional nickname"]="Pseudo optionnel";
lang["Post comment"]="Poster le commentaire";
lang["Delete link"]="Supprimer l'accès à ce lien";
lang["Your paste is"]="votre texte est accessible via ce lien";
lang["Hit CTRL+C to copy"]="Appuyez sur CTRL+C pour copier le lien";
2 changes: 2 additions & 0 deletions lang/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@
$lang["Open discussion"]="Ouvrir les commentaires";
$lang["Syntax coloring"]="Coloration syntaxique";
$lang["Discussion"]="Discussion";
$lang["Paste was properly deleted."]="Le texte a été correctement supprimé";