Skip to content

Commit

Permalink
FIX remove english strings for ALL modules, not just the first
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Feb 8, 2024
1 parent 715713c commit f9cb851
Showing 1 changed file with 6 additions and 16 deletions.
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

0 comments on commit f9cb851

Please sign in to comment.