From: Jerome Jutteau Date: Mon, 31 Dec 2012 14:48:30 +0000 (+0100) Subject: refactorised translation function X-Git-Tag: 1.0~14 X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/53517d3b939f85007001beb3a01a32b032a9070b?hp=1fe28b19ecaaeedfb9b5087f6d8c742968934ddb refactorised translation function --- diff --git a/admin.php b/admin.php index 7aceff9..e9e5342 100755 --- a/admin.php +++ b/admin.php @@ -37,7 +37,7 @@ if (file_exists (JIRAFEAU_ROOT . 'install.php')) { require (JIRAFEAU_ROOT . 'lib/template/header.php'); echo '

'. - _('Installer script still present') . + t('Installer script still present') . '

'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); exit; @@ -48,7 +48,7 @@ if (!$cfg['admin_password']) { require (JIRAFEAU_ROOT . 'lib/template/header.php'); echo '

'. - _('Sorry, the admin interface is not enabled.') . + t('Sorry, the admin interface is not enabled.') . '

'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); exit; @@ -71,7 +71,7 @@ if (isset ($_POST['admin_password'])) $_SESSION['admin_auth'] = false; require (JIRAFEAU_ROOT . 'lib/template/header.php'); echo '

'. - _('Wrong password.') . '

'; + t('Wrong password.') . '

'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } @@ -85,7 +85,7 @@ elseif (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true)
+
@@ -109,22 +109,22 @@ elseif (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true) /* Admin interface. */ require (JIRAFEAU_ROOT . 'lib/template/header.php'); -?>

-
+
@@ -132,11 +132,11 @@ require (JIRAFEAU_ROOT . 'lib/template/header.php'); @@ -144,13 +144,13 @@ require (JIRAFEAU_ROOT . 'lib/template/header.php'); @@ -158,13 +158,13 @@ require (JIRAFEAU_ROOT . 'lib/template/header.php'); @@ -172,20 +172,20 @@ require (JIRAFEAU_ROOT . 'lib/template/header.php');
- + - +
- + - +
- + - +
- + - +
- + - +
- +
' . NL; echo '

'; - echo _('Number of cleaned files') . ' : ' . $total; + echo t('Number of cleaned files') . ' : ' . $total; echo '

'; } elseif (strcmp ($_POST['action'], 'list') == 0) @@ -221,13 +221,13 @@ if (isset ($_POST['action'])) { jirafeau_delete ($_POST['link']); echo '
' . NL; - echo '

' . _('Link deleted') . '

'; + echo '

' . t('Link deleted') . '

'; } elseif (strcmp ($_POST['action'], 'delete_file') == 0) { $count = jirafeau_delete_file ($_POST['md5']); echo '
' . NL; - echo '

' . _('Deleted links') . ' : ' . $count . '

'; + echo '

' . t('Deleted links') . ' : ' . $count . '

'; } } diff --git a/file.php b/file.php index 8e4451a..fefeffd 100644 --- a/file.php +++ b/file.php @@ -35,7 +35,7 @@ if (isset ($_GET['h']) && !empty ($_GET['h'])) if (!preg_match ('/[0-9a-f]{32}$/', $link_name)) { require (JIRAFEAU_ROOT.'lib/template/header.php'); - echo '

' . _('Sorry, the requested file is not found') . '

'; + echo '

' . t('Sorry, the requested file is not found') . '

'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } @@ -44,7 +44,7 @@ if (isset ($_GET['h']) && !empty ($_GET['h'])) if (count ($link) == 0) { require (JIRAFEAU_ROOT.'lib/template/header.php'); - echo '

' . _('Sorry, the requested file is not found') . + echo '

' . t('Sorry, the requested file is not found') . '

'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); exit; @@ -54,7 +54,7 @@ if (isset ($_GET['h']) && !empty ($_GET['h'])) { jirafeau_delete ($link_name); require (JIRAFEAU_ROOT.'lib/template/header.php'); - echo '

'._('File not available.'). + echo '

'.t('File not available.'). '

'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); exit; @@ -64,7 +64,7 @@ if (isset ($_GET['h']) && !empty ($_GET['h'])) { jirafeau_delete ($link_name); require (JIRAFEAU_ROOT.'lib/template/header.php'); - echo '

'._('File has been deleted.'). + echo '

'.t('File has been deleted.'). '

'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); exit; @@ -75,8 +75,8 @@ if (isset ($_GET['h']) && !empty ($_GET['h'])) jirafeau_delete ($link_name); require (JIRAFEAU_ROOT.'lib/template/header.php'); echo '

'. - _('The time limit of this file has expired.') . ' ' . - _('File has been deleted.') . + t('The time limit of this file has expired.') . ' ' . + t('File has been deleted.') . '

'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); exit; @@ -92,13 +92,13 @@ if (isset ($_GET['h']) && !empty ($_GET['h'])) "" method = "post">
- -
" + "" />

' . _('Access denied') . + echo '

' . t('Access denied') . '

'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); exit; diff --git a/index.php b/index.php index 893ebf0..62588aa 100644 --- a/index.php +++ b/index.php @@ -71,21 +71,21 @@ require (JIRAFEAU_ROOT . 'lib/template/header.php'); /* Checking for errors. */ if (!is_writable (VAR_FILES)) - add_error (_('The file directory is not writable!'), VAR_FILES); + add_error (t('The file directory is not writable!'), VAR_FILES); if (!is_writable (VAR_LINKS)) - add_error (_('The link directory is not writable!'), VAR_LINKS); + add_error (t('The link directory is not writable!'), VAR_LINKS); /* Check if the install.php script is still in the directory. */ if (file_exists (JIRAFEAU_ROOT . 'install.php')) - add_error (_('Installer script still present'), - _('Please make sure to delete the installer script ' . + add_error (t('Installer script still present'), + t('Please make sure to delete the installer script ' . '"install.php" before continuing.')); if (!has_error () && !empty ($res)) { if ($res['error']['has_error']) - add_error (_('An error occurred.'), $res['error']['why']); + add_error (t('An error occurred.'), $res['error']['why']); else { $link = $cfg['web_root']; @@ -106,20 +106,20 @@ if (!has_error () && !empty ($res)) } echo '
'.NL; - echo '

' . _('File uploaded! Copy the following URL to get it') . + echo '

' . t('File uploaded! Copy the following URL to get it') . ':
' . NL; echo ''.$link.'' . NL; if ($time != JIRAFEAU_INFINITY) { - echo '
' . _('This file is valid until the following date') . + echo '
' . t('This file is valid until the following date') . ':
' . strftime ('%c', $time) . ''; } echo '

'; echo '
' . NL; - echo '

' . _('Keep the following URL to delete it at any moment') . ':
' . NL; + echo '

' . t('Keep the following URL to delete it at any moment') . ':
' . NL; echo '' . $delete_link . '' . NL; echo '

'; } @@ -135,30 +135,30 @@ if (!has_error () && $writable) " method = "post">
-

" />

+ "" />



$item) @@ -82,12 +82,12 @@ jirafeau_is_writable ($path) function jirafeau_check_var_dir ($path) { - $mkdir_str1 = _('The following directory could not be created') . ':'; - $mkdir_str2 = _('You should create this directory by hand.'); - $write_str1 = _('The following directory is not writable') . ':'; - $write_str2 = _('You should give the write right to the web server on ' . + $mkdir_str1 = t('The following directory could not be created') . ':'; + $mkdir_str2 = t('You should create this directory by hand.'); + $write_str1 = t('The following directory is not writable') . ':'; + $write_str2 = t('You should give the write right to the web server on ' . 'this directory.'); - $solution_str = _('Here is a solution') . ':'; + $solution_str = t('Here is a solution') . ':'; if (!jirafeau_mkdir ($path) || !jirafeau_is_writable ($path)) return array ('has_error' => true, @@ -122,7 +122,7 @@ if (!file_exists (JIRAFEAU_CFG)) { require (JIRAFEAU_ROOT . 'lib/template/header.php'); echo '

' . - _('The local configuration file could not be created. Create a ' . + t('The local configuration file could not be created. Create a ' . 'lib/config.local.php file and give the write ' . 'right to the web server (preferred solution), or give the ' . 'write right to the web server on the lib ' . @@ -137,7 +137,7 @@ if (!is_writable (JIRAFEAU_CFG) && !@chmod (JIRAFEAU_CFG, '0666')) { require (JIRAFEAU_ROOT . 'lib/template/header.php'); echo '

' . - _('The local configuration is not writable by the web server. ' . + t('The local configuration is not writable by the web server. ' . 'Give the write right to the web server on the ' . 'lib/config.local.php file.') . '

'; @@ -191,20 +191,20 @@ switch ($current) { case 1: default: - ?>

+ "" />

@@ -250,29 +250,29 @@ case 2:
+ "" />

+ echo t('Previous step'); ?>" /> + " />

" />" /> + "" />
'; } else { echo '

' . - _('Jirafeau is now fully operational') . ':' . + t('Jirafeau is now fully operational') . ':' . '
' . $cfg['web_root'].'

'; } diff --git a/lib/functions.php b/lib/functions.php index d4a5e6a..7b63148 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -67,26 +67,26 @@ jirafeau_upload_errstr ($code) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: - return _('Your file exceeds the maximum authorized file size. '); + return t('Your file exceeds the maximum authorized file size. '); break; case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_NO_FILE: return - _ + t ('Your file was not uploaded correctly. You may succeed in retrying. '); break; case UPLOAD_ERR_NO_TMP_DIR: case UPLOAD_ERR_CANT_WRITE: case UPLOAD_ERR_EXTENSION: - return _('Internal error. You may not succeed in retrying. '); + return t('Internal error. You may not succeed in retrying. '); break; default: break; } - return _('Unknown error. '); + return t('Unknown error. '); } /** Remove link and it's file @@ -208,7 +208,7 @@ jirafeau_upload ($file, $one_time_download, $key, $time, $cfg, $ip) return (array( 'error' => array ('has_error' => true, - 'why' => _('Internal error during file creation. ')), + 'why' => t('Internal error during file creation. ')), 'link' =>'', 'delete_link' => '')); } @@ -262,7 +262,7 @@ jirafeau_upload ($file, $one_time_download, $key, $time, $cfg, $ip) return (array( 'error' => array ('has_error' => true, - 'why' => _('Internal error during file creation. ')), + 'why' => t('Internal error during file creation. ')), 'link' =>'', 'delete_link' => '')); } @@ -388,18 +388,18 @@ jirafeau_admin_list ($name, $file_hash, $link_hash) if (!empty ($link_hash)) echo $link_hash . ' '; if (empty ($name) && empty ($file_hash) && empty ($link_hash)) - echo _('List all files'); + echo t('List all files'); echo ''; echo ''; echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; foreach ($links_dir as $link) { @@ -431,12 +431,12 @@ jirafeau_admin_list ($name, $file_hash, $link_hash) '' . '' . '' . - '' . + '' . '' . '' . '' . '' . - '' . + '' . '' . ''; echo ''; diff --git a/lib/lang.php b/lib/lang.php index b1265f8..6e592a2 100755 --- a/lib/lang.php +++ b/lib/lang.php @@ -23,7 +23,7 @@ 'fr' => 'Français'); /* Translation */ -function _ ($text) +function t ($text) { $cfg = $GLOBALS['cfg']; $languages_list = $GLOBALS['languages_list']; diff --git a/lib/template/footer.php b/lib/template/footer.php index 07911b9..4356961 100644 --- a/lib/template/footer.php +++ b/lib/template/footer.php @@ -1,7 +1,7 @@ diff --git a/lib/template/header.php b/lib/template/header.php index f9a4904..eef9fe9 100644 --- a/lib/template/header.php +++ b/lib/template/header.php @@ -12,11 +12,11 @@ header('Content-Type: ' . $content_type); - <?php echo _('Jirafeau, your web file repository'); ?> + <?php echo t('Jirafeau, your web file repository'); ?>
-

+

' . _('Filename') . '' . _('Type') . '' . _('Size') . '' . _('Expire') . '' . _('Onetime') . '' . _('Upload date') . '' . _('Origin') . '' . _('Action') . '' . t('Filename') . '' . t('Type') . '' . t('Size') . '' . t('Expire') . '' . t('Onetime') . '' . t('Upload date') . '' . t('Origin') . '' . t('Action') . '