From 2030caa0c85102b1cf6131dd9eefef4a347cda42 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 2 Sep 2023 14:59:09 +0200 Subject: translations and story --- db/i18n.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'db/i18n.php') diff --git a/db/i18n.php b/db/i18n.php index b4f7cbc..5cde5c2 100644 --- a/db/i18n.php +++ b/db/i18n.php @@ -14,16 +14,20 @@ function populateI18n ($locale, $poFile) { preg_match('/"(.*)"/', $nextLine, $msgstrMatch); if (empty($msgidMatch[1]) || str_starts_with($msgidMatch[1], 'PROJECT DESCRIPTION')) continue; - $msgid = $msgidMatch[1]; + $msgid = str_replace('\n', '', trim($msgidMatch[1])); // get lines immediately after msgstr $msgstr = $msgstrMatch[1]; $msgstrNextLine = fgets($handle); - while (! empty(trim($msgstrNextLine))) { - preg_match('/"(.*)"/', $msgstrNextLine, $msgstrNextLineMatch); - $msgstr .= $msgstrNextLineMatch[1]; - - $msgstrNextLine = fgets($handle); + if (str_starts_with($msgstrNextLine, 'msgid')) { + fseek($handle, -strlen($msgstrNextLine), SEEK_CUR); + } else { + while (! empty(trim($msgstrNextLine))) { + preg_match('/"(.*)"/', $msgstrNextLine, $msgstrNextLineMatch); + $msgstr .= $msgstrNextLineMatch[1]; + + $msgstrNextLine = fgets($handle); + } } $i18n[$locale][$msgid] = mb_convert_encoding($msgstr, 'UTF-8'); -- cgit v1.2.3