[Scummvm-git-logs] scummvm-web master -> da4fe5de77ae6fd188f08dd6cb3a4741faf540a4
Mataniko
mataniko at gmail.com
Tue Aug 4 12:30:39 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .
Summary:
da4fe5de77 I18N: Properly handle non-translated news
Commit: da4fe5de77ae6fd188f08dd6cb3a4741faf540a4
https://github.com/scummvm/scummvm-web/commit/da4fe5de77ae6fd188f08dd6cb3a4741faf540a4
Author: mataniko (mataniko at gmail.com)
Date: 2020-08-04T08:30:25-04:00
Commit Message:
I18N: Properly handle non-translated news
Changed paths:
include/I18N.php
diff --git a/include/I18N.php b/include/I18N.php
index 570a090f..856f5513 100644
--- a/include/I18N.php
+++ b/include/I18N.php
@@ -55,27 +55,27 @@ class I18N
echo("Converting " . DIR_NEWS . "/i18n/news.{$lang}.json to individual Markdown files\n");
$i18n = json_decode(file_get_contents(DIR_NEWS . "/i18n/news.{$lang}.json"));
- foreach ($i18n as $key => $value) {
- $object = YamlFrontMatter::parse(file_get_contents(DIR_NEWS . "/{$key}.markdown"));
+ foreach ($i18n as $key => $translatedArticle) {
+ $englishArticle = YamlFrontMatter::parse(file_get_contents(DIR_NEWS . "/{$key}.markdown"));
- $date = $this->purifier->purify($object->date);
- $author = $this->purifier->purify($object->author);
- if (array_key_exists('content', $value)) {
- $title = $this->purifier->purify(str_replace('"', '\"', $value->title));
+ $date = $this->purifier->purify($englishArticle->date);
+ $author = $this->purifier->purify($englishArticle->author);
+ if (array_key_exists('title', $translatedArticle) && $translatedArticle->title) {
+ $title = $this->purifier->purify(str_replace('"', '\"', $translatedArticle->title));
} else {
- $title = $this->purifier->purify(str_replace('"', '\"', $object->title));
+ $title = $this->purifier->purify(str_replace('"', '\"', $englishArticle->title));
}
- if (array_key_exists('content', $value)) {
- $content = $this->purifier->purify(trim($value->content));
+ if (array_key_exists('content', $translatedArticle) && $translatedArticle->content) {
+ $content = $this->purifier->purify(trim($translatedArticle->content));
} else {
- $content = $this->purifier->purify(trim($object->content));
+ $content = $this->purifier->purify(trim($englishArticle->body()));
}
if ($lang === 'fr') {
$content = preg_replace_callback("/(?<=\(http)(.*?)(?=\))/u",
- function($matches) {
+ function($matches) {
return preg_replace("/\x{202f}/u", "", $matches[1]);
- }, $content);
+ }, $content);
}
$yaml = "---\ntitle: \"$title\"\ndate: $date\nauthor: $author\n---\n\n$content\n";
@@ -118,8 +118,8 @@ class I18N
continue;
}
$key = rtrim($filename, ".markdown");
- $object = YamlFrontMatter::parse($data);
- $news[$key] = array('title' => $object->title, 'content' => trim($object->body()));
+ $article = YamlFrontMatter::parse($data);
+ $news[$key] = array('title' => $article->title, 'content' => trim($article->body()));
}
return $news;
}
More information about the Scummvm-git-logs
mailing list