Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions infra/LocaleGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class LocaleGenerator
private const FUNCTION_NAME_LIST_FIRST_ROW = 4;
private const ENGLISH_FUNCTION_CATEGORIES_COLUMN = 'A';
private const ENGLISH_REFERENCE_COLUMN = 'B';
private const EOL = "\n"; // not PHP_EOL

/**
* @var string
Expand Down Expand Up @@ -109,10 +110,10 @@ protected function buildConfigFileForLocale($column, $locale): void
$translationCell = $this->localeTranslations->getCell($column . $row);
$translationValue = $translationCell->getValue();
if (!empty($translationValue)) {
$errorCodeTranslation = "{$errorCode} = {$translationValue}" . PHP_EOL;
$errorCodeTranslation = "{$errorCode} = {$translationValue}" . self::EOL;
fwrite($configFile, $errorCodeTranslation);
} else {
$errorCodeTranslation = "{$errorCode}" . PHP_EOL;
$errorCodeTranslation = "{$errorCode}" . self::EOL;
fwrite($configFile, $errorCodeTranslation);
$this->log("No {$language} translation available for error code {$errorCode}");
}
Expand All @@ -126,7 +127,7 @@ protected function writeConfigArgumentSeparator($configFile, $column): void
$translationCell = $this->localeTranslations->getCell($column . self::ARGUMENT_SEPARATOR_ROW);
$localeValue = $translationCell->getValue();
if (!empty($localeValue)) {
$functionTranslation = "ArgumentSeparator = {$localeValue}" . PHP_EOL;
$functionTranslation = "ArgumentSeparator = {$localeValue}" . self::EOL;
fwrite($configFile, $functionTranslation);
} else {
$this->log('No Argument Separator defined');
Expand All @@ -148,7 +149,7 @@ protected function buildFunctionsFileForLocale($column, $locale): void
} elseif (!array_key_exists($functionName, $this->phpSpreadsheetFunctions)) {
$this->log("Function {$functionName} is not defined in PhpSpreadsheet");
} elseif (!empty($translationValue)) {
$functionTranslation = "{$functionName} = {$translationValue}" . PHP_EOL;
$functionTranslation = "{$functionName} = {$translationValue}" . self::EOL;
fwrite($functionFile, $functionTranslation);
} else {
$this->log("No {$language} translation available for function {$functionName}");
Expand Down Expand Up @@ -200,20 +201,20 @@ protected function getLocaleFolder(string $locale): string

protected function writeFileHeader($localeFile, string $localeLanguage, string $language, string $title): void
{
fwrite($localeFile, str_repeat('#', 60) . PHP_EOL);
fwrite($localeFile, '##' . PHP_EOL);
fwrite($localeFile, "## PhpSpreadsheet - {$title}" . PHP_EOL);
fwrite($localeFile, '##' . PHP_EOL);
fwrite($localeFile, "## {$localeLanguage} ({$language})" . PHP_EOL);
fwrite($localeFile, '##' . PHP_EOL);
fwrite($localeFile, str_repeat('#', 60) . PHP_EOL . PHP_EOL);
fwrite($localeFile, str_repeat('#', 60) . self::EOL);
fwrite($localeFile, '##' . self::EOL);
fwrite($localeFile, "## PhpSpreadsheet - {$title}" . self::EOL);
fwrite($localeFile, '##' . self::EOL);
fwrite($localeFile, "## {$localeLanguage} ({$language})" . self::EOL);
fwrite($localeFile, '##' . self::EOL);
fwrite($localeFile, str_repeat('#', 60) . self::EOL . self::EOL);
}

protected function writeFileSectionHeader($localeFile, string $header): void
{
fwrite($localeFile, PHP_EOL . '##' . PHP_EOL);
fwrite($localeFile, "## {$header}" . PHP_EOL);
fwrite($localeFile, '##' . PHP_EOL);
fwrite($localeFile, self::EOL . '##' . self::EOL);
fwrite($localeFile, "## {$header}" . self::EOL);
fwrite($localeFile, '##' . self::EOL);
}

protected function openTranslationWorkbook(): void
Expand Down Expand Up @@ -339,6 +340,6 @@ private function log(string $message): void
return;
}

echo $message, PHP_EOL;
echo $message, self::EOL;
}
}