占位符 i18next 翻译不起作用

Placeholder i18next translation not working

我已经创建了注册表。我正在使用 i18next 服务器端。

这是我的服务器端配置:

var i18n = require('i18next');
i18n.init({
saveMissing: true,
debug: true
});

app.use(i18n.handle);

以下是我的语言环境 json"

{
"app": {
  "lblalreadyhaveanaccount": "¿Ya tienes una cuenta?",
  "lblsignin": "Ingresar",
  "lblhelp": "Ayuda",
  "lblletscreateyouraccount": "Vamos a crear su cuenta",
  "lblname": "Nombre",
  "phfirstname": "Nombre de pila",
  ....
 }

我正在使用 ejs 作为我的模板引擎。这是以下代码:

...
<form ng-submit="validateForm()">
                <div class="form-group">
                    <!-- Name -->
                    <label><%= t('app.lblname') %></label>

                    <div class="row">
                        <div class="col-md-6">
                            <input id="fname" type="text" class="form-control"
                                   placeholder=<%= t('app.phfirstname') %>>
                        </div>
                        <div class="col-md-6">
                            <input id="lname" type="text" class="form-control"
                                   placeholder=<%= t('app.phlastname') %>>
                        </div>
                    </div>
  ....

我的问题是具有多字字符串的标签已正确呈现,但占位符仅显示语言环境 json 中字符串的第一个字。

检查元素显示如下:

<input id="fname" type="text" class="form-control" placeholder="Nombre" de="" pila="">

我找不到解决此问题的方法。请帮帮我。 提前谢谢你。

看起来浏览器正在尝试理解输入标签中的单词。为了帮助解决这个问题,请尝试在占位符文本周围添加双引号,如下所示:

<div class="row">
    <div class="col-md-6">
        <input id="fname" type="text" class="form-control"
               placeholder="<%= t('app.phfirstname') %>"
    </div>
    <div class="col-md-6">
        <input id="lname" type="text" class="form-control"
               placeholder="<%= t('app.phlastname') %>"
    </div>
</div>