JS报告 - 使用JS功能中的$ localizedResource
我有一部分,如下所示。
<tr>
<td class='col-narrow'>{{$localizedResource.DATE}}</td>
<td class='col-narrow'>{{$localizedResource.TIME}}</td>
<td class='col-narrow'>{{$localizedResource.DAY}}</td>
</tr>
<tr>
<td class='col-narrow'>{{date}}</td>
<td class='col-narrow'>{{time}}</td>
<td class='col-narrow'>{{day}}</td> // need to translate this
</tr>
我需要用我从API响应中获得的不同语言翻译{{day}}。 一直在Locales文件中添加了
function translateKey(key){
if(key){
const message = key.toUpperCase();
const newKey = this.$localizedresource.message;
return newKey;
}
}
我
<td class='col-narrow'>{{ translateKey day}}</td>
键
I have a part of table like below.
<tr>
<td class='col-narrow'>{{$localizedResource.DATE}}</td>
<td class='col-narrow'>{{$localizedResource.TIME}}</td>
<td class='col-narrow'>{{$localizedResource.DAY}}</td>
</tr>
<tr>
<td class='col-narrow'>{{date}}</td>
<td class='col-narrow'>{{time}}</td>
<td class='col-narrow'>{{day}}</td> // need to translate this
</tr>
I need to translate the {{Day}} in different languages which i receive from api response. I have added the keys in the locales files for all the days and tried doing the below which unfortunately did not work
function translateKey(key){
if(key){
const message = key.toUpperCase();
const newKey = this.$localizedresource.message;
return newKey;
}
}
and in the template i tried the following
<td class='col-narrow'>{{ translateKey day}}</td>
Can anyone help me figure out the issue here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JSReport已经有一个函数,请尝试
{{本地化日“本地化”}}}
,“本地化”是语言文件的文件夹名称
https://jsreport.net.net/learn/learn/learn/lailization#documentation < /a>
jsreport already has a function for that, try
{{localize day "localization"}}
,"localization" is the folder name of locale files
https://jsreport.net/learn/localization#documentation