6

我们在 Visual Studio 解决方案中有大量 C# 项目。对于其中的很多,我们有一个名为“TextResources.resx”的资源文件。这些在过去已被翻译,创建了几个相关的 resx 文件,例如“TextResources.fr.resx”。对于这些较旧的项目,这些翻译的 resx 文件显示为默认英语 TextResources.resx 的子项目,但是对于几个新项目,翻译的项目显示为单独的(相同的树级别)项目。

希望这张图能解释:

旧项目:

- TextResources.resx
     - TextResources.fr.resx 
     - TextResources.de.resx

新项目:

- TextResources.fr.resx 
- TextResources.de.resx 
- TextResources.resx 

这不仅看起来很奇怪,而且与这么多项目有点混淆。任何人都知道为什么它将一些翻译的 resx 文件分组而不是其他文件?

4

3 回答 3

10

I had the same problem and found no answer either.

I ended up editing the project (.csproj) file by hand.

<EmbeddedResource Include="Folder\TextResources.de.resx">
  <DependentUpon>TextResources.resx</DependentUpon>
  <SubType>Designer</SubType>
</EmbeddedResource>

Add the

<DependentUpon></DependentUpon> 

tag and type out the name of the "parent" resource file without leading folders.

于 2012-04-18T12:03:28.457 回答
0

适用于Visual Studio 2019的此解决方案

  <!-- Main Resource file -->
  <ItemGroup>
    <EmbeddedResource Update="Path\TextResources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>TextResources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

 <!-- Resource Designer class -->    
 <ItemGroup>
    <Compile Update="Path\TextResources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>TextResources.resx</DependentUpon>
    </Compile>
  </ItemGroup>

  <!-- Nested Resources files -->
  <ItemGroup>
    <EmbeddedResource Update="Path\TextResources.en.resx">
      <DependentUpon>Path\TextResources.resx</DependentUpon>
    </EmbeddedResource>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Path\TextResources.de.resx">
      <DependentUpon>Path\TextResources.resx</DependentUpon>
    </EmbeddedResource>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Path\TextResources.ar.resx">
      <DependentUpon>Path\TextResources.resx</DependentUpon>
    </EmbeddedResource>
  </ItemGroup>
于 2021-05-18T06:00:39.120 回答
0

查看 VS2019 中的自定义文件嵌套功能,这是一个示例:-

https://mitch.codes/tip-visual-studio-custom-file-nesting/

打开 [customised]“xx.filenesting.json”文件进行编辑后,只需在路径段部分添加“.resx”条目:-

查看 %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\NestingProfiles

      "pathSegment": {
        "add": {
          ".*": [
            ".js",
            ".css",
            ".html",
            ".htm",
            ".less",
            ".scss",
            ".coffee",
            ".iced",
            ".config",
            ".cs",
            ".vb",
            ".json",
            ".resx"          <-----
          ]
        }
      },
于 2021-08-27T12:59:34.293 回答