Nathan Baulch
Nathan Baulch

Reputation: 20703

Generate satellite assemblies for large solution with many resources and many languages

I have a very large solution (>100 projects) that's being translated into more than 10 languages. What's the best way to generate all the necessary satellite assemblies during the build process?

I know I can include the localized RESX files in their associated projects however this creates a lot of noise for developers. Translations are managed by a remote team who check them into source control independently. This also creates a lot of work each time a new language is added since every project has to be modified to include the new culture specific resources.

Are there any post-build tools that search for culture specific RESX files, group them into projects and build the satellite assemblies all at once?

If not, I guess I could use the DependentUpon attribute to hide localized resources in the Visual Studio solution explorer underneath the main resource file. This can't be done in the Visual Studio UI so I guess I'd have to build a tool that batch applies this pattern to all resource files in all projects. The resulting project file would look something like this:

<ItemGroup>
  <Compile Include="Properties\Resources.Designer.cs">
    <AutoGen>True</AutoGen>
    <DesignTime>True</DesignTime>
    <DependentUpon>Resources.resx</DependentUpon>
  </Compile>
</ItemGroup>
<ItemGroup>
  <EmbeddedResource Include="Properties\Resources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>Resources.Designer.cs</LastGenOutput>
  </EmbeddedResource>
  <EmbeddedResource Include="Properties\Resources.de.resx">
    <DependentUpon>Resources.resx</DependentUpon>
  </EmbeddedResource>
  <EmbeddedResource Include="Properties\Resources.fr.resx">
    <DependentUpon>Resources.resx</DependentUpon>
  </EmbeddedResource>
</ItemGroup>

Nested resources have an unexpected icon in the solution explorer but at least they're hidden by default.

Visual Studio Solution Explorer with nested localized resources

Upvotes: 1

Views: 1012

Answers (2)

Zoltan Rajnai
Zoltan Rajnai

Reputation: 39

You can use conditions on the ItemGroup or individual items to have them excluded from the build.

I recommend using $(ConfigurationName).

Look here:

MSBuild Conditions
ItemGroup Element (MSBuild)

Upvotes: 1

Clafou
Clafou

Reputation: 15410

You can insulate your core software development source control from the localization effort. The satellite assemblies can really just be dropped into your build, and therefore don't need to be built together with your code.

So you could set up a separate source control system for your localization project. It would contain a copy of your base .resx files (which you will need to update from your core source control) and the translated versions managed by your localizers. You could then build satellite assemblies from there and combine these with your core build to make your multi-language localized build.

Upvotes: 0

Related Questions