diff --git a/src/Microsoft.AspNetCore.Localization/ApplicationBuilderExtensions.cs b/src/Microsoft.AspNetCore.Localization/ApplicationBuilderExtensions.cs index 24f89e3bb2..9f2a0dac59 100644 --- a/src/Microsoft.AspNetCore.Localization/ApplicationBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Localization/ApplicationBuilderExtensions.cs @@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Builder if (cultures.Length == 0) { - throw new ArgumentException("Please provide at least one culture."); + throw new ArgumentException(Resources.Exception_CulturesShouldNotBeEmpty); } var options = new RequestLocalizationOptions() diff --git a/src/Microsoft.AspNetCore.Localization/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Localization/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..581e3cda17 --- /dev/null +++ b/src/Microsoft.AspNetCore.Localization/Properties/Resources.Designer.cs @@ -0,0 +1,37 @@ +// +namespace Microsoft.AspNetCore.Localization +{ + using System.Reflection; + using System.Resources; + + internal static class Resources + { + private static readonly ResourceManager _resourceManager + = new ResourceManager("Microsoft.AspNetCore.Localization.Resources", typeof(Resources).GetTypeInfo().Assembly); + + /// + /// Please provide at least one culture. + /// + internal static string Exception_CulturesShouldNotBeEmpty + { + get { return GetString("Exception_CulturesShouldNotBeEmpty"); } + } + + private static string GetString(string name, params string[] formatterNames) + { + var value = _resourceManager.GetString(name); + + System.Diagnostics.Debug.Assert(value != null); + + if (formatterNames != null) + { + for (var i = 0; i < formatterNames.Length; i++) + { + value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); + } + } + + return value; + } + } +} diff --git a/src/Microsoft.AspNetCore.Localization/Resources.resx b/src/Microsoft.AspNetCore.Localization/Resources.resx new file mode 100644 index 0000000000..17ef00c8c6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Localization/Resources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Please provide at least one culture. + + \ No newline at end of file