Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translator.Culture should allow setting neutral language #89

Open
Anlo2846 opened this issue Jun 18, 2020 · 2 comments
Open

Translator.Culture should allow setting neutral language #89

Anlo2846 opened this issue Jun 18, 2020 · 2 comments

Comments

@Anlo2846
Copy link

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.
JohanLarsson added a commit that referenced this issue Jun 30, 2020
No repro.
@JohanLarsson
Copy link
Member

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");
    }
}

@JohanLarsson
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants