<i id='JA3Nh'><tr id='JA3Nh'><dt id='JA3Nh'><q id='JA3Nh'><span id='JA3Nh'><b id='JA3Nh'><form id='JA3Nh'><ins id='JA3Nh'></ins><ul id='JA3Nh'></ul><sub id='JA3Nh'></sub></form><legend id='JA3Nh'></legend><bdo id='JA3Nh'><pre id='JA3Nh'><center id='JA3Nh'></center></pre></bdo></b><th id='JA3Nh'></th></span></q></dt></tr></i><div id='JA3Nh'><tfoot id='JA3Nh'></tfoot><dl id='JA3Nh'><fieldset id='JA3Nh'></fieldset></dl></div>
    <legend id='JA3Nh'><style id='JA3Nh'><dir id='JA3Nh'><q id='JA3Nh'></q></dir></style></legend>
  • <small id='JA3Nh'></small><noframes id='JA3Nh'>

      <tfoot id='JA3Nh'></tfoot>

          <bdo id='JA3Nh'></bdo><ul id='JA3Nh'></ul>

        ASP.NET 中的全局资源与本地资源

        时间:2023-08-25
          <bdo id='lPhMI'></bdo><ul id='lPhMI'></ul>

          <small id='lPhMI'></small><noframes id='lPhMI'>

            • <legend id='lPhMI'><style id='lPhMI'><dir id='lPhMI'><q id='lPhMI'></q></dir></style></legend>
            • <i id='lPhMI'><tr id='lPhMI'><dt id='lPhMI'><q id='lPhMI'><span id='lPhMI'><b id='lPhMI'><form id='lPhMI'><ins id='lPhMI'></ins><ul id='lPhMI'></ul><sub id='lPhMI'></sub></form><legend id='lPhMI'></legend><bdo id='lPhMI'><pre id='lPhMI'><center id='lPhMI'></center></pre></bdo></b><th id='lPhMI'></th></span></q></dt></tr></i><div id='lPhMI'><tfoot id='lPhMI'></tfoot><dl id='lPhMI'><fieldset id='lPhMI'></fieldset></dl></div>

                  <tbody id='lPhMI'></tbody>
                <tfoot id='lPhMI'></tfoot>
                  本文介绍了ASP.NET 中的全局资源与本地资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我们使用 resx 文件来本地化我们的 Web 应用程序.当只有一个页面使用某个短语时,我们通常会创建本地 resx 文件(映射到特定页面),而当多个页面需要该短语时,我们会创建全局 resx 文件.
                  但是全局 resx 文件的好处是它们是一个类,你可以像调用类的属性一样调用短语:

                  We use resx files to localize our web applications. We usually create local resx files (that map to a specific page) when only one page uses a certain phrase, and a global resx file when more than one page needs the phrase.
                  But the good thing about global resx files is that they are a class, and you can call the phrases like you call properties of a class:

                  Resource.UI.iNotFound

                  Resource.UI.iNotFound

                  所以我在想 - 为什么要有本地 resx 文件?为什么不对整个应用程序使用一个全局 resx 文件,这样可以避免调用不存在的短语导致运行时错误?

                  So I was thinking - why have local resx files at all? why not use one global resx file for the whole application, and that way avoid runtime errors from calling non-existent phrases?

                  我确定有一个很好的答案,我只是不知道它是什么......

                  I'm sure there's a good answer for that, I just don't know what it is....

                  推荐答案

                  我一直在寻找指南,并在 MSDN:

                  I kept on looking for guidelines, and found this in MSDN:

                  在全局和本地资源文件之间进行选择

                  您可以使用全局的任意组合和 Web 中的本地资源文件应用.通常,您添加资源到全局资源文件当你想分享资源时页面之间.全球资源资源文件也是强类型的当您想要访问文件时以编程方式.

                  You can use any combination of global and local resource files in the Web application. Generally, you add resources to a global resource file when you want to share the resources between pages. Resources in global resource files are also strongly typed for when you want to access the files programmatically.

                  但是,全局资源文件可以变大,如果你存储所有其中的本地化资源.全球的资源文件也可以更多难以管理,如果不止一个开发人员正在研究不同的页面但在单个资源文件中.

                  However, global resource files can become large, if you store all localized resources in them. Global resource files can also be more difficult to manage, if more than one developer is working on different pages but in a single resource file.

                  本地资源文件更容易管理单个 ASP.NET 的资源网页.但你不能分享页面之间的资源.此外,你可能会创建很多本地的资源文件,如果你有很多页面必须本地化为许多语言.如果网站很大许多文件夹和语言,本地资源可以快速扩展中的组件数应用领域.

                  Local resource files make it easier to manage resources for a single ASP.NET Web page. But you cannot share resources between pages. Additionally, you might create lots of local resource files, if you have many pages that must be localized into many languages. If sites are large with many folders and languages, local resources can quickly expand the number of assemblies in the application domain.

                  当您更改默认资源文件时,本地或全局,ASP.NET重新编译资源并重新启动ASP.NET 应用程序.这个可以影响你的整体表现地点.如果添加卫星资源文件,它不会导致重新编译资源,但ASP.NET 应用程序将重新启动.

                  When you make a change to a default resource file, either local or global, ASP.NET recompiles the resources and restarts the ASP.NET application. This can affect the overall performance of your site. If you add satellite resource files, it does not cause a recompilation of resources, but the ASP.NET application will restart.

                  所以看来编程团队需要权衡每种方法的优缺点,然后选择对他们有利的方法.

                  So it seems that it's really up to the programming team to weigh the pros and cons of each method and choose what's good for them.

                  这篇关于ASP.NET 中的全局资源与本地资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:任何语言的所有国家列表? 下一篇:如何本地化数据库驱动的网站

                  相关文章

                  最新文章

                    <small id='dU75N'></small><noframes id='dU75N'>

                  1. <legend id='dU75N'><style id='dU75N'><dir id='dU75N'><q id='dU75N'></q></dir></style></legend>
                    <tfoot id='dU75N'></tfoot>

                    • <bdo id='dU75N'></bdo><ul id='dU75N'></ul>

                      <i id='dU75N'><tr id='dU75N'><dt id='dU75N'><q id='dU75N'><span id='dU75N'><b id='dU75N'><form id='dU75N'><ins id='dU75N'></ins><ul id='dU75N'></ul><sub id='dU75N'></sub></form><legend id='dU75N'></legend><bdo id='dU75N'><pre id='dU75N'><center id='dU75N'></center></pre></bdo></b><th id='dU75N'></th></span></q></dt></tr></i><div id='dU75N'><tfoot id='dU75N'></tfoot><dl id='dU75N'><fieldset id='dU75N'></fieldset></dl></div>