Commit d664e90
authored
[generator] Make warning and error messages localizable. (#689)
Context: dotnet/android@0342fe5
Adds infrastructure to make the `Java.Interop` repository localizaable,
and rebases `generator` to work on this infrastructure.
Future PR's will make additional assemblies work on this infrastructure.
~~ Approach ~~
Create a single `Java.Interop.Localization.dll` assembly that will be
referenced by all localizable assemblies. This approach allows us to
have a single set of `.xlf` files to worry about providing to
translators, instead of a separate set for `generator`, `class-parse`,
`ApiXmlAdjuster`, etc.
The downside to this approach is that if you only wanted to ship
`generator.exe` you would be shipping the messages for the entire repo.
Given that our use case is to ship all tools together, and that we
won't have a ton of messages, this seems like an acceptable tradeoff.
(`generator` contains the most messages, and with this commit
`Java.Interop.Localization.dll` is ~9KB.)
Currently we only plan to localize the tools used on desktop to build
bindings. If we localize assemblies that run on device in the future,
we would most likely make a separate "run-time" set, as we wouldn't
want to ship e.g. `generator` messages on a device.
~~ Usage ~~
To create a new translatable string (all assemblies):
* Open `Java.Interop.Localization.Resources.resx` in an IDE.
* Enter the string lookup key, string value, and any notes for
translators.
* The string can now be retrieved via
`Java.Interop.Localization.Resources.MyStringKey`.
~~ Generator Usage ~~
To use the string in `generator.exe`:
* Create a new static member in `Utilities/Report.cs` that assigns
a build code to the string.
public static LocalizedMessage WarningUnknownReturnType => new LocalizedMessage (8700, Java.Interop.Localization.Resources.Generator_BG8700);
* Use `Report.LogCodedWarning()` or `Report.LogCodedError()` to
create an `MSBuild` formatted build warning/error.
Report.LogCodedError (Report.ErrorFailedToProcessEnumMap);
Overloads are available that take exceptions, file/line/col info,
and `string.Format()` parameters.1 parent 007b35b commit d664e90
File tree
41 files changed
+3654
-134
lines changed- src/Java.Interop.Localization
- xlf
- tools/generator
- Java.Interop.Tools.Generator.CodeGeneration
- Java.Interop.Tools.Generator.Importers
- Java.Interop.Tools.Generator.ObjectModel
- Java.Interop.Tools.Generator.Transformation
- SourceWriters
- Extensions
- Utilities
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
41 files changed
+3654
-134
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | 15 | | |
10 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
| |||
269 | 271 | | |
270 | 272 | | |
271 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
272 | 278 | | |
273 | 279 | | |
274 | 280 | | |
| |||
315 | 321 | | |
316 | 322 | | |
317 | 323 | | |
| 324 | + | |
318 | 325 | | |
319 | 326 | | |
320 | 327 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
0 commit comments