Skip to content

Commit 1a581d2

Browse files
authored
Merge pull request #7 from franzholz/develop
Make translated files convertable
2 parents 02be4fe + a147ebc commit 1a581d2

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Classes/Utility/Convert.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,16 @@ public function writeXmlAsXlfFilesInPlace(string $sourceFile): string
6363
return $fileCheckResult;
6464
}
6565

66+
$sourceFileOriginal = $sourceFile;
67+
$basename = basename($sourceFile);
68+
$dirname = dirname($sourceFile);
69+
if (($position = strpos($basename, '.')) == 2) {
70+
$sourceFileOriginal = $dirname . '/' . substr($basename, $position + 1);
71+
}
6672
$languages = $this->getAvailableTranslations($sourceFile);
6773
$errors = [];
6874
foreach ($languages as $langKey) {
69-
$newFileName = dirname($sourceFile) . '/' . $this->localizedFileRef($sourceFile, $langKey);
75+
$newFileName = $dirname . '/' . $this->localizedFileRef($sourceFileOriginal, $langKey);
7076
if (@is_file($newFileName)) {
7177
$errors[] = 'ERROR: Output file "' . $newFileName . '" already exists!';
7278
}
@@ -78,7 +84,7 @@ public function writeXmlAsXlfFilesInPlace(string $sourceFile): string
7884

7985
$output = '';
8086
foreach ($languages as $langKey) {
81-
$newFileName = dirname($sourceFile) . '/' . $this->localizedFileRef($sourceFile, $langKey);
87+
$newFileName = $dirname . '/' . $this->localizedFileRef($sourceFileOriginal, $langKey);
8288
$output .= $this->writeNewXliffFile($sourceFile, $newFileName, $langKey) . '<br />';
8389
}
8490
return $output;
@@ -105,11 +111,9 @@ public function writePhpAsXlfFilesInPlace(string $sourceFile): string
105111
*/
106112
protected function checkLanguageFilename(string $xmlFile): string
107113
{
108-
$basename = basename($xmlFile);
109-
110114
$result = '';
111-
if (strpos($basename, 'locallang') !== 0) {
112-
$result = 'ERROR: Filename didn\'t start with "locallang".';
115+
if (strpos($xmlFile, 'locallang') === false) {
116+
$result = 'ERROR: Filename didn\'t contain "locallang".';
113117
}
114118
return $result;
115119
}

0 commit comments

Comments
 (0)