1

我正在创建一个本地化应用程序 ASP NET MVC3,但问题是当我在根文件夹中添加 Resource.resx 文件时,访问修饰符被禁用,因此帮助启用访问修饰符这是我的 LanguageResources.Designer.cs 文件的代码

namespace Resources {
using System;      [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "10.0.0.0")]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
        internal class LanguageResources {

            private static global::System.Resources.ResourceManager resourceMan;

            private static global::System.Globalization.CultureInfo resourceCulture;

            [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
            internal LanguageResources() {
            }

            /// <summary>
            ///   Returns the cached ResourceManager instance used by this class.
            /// </summary>
            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
            internal static global::System.Resources.ResourceManager ResourceManager {
                get {
                    if (object.ReferenceEquals(resourceMan, null)) {
                        global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Resources.LanguageResources", global::System.Reflection.Assembly.Load("App_GlobalResources"));
                        resourceMan = temp;
                    }
                    return resourceMan;
                }
            }

            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
            internal static global::System.Globalization.CultureInfo Culture {
                get {
                    return resourceCulture;
                }
                set {
                    resourceCulture = value;
                }
            }

            /// <summary>
            ///   Looks up a localized string similar to Hii this my site.
            /// </summary>
            internal static string welcome {
                get {
                    return ResourceManager.GetString("welcome", resourceCulture);
                }
            }
        }
    }

我还在 web.config 文件中添加了全球化

<system.web>
<globalization uiCulture="auto" culture="auto"/>
</system.web> 
4

1 回答 1

1

我建议您将资源文件放在单独的类库中,并且您必须将Custom Tool资源文件的类型设置为PublicResXFileCodeGenerator.

有关更多信息,请参阅此帖子

于 2012-11-29T14:45:41.000 回答