Gu.Localization
Gu.Localization copied to clipboard
Translator.Culture should allow setting neutral language
When a .csproj has a neutral language set, for example:
<NeutralLanguage>en</NeutralLanguage>
and the following assignment is executed:
Translator.Culture = CultureInfo.GetCultureInfo("en");
the following exception is thrown:
System.ArgumentException : Can only set culture to an existing culture.
Check the property Cultures for a list of valid cultures.
I failed to repro this bug using:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Gu.Localization\Gu.Localization.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
public partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
Translator.Culture = CultureInfo.GetCultureInfo("en");
}
}
Published a new version https://www.nuget.org/packages/Gu.Localization/6.5.0 no intentional fix for this but we can check if it is still an issue.
In a test project with no <NeutralLanguage>en</NeutralLanguage>
I can see this being an issue as there is no mechanism for inheriting neutral culture in place.