Skip to content

Commit a52abde

Browse files
Address review comments
1 parent a071aec commit a52abde

File tree

7 files changed

+74
-26
lines changed

7 files changed

+74
-26
lines changed

Configuration.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
</PropertyGroup>
176176

177177
<PropertyGroup>
178+
<XlfLanguages>cs;de;es;fr;it;ja;ko;pl;pt-BR;ru;tr;zh-Hans;zh-Hant</XlfLanguages>
178179
<UpdateXlfOnBuild Condition="'$(RunningOnCI)' != 'true'">true</UpdateXlfOnBuild>
179180
</PropertyGroup>
180181

Documentation/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
* [Using Your Build](workflow/UsingYourBuild.md)
4040
* [Jenkins Build Artifacts](workflow/JenkinsBuildArtifacts.md)
4141
* [Development tips and native debugging](workflow/DevelopmentTips.md)
42+
* [Localization](workflow/Localization.md)
4243

4344

4445
# Coding Guidelines
10.9 KB
Loading
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Localization
2+
3+
All new Xamarin.Android MSBuild error or warning messages should be localizable,
4+
so when adding a new message, follow these steps:
5+
6+
1. Add the new message to
7+
`src/Xamarin.Android.Build.Tasks/Properties/Resources.resx`. Use the
8+
message code as the name of the resource. For example, for the message text
9+
associated with code `XA0000`, use `XA0000` as the name:
10+
11+
![Managed Resources Editor with XA0000 as the name for a
12+
resource][resources-editor]
13+
14+
Be sure to use Visual Studio or Visual Studio for Mac to edit the `.resx`
15+
file so that the `ResXFileCodeGenerator` tool will run and update the
16+
corresponding `Resources.Designer.cs` file.
17+
18+
2. In the call to `LogCodedError()` or `LogCodedWarning()`, reference the
19+
message string using the generated C# property name like
20+
`Properties.Resources.XA0000`.
21+
22+
3. After adding the new message, build `Xamarin.Android.Build.Tasks.csproj`
23+
locally. This will run the targets from [dotnet/xliff-tasks][xliff-tasks]
24+
to update the `.xlf` [XLIFF][xliff] localization files with the latest
25+
changes from the `.resx` file.
26+
27+
4. Include the changes to the`.resx` file as well as the generated changes to
28+
the `Resources.Designer.cs` file and the `.xlf` files in the commit.
29+
30+
## Guidelines
31+
32+
* If a message code is used in multiple calls to `LogCodedError()` or
33+
`LogCodedWarning()` that each logs a different message, append short
34+
descriptive phrases to the end of the code to create additional resource
35+
names as needed. For example, you could have names like `XA0000_Files` and
36+
`XA0000_Directories` for two different strings.
37+
38+
* To include values of variables in the message, use numbered format items
39+
like `{0}` and `{1}` rather than string interpolation or string
40+
concatenation.
41+
42+
String interpolation won't work because string resources are not subject to
43+
interpolation. String concatenation should also be avoided because it means
44+
the message text will be split across multiple string resources, which makes
45+
it more complicated to provide appropriate context about the message for the
46+
translation team.
47+
48+
* Use the comments field in the `.resx` file to provide additional context to
49+
the translation team about the message. For example, for a message that
50+
includes a format item like `{0}`, it can sometimes be helpful to add a
51+
comment about what will appear for that item in the final formatted string:
52+
53+
```
54+
{0} - The managed type name
55+
```
56+
57+
For a few more examples, see the dotnet/sdk repo:
58+
59+
https://github.com/dotnet/sdk/blob/master/src/Tasks/Common/Resources/Strings.resx
60+
61+
[resources-editor]: ../images/resources-editor-xa0000.png
62+
[xliff-tasks]: https://github.com/dotnet/xliff-tasks
63+
[xliff]: http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html

build-tools/installers/create-installers.targets

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="..\scripts\XAVersionInfo.targets" />
4+
<Import Project="..\scripts\LocalizationLanguages.projitems" />
45
<Import Project="..\..\bin\Build$(Configuration)\ProfileAssemblies.projitems" />
56
<Import Project="..\..\bin\Build$(Configuration)\Mono.Android.Apis.projitems" />
67
<UsingTask AssemblyFile="..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" />
@@ -194,19 +195,7 @@
194195
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Bindings.targets" />
195196
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Build.Tasks.dll" />
196197
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Build.Tasks.pdb" />
197-
<_MSBuildFiles Include="$(MSBuildSrcDir)\cs\Xamarin.Android.Build.Tasks.resources.dll" />
198-
<_MSBuildFiles Include="$(MSBuildSrcDir)\de\Xamarin.Android.Build.Tasks.resources.dll" />
199-
<_MSBuildFiles Include="$(MSBuildSrcDir)\es\Xamarin.Android.Build.Tasks.resources.dll" />
200-
<_MSBuildFiles Include="$(MSBuildSrcDir)\fr\Xamarin.Android.Build.Tasks.resources.dll" />
201-
<_MSBuildFiles Include="$(MSBuildSrcDir)\it\Xamarin.Android.Build.Tasks.resources.dll" />
202-
<_MSBuildFiles Include="$(MSBuildSrcDir)\ja\Xamarin.Android.Build.Tasks.resources.dll" />
203-
<_MSBuildFiles Include="$(MSBuildSrcDir)\ko\Xamarin.Android.Build.Tasks.resources.dll" />
204-
<_MSBuildFiles Include="$(MSBuildSrcDir)\pl\Xamarin.Android.Build.Tasks.resources.dll" />
205-
<_MSBuildFiles Include="$(MSBuildSrcDir)\pt-BR\Xamarin.Android.Build.Tasks.resources.dll" />
206-
<_MSBuildFiles Include="$(MSBuildSrcDir)\ru\Xamarin.Android.Build.Tasks.resources.dll" />
207-
<_MSBuildFiles Include="$(MSBuildSrcDir)\tr\Xamarin.Android.Build.Tasks.resources.dll" />
208-
<_MSBuildFiles Include="$(MSBuildSrcDir)\zh-Hans\Xamarin.Android.Build.Tasks.resources.dll" />
209-
<_MSBuildFiles Include="$(MSBuildSrcDir)\zh-Hant\Xamarin.Android.Build.Tasks.resources.dll" />
198+
<_MSBuildFiles Include="@(_LocalizationLanguages->'$(MSBuildSrcDir)\%(Identity)\Xamarin.Android.Build.Tasks.resources.dll')" />
210199
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.BuildInfo.txt" />
211200
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Cecil.dll" />
212201
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Cecil.pdb" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<ItemGroup>
3+
<_LocalizationLanguages Include="$(XlfLanguages)" />
4+
</ItemGroup>
5+
</Project>

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<DebugSymbols>True</DebugSymbols>
1818
</PropertyGroup>
1919
<Import Project="..\..\Configuration.props" />
20+
<Import Project="..\..\build-tools\scripts\LocalizationLanguages.projitems" />
2021
<Import Project="..\..\build-tools\scripts\MSBuildReferences.projitems" />
2122
<Import Project="..\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems" Label="Shared" Condition="Exists('..\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems')" />
2223
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -600,19 +601,7 @@
600601
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
601602
<SubType>Designer</SubType>
602603
</EmbeddedResource>
603-
<None Include="Properties\xlf\Resources.fr.xlf" />
604-
<None Include="Properties\xlf\Resources.cs.xlf" />
605-
<None Include="Properties\xlf\Resources.de.xlf" />
606-
<None Include="Properties\xlf\Resources.es.xlf" />
607-
<None Include="Properties\xlf\Resources.it.xlf" />
608-
<None Include="Properties\xlf\Resources.ja.xlf" />
609-
<None Include="Properties\xlf\Resources.ko.xlf" />
610-
<None Include="Properties\xlf\Resources.pl.xlf" />
611-
<None Include="Properties\xlf\Resources.pt-BR.xlf" />
612-
<None Include="Properties\xlf\Resources.ru.xlf" />
613-
<None Include="Properties\xlf\Resources.tr.xlf" />
614-
<None Include="Properties\xlf\Resources.zh-Hans.xlf" />
615-
<None Include="Properties\xlf\Resources.zh-Hant.xlf" />
604+
<None Include="@(_LocalizationLanguages->'Properties\xlf\Resources.%(Identity).xlf')" />
616605
</ItemGroup>
617606
<ItemGroup>
618607
<_MonoAndroidEnum Include="$(AndroidGeneratedClassDirectory)\Android.Content.PM.LaunchMode.cs" />

0 commit comments

Comments
 (0)