Skip to content

Translator.Culture should allow setting neutral language #89

Description

@Anlo2846

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.

Activity

  1. added a commit that references this issue on Jun 30, 2020
  2. JohanLarsson commented on Jun 30, 2020

    @JohanLarsson
    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");
        }
    }
  3. JohanLarsson commented on Jul 1, 2020

    @JohanLarsson
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions