From 33b11682f9826346f48b7587161dc5a43944a063 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?= <thomas.mueller@tmit.eu>
Date: Tue, 24 Feb 2015 17:20:59 +0100
Subject: [PATCH] translate error messages

---
 lib/private/files/storage/common.php | 17 +++++++++++------
 lib/private/files/view.php           |  8 +++++---
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index 091f89662d..e948b5aa35 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -471,12 +471,12 @@ abstract class Common implements \OC\Files\Storage\Storage {
 	 * @param string $fileName
 	 * @throws InvalidPathException
 	 */
-	private function verifyWindowsPath($fileName) {
+	protected function verifyWindowsPath($fileName) {
 		$fileName = trim($fileName);
 		$this->scanForInvalidCharacters($fileName, "\\/<>:\"|?*");
 		$reservedNames = ['CON', 'PRN', 'AUX', 'NUL', 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9'];
 		if (in_array(strtoupper($fileName), $reservedNames)) {
-				throw new InvalidPathException("File name is a reserved word");
+			throw new InvalidPathException($this->t("File name is a reserved word"));
 		}
 	}
 
@@ -484,12 +484,12 @@ abstract class Common implements \OC\Files\Storage\Storage {
 	 * @param string $fileName
 	 * @throws InvalidPathException
 	 */
-	private function verifyPosixPath($fileName) {
+	protected function verifyPosixPath($fileName) {
 		$fileName = trim($fileName);
 		$this->scanForInvalidCharacters($fileName, "\\/");
 		$reservedNames = ['*'];
 		if (in_array($fileName, $reservedNames)) {
-			throw new InvalidPathException("File name is a reserved word");
+			throw new InvalidPathException($this->t('File name is a reserved word'));
 		}
 	}
 
@@ -501,14 +501,19 @@ abstract class Common implements \OC\Files\Storage\Storage {
 	private function scanForInvalidCharacters($fileName, $invalidChars) {
 		foreach(str_split($invalidChars) as $char) {
 			if (strpos($fileName, $char) !== false) {
-				throw new InvalidPathException('File name contains at least one invalid characters');
+				throw new InvalidPathException($this->t('File name contains at least one invalid characters'));
 			}
 		}
 
 		$sanitizedFileName = filter_var($fileName, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
 		if($sanitizedFileName !== $fileName) {
-			throw new InvalidPathException('File name contains at least one invalid characters');
+			throw new InvalidPathException($this->t('File name contains at least one invalid characters'));
 		}
 	}
 
+	private function t($string) {
+		$l10n = \OC::$server->getL10N('lib');
+		return $l10n->t($string);
+	}
+
 }
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 6a93d7bbf8..9d8416d233 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1543,13 +1543,15 @@ class View {
 	 */
 	public function verifyPath($path, $fileName) {
 
+		$l10n = \OC::$server->getL10N('lib');
+
 		// verify empty and dot files
 		$trimmed = trim($fileName);
 		if ($trimmed === '') {
-			throw new InvalidPathException('Empty filename is not allowed');
+			throw new InvalidPathException($l10n->t('Empty filename is not allowed'));
 		}
 		if ($trimmed === '.' || $trimmed === '..') {
-			throw new InvalidPathException('Dot files are not allowed');
+			throw new InvalidPathException($l10n->t('Dot files are not allowed'));
 		}
 
 		// verify database - e.g. mysql only 3-byte chars
@@ -1558,7 +1560,7 @@ class View {
     | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
     | \xF4[\x80-\x8F][\x80-\xBF]{2}      # plane 16
 )*$%xs', $fileName)) {
-			throw new InvalidPathException('4-byte characters are not supported in file names');
+			throw new InvalidPathException($l10n->t('4-byte characters are not supported in file names'));
 		}
 
 		/** @type \OCP\Files\Storage $storage */
-- 
GitLab