diff options
Diffstat (limited to 'db/i18n.php')
-rw-r--r-- | db/i18n.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/i18n.php b/db/i18n.php new file mode 100644 index 0000000..9e64c91 --- /dev/null +++ b/db/i18n.php @@ -0,0 +1,23 @@ +<?php + +$basePath = dirname(__DIR__) . '/modules/tuxemon/mods/tuxemon/l18n'; +foreach (scandir($basePath) as $dirname) { + if (in_array($dirname, ['.', '..']) || ! is_dir("$basePath/$dirname")) continue; + + $i18n = []; + $poFile = "$basePath/$dirname/LC_MESSAGES/base.po"; + $handle = fopen($poFile, 'r'); + while ($line = fgets($handle)) { + if (str_starts_with($line, 'msgid')) { + $nextLine = fgets($handle); + preg_match('/"(.*)"/', $line, $msgid); + preg_match('/"(.*)"/', $nextLine, $msgstr); + + if (empty($msgid[1])) continue; + + $i18n[$msgid[1]] = mb_convert_encoding($msgstr[1], 'UTF-8'); + } + } + + file_put_contents(__DIR__ . "/i18n/$dirname.json", json_encode($i18n)); +} |