私は、.NET Web Appを構築しています。ローカライズされた文字列はMultilingual App Toolkitによって提供されています。これは、リソースファイルで定義された名前を持つプロパティを持つ静的クラスを生成します。それは次のようになります。私は、文字列にアクセスするコードでユーザー固有のローカライズされたリソースにアクセス
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Strings {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Strings() {
}
/// <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("FaqBot.Resources.Strings", typeof(Strings).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[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 Good Morning.
/// </summary>
internal static string Greeting {
get {
return ResourceManager.GetString("Greeting", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Welcome.
/// </summary>
internal static string Welcome {
get {
return ResourceManager.GetString("Welcome", resourceCulture);
}
}
}
、私は文化を設定することができ、および文字列プロパティへの以降のアクセスでは、正しくローカライズされた文字列を返します。
私のWebアプリケーションでは、ユーザーに言語を選択させるオプションがあり、この設定を保存する仕組みがあります。ただし、Stringsファイルは静的なので、あるユーザーが言語を変更すると、他のユーザーの後続の文字列も変更されます。 これを回避する1つの方法は、すべての文字列アクセスの前に明示的にカルチャを設定することですが、これは競合状態と醜いコードにつながります。
どのように私はそれぞれのユーザーがそれぞれの文字列アクセスの前に文化を明示的に設定することなく、好みの言語で回答を得ることができますか?そうする