1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-18 20:41:16 +02:00

Fix issue where wrong directory separator slash could end up in language translation files

This commit is contained in:
Ryan Cramer
2019-12-27 15:57:12 -05:00
parent 7d4ef4b786
commit e7c9a1b79f

View File

@@ -138,6 +138,10 @@ class LanguageTranslator extends Wire {
foreach($translations as $hash => $translation) {
if(!strlen($translation['text'])) unset($translations[$hash]);
}
if(strpos($file, "\\") !== false && strpos($file, "\\" . basename($file))) {
// file has MS-DOS style slashes and they are not escapes, convert to unix
$file = str_replace("\\", '/', $file);
}
return array(
'file' => $file,
'textdomain' => $textdomain,
@@ -257,9 +261,13 @@ class LanguageTranslator extends Wire {
*/
protected function textdomainString($textdomain) {
if(is_string($textdomain) && (strpos($textdomain, DIRECTORY_SEPARATOR) !== false || strpos($textdomain, '/') !== false)) $textdomain = $this->filenameToTextdomain($textdomain); // @werker #424
else if(is_object($textdomain)) $textdomain = $this->objectToTextdomain($textdomain);
else $textdomain = strtolower($textdomain);
if(is_string($textdomain) && (strpos($textdomain, DIRECTORY_SEPARATOR) !== false || strpos($textdomain, '/') !== false)) {
$textdomain = $this->filenameToTextdomain($textdomain); // @werker #424
} else if(is_object($textdomain)) {
$textdomain = $this->objectToTextdomain($textdomain);
} else {
$textdomain = strtolower($textdomain);
}
// just in case there is an extension on it, remove it
if(strpos($textdomain, '.')) $textdomain = basename($textdomain, '.json');