Locale Generator - Change to Use Unix Line Endings Even on Windows (#2174)

See issue #2172. The locale files are regenerated whenever the test suite is run.

The use of PHP_EOL in LocaleGenerator.php is awkward on Windows systems, since it causes git to think the file has changed. Change to use `"\n"` instead.
This commit is contained in:
oleibman 2021-06-19 01:20:16 -07:00 committed by GitHub
parent 33ef03d1fa
commit d200c5363f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 15 deletions

View File

@ -25,6 +25,7 @@ class LocaleGenerator
private const FUNCTION_NAME_LIST_FIRST_ROW = 4; private const FUNCTION_NAME_LIST_FIRST_ROW = 4;
private const ENGLISH_FUNCTION_CATEGORIES_COLUMN = 'A'; private const ENGLISH_FUNCTION_CATEGORIES_COLUMN = 'A';
private const ENGLISH_REFERENCE_COLUMN = 'B'; private const ENGLISH_REFERENCE_COLUMN = 'B';
private const EOL = "\n"; // not PHP_EOL
/** /**
* @var string * @var string
@ -109,10 +110,10 @@ class LocaleGenerator
$translationCell = $this->localeTranslations->getCell($column . $row); $translationCell = $this->localeTranslations->getCell($column . $row);
$translationValue = $translationCell->getValue(); $translationValue = $translationCell->getValue();
if (!empty($translationValue)) { if (!empty($translationValue)) {
$errorCodeTranslation = "{$errorCode} = {$translationValue}" . PHP_EOL; $errorCodeTranslation = "{$errorCode} = {$translationValue}" . self::EOL;
fwrite($configFile, $errorCodeTranslation); fwrite($configFile, $errorCodeTranslation);
} else { } else {
$errorCodeTranslation = "{$errorCode}" . PHP_EOL; $errorCodeTranslation = "{$errorCode}" . self::EOL;
fwrite($configFile, $errorCodeTranslation); fwrite($configFile, $errorCodeTranslation);
$this->log("No {$language} translation available for error code {$errorCode}"); $this->log("No {$language} translation available for error code {$errorCode}");
} }
@ -126,7 +127,7 @@ class LocaleGenerator
$translationCell = $this->localeTranslations->getCell($column . self::ARGUMENT_SEPARATOR_ROW); $translationCell = $this->localeTranslations->getCell($column . self::ARGUMENT_SEPARATOR_ROW);
$localeValue = $translationCell->getValue(); $localeValue = $translationCell->getValue();
if (!empty($localeValue)) { if (!empty($localeValue)) {
$functionTranslation = "ArgumentSeparator = {$localeValue}" . PHP_EOL; $functionTranslation = "ArgumentSeparator = {$localeValue}" . self::EOL;
fwrite($configFile, $functionTranslation); fwrite($configFile, $functionTranslation);
} else { } else {
$this->log('No Argument Separator defined'); $this->log('No Argument Separator defined');
@ -148,7 +149,7 @@ class LocaleGenerator
} elseif (!array_key_exists($functionName, $this->phpSpreadsheetFunctions)) { } elseif (!array_key_exists($functionName, $this->phpSpreadsheetFunctions)) {
$this->log("Function {$functionName} is not defined in PhpSpreadsheet"); $this->log("Function {$functionName} is not defined in PhpSpreadsheet");
} elseif (!empty($translationValue)) { } elseif (!empty($translationValue)) {
$functionTranslation = "{$functionName} = {$translationValue}" . PHP_EOL; $functionTranslation = "{$functionName} = {$translationValue}" . self::EOL;
fwrite($functionFile, $functionTranslation); fwrite($functionFile, $functionTranslation);
} else { } else {
$this->log("No {$language} translation available for function {$functionName}"); $this->log("No {$language} translation available for function {$functionName}");
@ -200,20 +201,20 @@ class LocaleGenerator
protected function writeFileHeader($localeFile, string $localeLanguage, string $language, string $title): void protected function writeFileHeader($localeFile, string $localeLanguage, string $language, string $title): void
{ {
fwrite($localeFile, str_repeat('#', 60) . PHP_EOL); fwrite($localeFile, str_repeat('#', 60) . self::EOL);
fwrite($localeFile, '##' . PHP_EOL); fwrite($localeFile, '##' . self::EOL);
fwrite($localeFile, "## PhpSpreadsheet - {$title}" . PHP_EOL); fwrite($localeFile, "## PhpSpreadsheet - {$title}" . self::EOL);
fwrite($localeFile, '##' . PHP_EOL); fwrite($localeFile, '##' . self::EOL);
fwrite($localeFile, "## {$localeLanguage} ({$language})" . PHP_EOL); fwrite($localeFile, "## {$localeLanguage} ({$language})" . self::EOL);
fwrite($localeFile, '##' . PHP_EOL); fwrite($localeFile, '##' . self::EOL);
fwrite($localeFile, str_repeat('#', 60) . PHP_EOL . PHP_EOL); fwrite($localeFile, str_repeat('#', 60) . self::EOL . self::EOL);
} }
protected function writeFileSectionHeader($localeFile, string $header): void protected function writeFileSectionHeader($localeFile, string $header): void
{ {
fwrite($localeFile, PHP_EOL . '##' . PHP_EOL); fwrite($localeFile, self::EOL . '##' . self::EOL);
fwrite($localeFile, "## {$header}" . PHP_EOL); fwrite($localeFile, "## {$header}" . self::EOL);
fwrite($localeFile, '##' . PHP_EOL); fwrite($localeFile, '##' . self::EOL);
} }
protected function openTranslationWorkbook(): void protected function openTranslationWorkbook(): void
@ -339,6 +340,6 @@ class LocaleGenerator
return; return;
} }
echo $message, PHP_EOL; echo $message, self::EOL;
} }
} }