mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
fix: #9629, translate content property of meta tags
This commit is contained in:
@@ -240,22 +240,25 @@ ajaxify = window.ajaxify || {};
|
|||||||
.forEach(function (el) {
|
.forEach(function (el) {
|
||||||
document.head.removeChild(el);
|
document.head.removeChild(el);
|
||||||
});
|
});
|
||||||
|
require(['translator'], function (translator) {
|
||||||
// Add new meta tags
|
// Add new meta tags
|
||||||
ajaxify.data._header.tags.meta
|
ajaxify.data._header.tags.meta
|
||||||
.filter(function (tagObj) {
|
.filter(function (tagObj) {
|
||||||
var name = tagObj.name || tagObj.property;
|
var name = tagObj.name || tagObj.property;
|
||||||
return metaWhitelist.some(function (exp) {
|
return metaWhitelist.some(function (exp) {
|
||||||
return !!exp.test(name);
|
return !!exp.test(name);
|
||||||
|
});
|
||||||
|
}).forEach(async function (tagObj) {
|
||||||
|
if (tagObj.content) {
|
||||||
|
tagObj.content = await translator.translate(tagObj.content);
|
||||||
|
}
|
||||||
|
var metaEl = document.createElement('meta');
|
||||||
|
Object.keys(tagObj).forEach(function (prop) {
|
||||||
|
metaEl.setAttribute(prop, tagObj[prop]);
|
||||||
|
});
|
||||||
|
document.head.appendChild(metaEl);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
.forEach(function (tagObj) {
|
|
||||||
var metaEl = document.createElement('meta');
|
|
||||||
Object.keys(tagObj).forEach(function (prop) {
|
|
||||||
metaEl.setAttribute(prop, tagObj[prop]);
|
|
||||||
});
|
|
||||||
document.head.appendChild(metaEl);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Delete the old link tags
|
// Delete the old link tags
|
||||||
Array.prototype.slice
|
Array.prototype.slice
|
||||||
|
|||||||
Reference in New Issue
Block a user