查看按钮:
如果所有工具提示都存在此问题,我不会感到惊讶。
我也遇到了同样的问题。
快速浏览 Discourse 后发现 escape 被用于按钮标签、标题和内容。
escape 是什么:
在文本上下文中,这似乎都是有效的字符。
我想知道,这里是否需要它?
我相信未用 htmlSafe 标记的 HTML 会被模板转义?![]()
一种解决方法是用真正的法语撇号替换编程撇号。
使用:’
而不是:'
此符号在美国 QWERTY 键盘上不存在,在旧的 AZERTY 键盘上也不存在,但它同时存在于新的 AFNOR(法国标准化协会)标准法语键盘上,无论是新的 AZERTY 还是BÉPO。
这并不能解决程序撇号未正确转义的深层问题,但真正的法语撇号是正确的用法,一旦大多数法国人使用标准键盘,他们就会在打字时使用它。
旧的 AZERTY 实际上从未被任何官方机构标准化。
我刚刚用一些自定义代码修复了这个问题,请将 I18n.translations 中的 ' 替换为 ’
withPluginApi("0.8.18", (api) => {
const locale = I18n.currentLocale();
function replaceSingleQuotes(obj) {
if (typeof obj === 'string') {
// Split the string into HTML tags and non-tag parts
return obj.split(/(<[^>]+>)/g).map(segment => {
// If the segment is an HTML tag, do not replace anything
if (segment.startsWith('<') && segment.endsWith('>')) {
return segment;
} else {
// Replace single quotes only in non-HTML parts
return segment.replace(/'/g, '’');
}
}).join('');
} else if (typeof obj === 'object' && obj !== null) {
// Recursively process object properties
for (const key in obj) {
obj[key] = replaceSingleQuotes(obj[key]);
}
}
return obj;
}
if (I18n.translations[locale].js) {
I18n.translations[locale].js = replaceSingleQuotes(I18n.translations[locale].js);
}
});
此问题应已修复,请参考此提交:FIX: user tips in languages with apostrophes by pmusaraj · Pull Request #34118 · discourse/discourse · GitHub
感谢您的报告!
此主题已在 3 天后自动关闭。不再允许回复。