简体   繁体   English

翻译 asp.net 核心 web 应用程序中的 Vue 元素

[英]Translate Vue element in asp.net core web app

I recentyl inherented a Web App in work made in ASP.Net Core 2.2 and the Views are made with Razor and Vue, I was asked to add multi languagem support to the app, so already created all the resx files, and added IViewLocalizer to the Views, now I have a problem that is the Vue variables, I never worked with Vue so I would ask your help in this part.我最近在 ASP.Net Core 2.2 中内置了一个 Web 应用程序,视图是用 Razor 和 Vue 制作的,我被要求为应用程序添加多语言支持,因此已经创建了所有 resx 文件,并将 IViewLocalizer 添加到意见,现在我有一个问题是 Vue 变量,我从未使用过 Vue,所以我会在这部分寻求你的帮助。

I have a v-for我有一个 v-for

<div v-for="Order in client.Orders" class="card-block border">
    <div class="card-header">
        <div class="row">
            <div class="col-6">
                <h5 class="text-sm">@Localizer["Order"] {{Order.OrderId}}</h5>
            </div>
            </div>
        </div>
    </div>

    <div class="bg-light text-center">
        <em class="text-sm">{{Order.State}}</em>
    </div>
    <div class="card-body">
        <table class="table table-sm table-borderless text-sm">
            <tbody>
                <tr>
                    <td>@Localizer["Location"]</td>
                    <td class="text-center">{{Order.PaymentLocation}}</td>
                </tr>
                <tr>
                    <td>@Localizer["Destination Country"]</td>
                    <td class="text-center">{{Order.DestCountry}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
 

How can I have access to the {{Order.State}} to translate the value?我怎样才能访问 {{Order.State}} 来翻译值?

Thank you !谢谢 !

I am afraid you can not use asp.net core IViewLocalizer to localize the data in Vue, because the client side codes and server side codes are in different lifetime.恐怕您不能使用 asp.net 核心IViewLocalizer来本地化 Vue 中的数据,因为客户端代码和服务器端代码的生命周期不同。 You may need to have a Api for translate the words then return it to vue.您可能需要一个 Api 来翻译单词,然后将其返回给 vue。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM