That's a mouthful...
那是满口的......
Here's the issue, we're doing some client-side validation via AJAX calls to page methods (which are essentially web services). We've also added a drop-down on the page to choose your language and have created a class that inherits from Page that initializes localization based on the drop-down selection. When page methods are getting called via AJAX though, the page isn't instantiated normally and therefore the initialization of localization isn't taking place.
这是问题,我们正在通过AJAX调用页面方法(实质上是Web服务)进行一些客户端验证。我们还在页面上添加了一个下拉列表来选择您的语言,并创建了一个继承自Page的类,该类根据下拉选项初始化本地化。当通过AJAX调用页面方法时,页面没有正常实例化,因此没有进行本地化的初始化。
I've considered saving language choice to the session, but that doesn't solve the problem as every page method would have to re-initialize localization in order to get the proper language files loaded. Any thoughts on how to deal with dynamic localization in Page Methods or Web Services?
我已经考虑过将语言选择保存到会话中,但这并不能解决问题,因为每个页面方法都必须重新初始化本地化才能获得正确的语言文件。有关如何处理页面方法或Web服务中的动态本地化的任何想法?
This is our first foray into localization so I'm hoping I'm missing something obvious...
这是我们第一次涉足本地化,所以我希望我错过了一些明显的东西......
1 个解决方案
#1
1
I'm not sure why you're experencing this problem, but one easy solution would be to simply pass in the locale in the ajax call to a page method or web service.
我不确定你为什么要解决这个问题,但一个简单的解决方案是简单地将ajax调用中的语言环境传递给页面方法或Web服务。
What I did in my application was to set a cookie with the locale. What I do in my auto-complete web service is simply call the following line of code from all my public web service methods: LavaBlastBasePage.SetCultureFromCookie();
我在我的应用程序中所做的是使用语言环境设置cookie。我在自动完成的Web服务中所做的只是从我的所有公共Web服务方法中调用以下代码行:LavaBlastBasePage.SetCultureFromCookie();
This is similar to using the session, however.
但这与使用会话类似。
#1
1
I'm not sure why you're experencing this problem, but one easy solution would be to simply pass in the locale in the ajax call to a page method or web service.
我不确定你为什么要解决这个问题,但一个简单的解决方案是简单地将ajax调用中的语言环境传递给页面方法或Web服务。
What I did in my application was to set a cookie with the locale. What I do in my auto-complete web service is simply call the following line of code from all my public web service methods: LavaBlastBasePage.SetCultureFromCookie();
我在我的应用程序中所做的是使用语言环境设置cookie。我在自动完成的Web服务中所做的只是从我的所有公共Web服务方法中调用以下代码行:LavaBlastBasePage.SetCultureFromCookie();
This is similar to using the session, however.
但这与使用会话类似。