fix: use first site language in article layout when multiple languages configured

This commit is contained in:
ppoffice 2024-01-05 20:56:15 -08:00
parent da853cd39c
commit 49568ab9b0
No known key found for this signature in database
GPG Key ID: D872802C1F2A16AA
1 changed files with 5 additions and 3 deletions

View File

@ -24,8 +24,10 @@ module.exports = class extends Component {
const { article, plugins } = config;
const { url_for, date, date_xml, __, _p } = helper;
const indexLaunguage = toMomentLocale(config.language || 'en');
const language = toMomentLocale(page.lang || page.language || config.language || 'en');
const defaultLanguage = Array.isArray(config.language) && config.language.length ? config.language[0] : config.language;
const indexLanguage = toMomentLocale(defaultLanguage || 'en');
const language = toMomentLocale(page.lang || page.language || defaultLanguage || 'en');
const cover = page.cover ? url_for(page.cover) : null;
const updateTime = article && article.update_time !== undefined ? article.update_time : true;
const isUpdated = page.updated && !moment(page.date).isSame(moment(page.updated));
@ -74,7 +76,7 @@ module.exports = class extends Component {
{(() => {
const words = getWordCount(page._content);
const time = moment.duration((words / 150.0) * 60, 'seconds');
return `${_p('article.read_time', time.locale(index ? indexLaunguage : language).humanize())} (${_p('article.word_count', words)})`;
return `${_p('article.read_time', time.locale(index ? indexLanguage : language).humanize())} (${_p('article.word_count', words)})`;
})()}
</span> : null}
{/* Visitor counter */}