JS报告 - 使用JS功能中的$ localizedResource

发布于 2025-02-05 17:40:59 字数 808 浏览 1 评论 0原文

我有一部分,如下所示。

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幻想少年梦 2025-02-12 17:40:59

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文