Skip to content

Commit eb51781

Browse files
authored
Merge pull request #89 from TeamEver/eenewe-codex/compléter-les-données-manquantes-lors-de-l-enregistrement-d
Fix missing translations for new blog posts
2 parents f7aad2f + 352a067 commit eb51781

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

controllers/admin/AdminEverpsBlogPostController.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,29 @@ public function postProcess()
11331133
);
11341134
}
11351135
}
1136+
// Copy default language values to empty translations
1137+
$defaultLang = (int) Configuration::get('PS_LANG_DEFAULT');
1138+
foreach (Language::getLanguages(false) as $lang) {
1139+
$idLang = (int) $lang['id_lang'];
1140+
if (empty($post->title[$idLang])) {
1141+
$post->title[$idLang] = $post->title[$defaultLang] ?? '';
1142+
}
1143+
if (empty($post->content[$idLang])) {
1144+
$post->content[$idLang] = $post->content[$defaultLang] ?? '';
1145+
}
1146+
if (empty($post->excerpt[$idLang])) {
1147+
$post->excerpt[$idLang] = $post->excerpt[$defaultLang] ?? '';
1148+
}
1149+
if (empty($post->meta_title[$idLang])) {
1150+
$post->meta_title[$idLang] = $post->meta_title[$defaultLang] ?? '';
1151+
}
1152+
if (empty($post->meta_description[$idLang])) {
1153+
$post->meta_description[$idLang] = $post->meta_description[$defaultLang] ?? '';
1154+
}
1155+
if (empty($post->link_rewrite[$idLang])) {
1156+
$post->link_rewrite[$idLang] = $post->link_rewrite[$defaultLang] ?? '';
1157+
}
1158+
}
11361159
if (!count($this->errors)) {
11371160
try {
11381161
$post->save();

0 commit comments

Comments
 (0)