fix: #7894, translate log in to view

v1.18.x
Barış Soner Uşaklı 5 years ago
parent 3c6c40b177
commit 2a5fe2b8f4

@ -21,6 +21,7 @@
"last_reply_time": "Last reply", "last_reply_time": "Last reply",
"reply-as-topic": "Reply as topic", "reply-as-topic": "Reply as topic",
"guest-login-reply": "Log in to reply", "guest-login-reply": "Log in to reply",
"login-to-view": "🔒 Log in to view",
"edit": "Edit", "edit": "Edit",
"delete": "Delete", "delete": "Delete",
"purge": "Purge", "purge": "Purge",

@ -8,7 +8,8 @@ define('forum/topic/posts', [
'forum/topic/images', 'forum/topic/images',
'navigator', 'navigator',
'components', 'components',
], function (pagination, infinitescroll, postTools, images, navigator, components) { 'translator',
], function (pagination, infinitescroll, postTools, images, navigator, components, translator) {
var Posts = { }; var Posts = { };
Posts.onNewPost = function (data) { Posts.onNewPost = function (data) {
@ -309,14 +310,16 @@ define('forum/topic/posts', [
var loginEl = document.createElement('a'); var loginEl = document.createElement('a');
loginEl.className = 'login-required'; loginEl.className = 'login-required';
loginEl.href = config.relative_path + '/login'; loginEl.href = config.relative_path + '/login';
loginEl.appendChild(document.createTextNode('🔒 Log in to view'));
posts.each(function (idx, postEl) { translator.translate('[[topic:login-to-view]]', function (translated) {
$(postEl).find('[component="post/content"] img').each(function (idx, imgEl) { loginEl.appendChild(document.createTextNode(translated));
imgEl = $(imgEl); posts.each(function (idx, postEl) {
if (imgEl.attr('src').startsWith(config.relative_path + config.upload_url)) { $(postEl).find('[component="post/content"] img').each(function (idx, imgEl) {
imgEl.replaceWith(loginEl.cloneNode(true)); imgEl = $(imgEl);
} if (imgEl.attr('src').startsWith(config.relative_path + config.upload_url)) {
imgEl.replaceWith(loginEl.cloneNode(true));
}
});
}); });
}); });
} }

Loading…
Cancel
Save