且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Web应用程序国际化,是服务器端还是客户端?

更新时间:2023-11-27 22:22:28

I18n的第一条规则:遵循标准方法。不要重新发明***。如果是Asp.Net,则意味着服务器端国际化。

The first rule of I18n: follow the standard way. Do not re-invent the wheel. In case of Asp.Net that means server-side Internationalization.

嗯,有点。如果碰巧有大量动态创建的控件,则仍然需要一些用于客户端脚本的本地化机制。您可以集中化它,即创建一个翻译后的字符串和model + controller的全局数组,这样就可以通过AJAX调用进行填充(尽管X***用J代替JSON ...)。

无论如何,您的模型应该只从资源文件中检索适当的字符串,控制器应该将JSON馈送到客户端(好主意实际上是请求较小的块,即仅针对给定视图/屏幕的翻译,而不是整个应用程序的翻译)

Well, sort of. If you happen to have tons of dynamically created controls, you still need some Localization mechanism for client-side scripts. You can centralize it, i.e. create one global array of translated strings and the model+controller, so you can i.e. populate it via AJAX call (although X would be best replaced by J for JSON...).
Anyway, your model should simply retrieve appropriate strings from resource files and controller should feed the JSON to the client side (good idea is to actually request smaller chunks, i.e. just the translation for given view/screen instead of translations for the whole application).

如您所见,***的方法是混合使用。由于许多原因,***在整个应用程序中使用一种本地化模型,即仅使用* .resx文件。

此外,还有对于国际化的要多得多,而不仅仅是普通字符串的外部化...

As you can see, the best would be some mixed approach. For many reasons, one would be it is better to use one Localization model for the whole application, i.e. use only *.resx files.
Besides, there is much more to Internationalization than just plain string externalization...