法语语言环境正在破坏按钮功能

French locale is breaking button function

问题

如果用户在法语区域查看网站,按钮将无法正常工作。

背景信息

我正在使用 {% trans %} 标记直接在我的 Django 模板中翻译按钮文本。在我的脚本标签内,我还使用 {% trans %} 标签在触发按钮操作 (onclick) 后添加翻译:let show_correction = '{% trans "Show native corrections" %}';.

在法语语言环境中,它变为:let show_correction='Afficher les corrections d'autres locuteurs natifs';。我认为这个问题特别发生在 d'autres.

我的猜测

也许函数因为撇号提前终止了?


我到底该如何解决这个问题?

解决方案:https://docs.djangoproject.com/en/3.2/topics/i18n/translation/#module-django.views.i18n

基本用法:

let foo = gettext("Your string to be translated");