Skip to content
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

FIX remove english strings for ALL modules, not just the first #25

Merged
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
22 changes: 6 additions & 16 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class Translator

private array $modulePaths = [];

/** Original json content for ALL modules */
private array $originalJson = [];

/** Original yaml content for ALL modules */
private array $originalYaml = [];

private array $pullRequestUrls = [];
Expand Down Expand Up @@ -312,19 +314,13 @@ private function mergeYaml(): void
private function removeEnglishStringsFromYamlTranslations(): void
{
$this->log('Removing english from yml translation files');
$enPath = '';
$enYaml = null;
$count = 0;
foreach (array_keys($this->originalYaml) as $path) {
if (!file_exists($path)) {
continue;
}
if (!$enPath) {
$enPath = preg_replace('#/[^/\.]+\.yml#', '/en.yml', $path);
}
if (!$enYaml) {
$enYaml = Yaml::parse(file_get_contents($enPath));
}
$enPath = preg_replace('#/[^/\.]+\.yml#', '/en.yml', $path);
$enYaml = Yaml::parse(file_get_contents($enPath));
if ($enPath === $path) {
continue;
}
Expand Down Expand Up @@ -454,19 +450,13 @@ private function mergeJson(): void
private function removeEnglishStringsFromJsonTranslations(): void
{
$this->log('Removing english from json translation files');
$enPath = '';
$enJson = null;
$count = 0;
foreach (array_keys($this->originalJson) as $path) {
if (!file_exists($path)) {
continue;
}
if (!$enPath) {
$enPath = preg_replace('#/[^/\.]+\.json$#', '/en.json', $path);
}
if (!$enJson) {
$enJson = $this->jsonDecode(file_get_contents($enPath));
}
$enPath = preg_replace('#/[^/\.]+\.json$#', '/en.json', $path);
$enJson = $this->jsonDecode(file_get_contents($enPath));
if ($enPath === $path) {
continue;
}
Expand Down
Loading