Merge pull request #8777 from owncloud/l10n-utils-and-defaults

more strings to translate in utils also some fixes in defaults
This commit is contained in:
Morris Jobke 2014-06-28 15:40:49 +02:00
commit 9890b1509d
3 changed files with 72 additions and 60 deletions

View File

@ -179,20 +179,22 @@ class OC {
} }
public static function checkConfig() { public static function checkConfig() {
$l = OC_L10N::get('lib');
if (file_exists(self::$configDir . "/config.php") if (file_exists(self::$configDir . "/config.php")
and !is_writable(self::$configDir . "/config.php") and !is_writable(self::$configDir . "/config.php")
) { ) {
if (self::$CLI) { if (self::$CLI) {
echo "Can't write into config directory!\n"; echo $l->t('Cannot write into "config" directory!')."\n";
echo "This can usually be fixed by giving the webserver write access to the config directory\n"; echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n";
echo "\n"; echo "\n";
echo "See " . \OC_Helper::linkToDocs('admin-dir_permissions') . "\n"; echo $l->t('See %s', array(\OC_Helper::linkToDocs('admin-dir_permissions')))."\n";
exit; exit;
} else { } else {
OC_Template::printErrorPage( OC_Template::printErrorPage(
"Can't write into config directory!", $l->t('Cannot write into "config" directory!'),
'This can usually be fixed by ' $l->t('This can usually be fixed by '
. '<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">giving the webserver write access to the config directory</a>.' . '%sgiving the webserver write access to the config directory%s.',
array('<a href="'.\OC_Helper::linkToDocs('admin-dir_permissions').'" target="_blank">', '</a>'))
); );
} }
} }

View File

@ -19,12 +19,14 @@ class OC_Defaults {
private $defaultBaseUrl; private $defaultBaseUrl;
private $defaultSyncClientUrl; private $defaultSyncClientUrl;
private $defaultDocBaseUrl; private $defaultDocBaseUrl;
private $defaultDocVersion;
private $defaultSlogan; private $defaultSlogan;
private $defaultLogoClaim; private $defaultLogoClaim;
private $defaultMailHeaderColor; private $defaultMailHeaderColor;
function __construct() { function __construct() {
$this->l = OC_L10N::get('core'); $this->l = OC_L10N::get('lib');
$version = OC_Util::getVersion();
$this->defaultEntity = "ownCloud"; /* e.g. company name, used for footers and copyright notices */ $this->defaultEntity = "ownCloud"; /* e.g. company name, used for footers and copyright notices */
$this->defaultName = "ownCloud"; /* short name, used when referring to the software */ $this->defaultName = "ownCloud"; /* short name, used when referring to the software */
@ -32,6 +34,7 @@ class OC_Defaults {
$this->defaultBaseUrl = "https://owncloud.org"; $this->defaultBaseUrl = "https://owncloud.org";
$this->defaultSyncClientUrl = "https://owncloud.org/sync-clients/"; $this->defaultSyncClientUrl = "https://owncloud.org/sync-clients/";
$this->defaultDocBaseUrl = "http://doc.owncloud.org"; $this->defaultDocBaseUrl = "http://doc.owncloud.org";
$this->defaultDocVersion = $version[0] . ".0"; // used to generate doc links
$this->defaultSlogan = $this->l->t("web services under your control"); $this->defaultSlogan = $this->l->t("web services under your control");
$this->defaultLogoClaim = ""; $this->defaultLogoClaim = "";
$this->defaultMailHeaderColor = "#1d2d44"; /* header color of mail notifications */ $this->defaultMailHeaderColor = "#1d2d44"; /* header color of mail notifications */
@ -180,7 +183,7 @@ class OC_Defaults {
if ($this->themeExist('buildDocLinkToKey')) { if ($this->themeExist('buildDocLinkToKey')) {
return $this->theme->buildDocLinkToKey($key); return $this->theme->buildDocLinkToKey($key);
} }
return $this->getDocBaseUrl() . '/server/6.0/go.php?to=' . $key; return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
} }
/** /**

View File

@ -374,6 +374,7 @@ class OC_Util {
* @return array arrays with error messages and hints * @return array arrays with error messages and hints
*/ */
public static function checkServer() { public static function checkServer() {
$l = OC_L10N::get('lib');
$errors = array(); $errors = array();
$CONFIG_DATADIRECTORY = OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data'); $CONFIG_DATADIRECTORY = OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data');
@ -394,24 +395,24 @@ class OC_Util {
and !is_callable('pg_connect') and !is_callable('pg_connect')
and !is_callable('oci_connect')) { and !is_callable('oci_connect')) {
$errors[] = array( $errors[] = array(
'error'=>'No database drivers (sqlite, mysql, or postgresql) installed.', 'error'=> $l->t('No database drivers (sqlite, mysql, or postgresql) installed.'),
'hint'=>'' //TODO: sane hint 'hint'=>'' //TODO: sane hint
); );
$webServerRestart = true; $webServerRestart = true;
} }
//common hint for all file permissions error messages //common hint for all file permissions error messages
$permissionsHint = 'Permissions can usually be fixed by ' $permissionsHint = $l->t('Permissions can usually be fixed by '
.'<a href="' . OC_Helper::linkToDocs('admin-dir_permissions') .'%sgiving the webserver write access to the root directory%s.',
.'" target="_blank">giving the webserver write access to the root directory</a>.'; array('<a href="'.\OC_Helper::linkToDocs('admin-dir_permissions').'" target="_blank">', '</a>'));
// Check if config folder is writable. // Check if config folder is writable.
if(!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { if(!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) {
$errors[] = array( $errors[] = array(
'error' => "Can't write into config directory", 'error' => $l->t('Cannot write into "config" directory'),
'hint' => 'This can usually be fixed by ' 'hint' => $l->t('This can usually be fixed by '
.'<a href="' . OC_Helper::linkToDocs('admin-dir_permissions') .'%sgiving the webserver write access to the config directory%s.',
.'" target="_blank">giving the webserver write access to the config directory</a>.' array('<a href="'.\OC_Helper::linkToDocs('admin-dir_permissions').'" target="_blank">', '</a>'))
); );
} }
@ -421,11 +422,11 @@ class OC_Util {
|| !is_writable(OC_App::getInstallPath()) || !is_writable(OC_App::getInstallPath())
|| !is_readable(OC_App::getInstallPath()) ) { || !is_readable(OC_App::getInstallPath()) ) {
$errors[] = array( $errors[] = array(
'error' => "Can't write into apps directory", 'error' => $l->t('Cannot write into "apps" directory'),
'hint' => 'This can usually be fixed by ' 'hint' => $l->t('This can usually be fixed by '
.'<a href="' . OC_Helper::linkToDocs('admin-dir_permissions') .'%sgiving the webserver write access to the apps directory%s'
.'" target="_blank">giving the webserver write access to the apps directory</a> ' .' or disabling the appstore in the config file.',
.'or disabling the appstore in the config file.' array('<a href="'.\OC_Helper::linkToDocs('admin-dir_permissions').'" target="_blank">', '</a>'))
); );
} }
} }
@ -436,11 +437,11 @@ class OC_Util {
$errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY));
} else { } else {
$errors[] = array( $errors[] = array(
'error' => "Can't create data directory (".$CONFIG_DATADIRECTORY.")", 'error' => $l->t('Cannot create "data" directory (%s)', array($CONFIG_DATADIRECTORY)),
'hint' => 'This can usually be fixed by ' 'hint' => $l->t('This can usually be fixed by '
.'<a href="' . OC_Helper::linkToDocs('admin-dir_permissions') .'<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.',
.'" target="_blank">giving the webserver write access to the root directory</a>.' array(OC_Helper::linkToDocs('admin-dir_permissions')))
); );
} }
} else if(!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { } else if(!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
$errors[] = array( $errors[] = array(
@ -453,30 +454,32 @@ class OC_Util {
if(!OC_Util::isSetLocaleWorking()) { if(!OC_Util::isSetLocaleWorking()) {
$errors[] = array( $errors[] = array(
'error' => 'Setting locale to en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8 failed', 'error' => $l->t('Setting locale to %s failed',
'hint' => 'Please install one of theses locales on your system and restart your webserver.' array('en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/'
.'pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8')),
'hint' => $l->t('Please install one of theses locales on your system and restart your webserver.')
); );
} }
$moduleHint = "Please ask your server administrator to install the module."; $moduleHint = $l->t('Please ask your server administrator to install the module.');
// check if all required php modules are present // check if all required php modules are present
if(!class_exists('ZipArchive')) { if(!class_exists('ZipArchive')) {
$errors[] = array( $errors[] = array(
'error'=>'PHP module zip not installed.', 'error'=> $l->t('PHP module %s not installed.', array('zip')),
'hint'=>$moduleHint 'hint'=>$moduleHint
); );
$webServerRestart = true; $webServerRestart = true;
} }
if(!class_exists('DOMDocument')) { if(!class_exists('DOMDocument')) {
$errors[] = array( $errors[] = array(
'error' => 'PHP module dom not installed.', 'error'=> $l->t('PHP module %s not installed.', array('dom')),
'hint' => $moduleHint 'hint' => $moduleHint
); );
$webServerRestart =true; $webServerRestart =true;
} }
if(!function_exists('xml_parser_create')) { if(!function_exists('xml_parser_create')) {
$errors[] = array( $errors[] = array(
'error' => 'PHP module libxml not installed.', 'error'=> $l->t('PHP module %s not installed.', array('libxml')),
'hint' => $moduleHint 'hint' => $moduleHint
); );
$webServerRestart = true; $webServerRestart = true;
@ -490,57 +493,57 @@ class OC_Util {
} }
if(!function_exists('ctype_digit')) { if(!function_exists('ctype_digit')) {
$errors[] = array( $errors[] = array(
'error'=>'PHP module ctype is not installed.', 'error'=> $l->t('PHP module %s not installed.', array('ctype')),
'hint'=>$moduleHint 'hint'=>$moduleHint
); );
$webServerRestart = true; $webServerRestart = true;
} }
if(!function_exists('json_encode')) { if(!function_exists('json_encode')) {
$errors[] = array( $errors[] = array(
'error'=>'PHP module JSON is not installed.', 'error'=> $l->t('PHP module %s not installed.', array('JSON')),
'hint'=>$moduleHint 'hint'=>$moduleHint
); );
$webServerRestart = true; $webServerRestart = true;
} }
if(!extension_loaded('gd') || !function_exists('gd_info')) { if(!extension_loaded('gd') || !function_exists('gd_info')) {
$errors[] = array( $errors[] = array(
'error'=>'PHP module GD is not installed.', 'error'=> $l->t('PHP module %s not installed.', array('GD')),
'hint'=>$moduleHint 'hint'=>$moduleHint
); );
$webServerRestart = true; $webServerRestart = true;
} }
if(!function_exists('gzencode')) { if(!function_exists('gzencode')) {
$errors[] = array( $errors[] = array(
'error'=>'PHP module zlib is not installed.', 'error'=> $l->t('PHP module %s not installed.', array('zlib')),
'hint'=>$moduleHint 'hint'=>$moduleHint
); );
$webServerRestart = true; $webServerRestart = true;
} }
if(!function_exists('iconv')) { if(!function_exists('iconv')) {
$errors[] = array( $errors[] = array(
'error'=>'PHP module iconv is not installed.', 'error'=> $l->t('PHP module %s not installed.', array('iconv')),
'hint'=>$moduleHint 'hint'=>$moduleHint
); );
$webServerRestart = true; $webServerRestart = true;
} }
if(!function_exists('simplexml_load_string')) { if(!function_exists('simplexml_load_string')) {
$errors[] = array( $errors[] = array(
'error'=>'PHP module SimpleXML is not installed.', 'error'=> $l->t('PHP module %s not installed.', array('SimpleXML')),
'hint'=>$moduleHint 'hint'=>$moduleHint
); );
$webServerRestart = true; $webServerRestart = true;
} }
if(version_compare(phpversion(), '5.3.3', '<')) { if(version_compare(phpversion(), '5.3.3', '<')) {
$errors[] = array( $errors[] = array(
'error'=>'PHP 5.3.3 or higher is required.', 'error'=> $l->t('PHP %s or higher is required.', '5.3.3'),
'hint'=>'Please ask your server administrator to update PHP to the latest version.' 'hint'=> $l->t('Please ask your server administrator to update PHP to the latest version.'
.' Your PHP version is no longer supported by ownCloud and the PHP community.' .' Your PHP version is no longer supported by ownCloud and the PHP community.')
); );
$webServerRestart = true; $webServerRestart = true;
} }
if(!defined('PDO::ATTR_DRIVER_NAME')) { if(!defined('PDO::ATTR_DRIVER_NAME')) {
$errors[] = array( $errors[] = array(
'error'=>'PHP PDO module is not installed.', 'error'=> $l->t('PHP module %s not installed.', array('PDO')),
'hint'=>$moduleHint 'hint'=>$moduleHint
); );
$webServerRestart = true; $webServerRestart = true;
@ -550,17 +553,17 @@ class OC_Util {
|| (strtolower(@ini_get('safe_mode')) == 'true') || (strtolower(@ini_get('safe_mode')) == 'true')
|| (ini_get("safe_mode") == 1 ))) { || (ini_get("safe_mode") == 1 ))) {
$errors[] = array( $errors[] = array(
'error'=>'PHP Safe Mode is enabled. ownCloud requires that it is disabled to work properly.', 'error'=> $l->t('PHP Safe Mode is enabled. ownCloud requires that it is disabled to work properly.'),
'hint'=>'PHP Safe Mode is a deprecated and mostly useless setting that should be disabled. ' 'hint'=> $l->t('PHP Safe Mode is a deprecated and mostly useless setting that should be disabled. '
.'Please ask your server administrator to disable it in php.ini or in your webserver config.' .'Please ask your server administrator to disable it in php.ini or in your webserver config.')
); );
$webServerRestart = true; $webServerRestart = true;
} }
if (get_magic_quotes_gpc() == 1 ) { if (get_magic_quotes_gpc() == 1 ) {
$errors[] = array( $errors[] = array(
'error'=>'Magic Quotes is enabled. ownCloud requires that it is disabled to work properly.', 'error'=> $l->t('Magic Quotes is enabled. ownCloud requires that it is disabled to work properly.'),
'hint'=>'Magic Quotes is a deprecated and mostly useless setting that should be disabled. ' 'hint'=> $l->t('Magic Quotes is a deprecated and mostly useless setting that should be disabled. '
.'Please ask your server administrator to disable it in php.ini or in your webserver config.' .'Please ask your server administrator to disable it in php.ini or in your webserver config.')
); );
$webServerRestart = true; $webServerRestart = true;
} }
@ -573,8 +576,8 @@ class OC_Util {
if($webServerRestart) { if($webServerRestart) {
$errors[] = array( $errors[] = array(
'error'=>'PHP modules have been installed, but they are still listed as missing?', 'error'=> $l->t('PHP modules have been installed, but they are still listed as missing?'),
'hint'=>'Please ask your server administrator to restart the web server.' 'hint'=> $l->t('Please ask your server administrator to restart the web server.')
); );
} }
@ -591,6 +594,7 @@ class OC_Util {
* @return array errors array * @return array errors array
*/ */
public static function checkDatabaseVersion() { public static function checkDatabaseVersion() {
$l = OC_L10N::get('lib');
$errors = array(); $errors = array();
$dbType = \OC_Config::getValue('dbtype', 'sqlite'); $dbType = \OC_Config::getValue('dbtype', 'sqlite');
if ($dbType === 'pgsql') { if ($dbType === 'pgsql') {
@ -602,16 +606,17 @@ class OC_Util {
$version = $data['server_version']; $version = $data['server_version'];
if (version_compare($version, '9.0.0', '<')) { if (version_compare($version, '9.0.0', '<')) {
$errors[] = array( $errors[] = array(
'error' => 'PostgreSQL >= 9 required', 'error' => $l->t('PostgreSQL >= 9 required'),
'hint' => 'Please upgrade your database version' 'hint' => $l->t('Please upgrade your database version')
); );
} }
} }
} catch (\Doctrine\DBAL\DBALException $e) { } catch (\Doctrine\DBAL\DBALException $e) {
\OCP\Util::logException('core', $e); \OCP\Util::logException('core', $e);
$errors[] = array( $errors[] = array(
'error' => 'Error occurred while checking PostgreSQL version', 'error' => $l->t('Error occurred while checking PostgreSQL version'),
'hint' => 'Please make sure you have PostgreSQL >= 9 or check the logs for more information about the error' 'hint' => $l->t('Please make sure you have PostgreSQL >= 9 or'
.' check the logs for more information about the error')
); );
} }
} }
@ -667,12 +672,13 @@ class OC_Util {
* @return array arrays with error messages and hints * @return array arrays with error messages and hints
*/ */
public static function checkDataDirectoryPermissions($dataDirectory) { public static function checkDataDirectoryPermissions($dataDirectory) {
$l = OC_L10N::get('lib');
$errors = array(); $errors = array();
if (self::runningOnWindows()) { if (self::runningOnWindows()) {
//TODO: permissions checks for windows hosts //TODO: permissions checks for windows hosts
} else { } else {
$permissionsModHint = 'Please change the permissions to 0770 so that the directory' $permissionsModHint = $l->t('Please change the permissions to 0770 so that the directory'
.' cannot be listed by other users.'; .' cannot be listed by other users.');
$perms = substr(decoct(@fileperms($dataDirectory)), -3); $perms = substr(decoct(@fileperms($dataDirectory)), -3);
if (substr($perms, -1) != '0') { if (substr($perms, -1) != '0') {
chmod($dataDirectory, 0770); chmod($dataDirectory, 0770);
@ -680,7 +686,7 @@ class OC_Util {
$perms = substr(decoct(@fileperms($dataDirectory)), -3); $perms = substr(decoct(@fileperms($dataDirectory)), -3);
if (substr($perms, 2, 1) != '0') { if (substr($perms, 2, 1) != '0') {
$errors[] = array( $errors[] = array(
'error' => 'Data directory ('.$dataDirectory.') is readable for other users', 'error' => $l->t('Data directory (%s) is readable by other users', array($dataDirectory)),
'hint' => $permissionsModHint 'hint' => $permissionsModHint
); );
} }
@ -697,12 +703,13 @@ class OC_Util {
* @return bool true if the data directory is valid, false otherwise * @return bool true if the data directory is valid, false otherwise
*/ */
public static function checkDataDirectoryValidity($dataDirectory) { public static function checkDataDirectoryValidity($dataDirectory) {
$l = OC_L10N::get('lib');
$errors = array(); $errors = array();
if (!file_exists($dataDirectory.'/.ocdata')) { if (!file_exists($dataDirectory.'/.ocdata')) {
$errors[] = array( $errors[] = array(
'error' => 'Data directory (' . $dataDirectory . ') is invalid', 'error' => $l->t('Data directory (%s) is invalid', array($dataDirectory)),
'hint' => 'Please check that the data directory contains a file' . 'hint' => $l->t('Please check that the data directory contains a file' .
' ".ocdata" in its root.' ' ".ocdata" in its root.')
); );
} }
return $errors; return $errors;