Skip to content

Instantly share code, notes, and snippets.

@Char0394
Created April 28, 2022 13:46
Show Gist options
  • Save Char0394/7d37f85a21b8f021f5808b2e2544a1b4 to your computer and use it in GitHub Desktop.
Save Char0394/7d37f85a21b8f021f5808b2e2544a1b4 to your computer and use it in GitHub Desktop.
[ContentProperty("Text")]
public class TranslateExtension : IMarkupExtension<bindingbase>
{
public string Text { get; set; }
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider, ILocalizer localizer)
{
return ProvideValue(serviceProvider, localizer);
}
public BindingBase ProvideValue(IServiceProvider serviceProvider, ILocalizer localizer)
{
var binding = new Binding
{
Mode = BindingMode.OneWay,
Path = localizer.GetTranslation("<language here>")
Source = ResourceManagerHelper.Instance,
};
return binding;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment