Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information