diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-08-19 15:32:48 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-08-19 15:32:48 +0200 |
commit | c1fe94a630a88c4f7203d54f34985c109030791c (patch) | |
tree | e6e75fe468dddddcbe440cbd356ddaaaf605144f /db/i18n.php | |
parent | 218da95a4b387ee5ac25f168d1529419039f2e54 (diff) |
translations
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)); +} |