Skip to content

Commit d8b8e1c

Browse files
This is a first step toward making the Xamarin.Android.Build.Tasks MSBuild error and warning messages localizable. This first step covers a few decisions: * Use the MSBuild message codes like `XA4214` as the names for the string resources. * When an MSBuild message code like XA4214 is associated with more than one string, append short descriptive phrases to the end of the code to create additional property names as needed. * Name the `.resx` file `Resources.resx`, and place it in the `src/Xamarin.Android.Build.Tasks/Properties/` directory, alongside the `AssemblyInfo.cs` file. This follows what the nonpublic xamarin/designer and xamarin/XamarinVS repositories do. * Store the `.resx` file with LF line endings in the repo, but set `.resx` files to `text` mode in `.gitattributes` so the file can be checked out and edited with CRLF line endings on Windows. The Visual Studio `.resx` resource editor uses CRLF line endings. * Use the `<Generator>ResXFileCodeGenerator</Generator>` Visual Studio IDE mechanism to generate a `Resources.Designer.cs` file that is explicitly included in the project as a `@(Compile)` item. The `Resource.Designer.cs` file provides C# property names to access the `.resx` resources. Visual Studio updates the file each time a change is saved to the corresponding `.resx` file. This follows what the nonpublic xamarin/designer and xamarin/XamarinVS repos do. In the future, if `Xamarin.Android.Build.Tasks.csproj` is converted to a short-form project, it would probably be best to add a dependency on dotnet/arcade and switch to using the [`GenerateResxSource` mechanism][0] instead. That would match what dotnet/sdk does. * Use the [comment style from dotnet/sdk][1] to provide a brief explanation of each format item like `{0}`, especially in cases where the expected contents of the format item might not be obvious from context. * Keep the MSBuild message codes as string literals in the `.cs` files. This differs from what dotnet/sdk and microsoft/msbuild do. This might be incorrect. It might be important to include the message code prefix in the string so that the localization team can decide on the appropriate capitalization after the `:` character. See for example the use of lowercase letters after the `:` character in the Italian translations in [microsoft/msbuild][2] and [dotnet/sdk][3]. String values from `.resx` resources are not subject to interpolation, so any strings that use C# 6 string interpolation will need to be replaced with format strings that use format items like `{0}`. The message for XA4214 did not use string interpolation, so no change was needed for this first example. This commit does not yet leverage the MSBuild tasks and targets from [xliff-tasks][4] to generate satellite assemblies for localized string resources. That will be the next step. This commit intentionally skips adding anything to `Documentation/release-notes/` for now because these changes do not yet affect anything interesting to end users. [0]: https://github.com/dotnet/arcade/blob/e67d9f098029ebecedf11012a749b532d68ad2a9/Documentation/ArcadeSdk.md#generateresxsource-bool [1]: https://github.com/dotnet/sdk/blob/9bab2f06387393a06a79e4234494eebf42f9cc10/src/Tasks/Common/Resources/Strings.resx#L349 [2]: https://github.com/microsoft/msbuild/blob/1f4524283e4e7f0dfae9a83557bf551c8a28cab9/src/Tasks/Resources/xlf/Strings.it.xlf [3]: https://github.com/dotnet/sdk/blob/9bab2f06387393a06a79e4234494eebf42f9cc10/src/Tasks/Common/Resources/xlf/Strings.it.xlf [4]: https://github.com/dotnet/xliff-tasks
1 parent 4e07529 commit d8b8e1c

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)