microsoft / VSExtensibility

A repo for upcoming changes to extensibility in Visual Studio, the new extensibility model, and language server protocol.
MIT License
354 stars 42 forks source link

XAML localization using string-resources.json #268

Open sboulema opened 9 months ago

sboulema commented 9 months ago

Is it possible to use the strings from the string-resources.json file in a XAML UserControl/DataTemplate?

I tried creating a property on my datacontext with the localizableString attribute, but that does not work and the tooltip indicates it is not meant to be used by extenders...

Would be great to have all strings in a single location!

matteo-prosperi commented 7 months ago

Hello. The string-resources.json values are only used in configuration properties. At the moment, the best way to localize a string in a UI component of a VisualStudio.Extensibility extension is to have a bindable string property in the data context and retrieve its value from a resx resource file. The request of having all your strings in a single place is on our radar and we will consider for future improvements. Also, note that the LocalizableString attribute is documented as internal use-only it's not meant to be used by extenders. See https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.extensibility.localizablestringattribute