LocalizationSampleExtension.cs 1.2 KB

1234567891011121314151617181920212223242526272829
  1. using PixiEditor.Extensions.Sdk;
  2. using PixiEditor.Extensions.Sdk.Api.Localization;
  3. namespace LocalizationSample;
  4. public class LocalizationSampleExtension : WasmExtension
  5. {
  6. /// <summary>
  7. /// This method is called when extension is loaded.
  8. /// All extensions are first loaded and then initialized. This method is called before <see cref="OnInitialized"/>.
  9. /// </summary>
  10. public override void OnLoaded()
  11. {
  12. }
  13. /// <summary>
  14. /// This method is called when extension is initialized. After this method is called, you can use Api property to access PixiEditor API.
  15. /// </summary>
  16. public override void OnInitialized()
  17. {
  18. // You can either use direct key or ExtensionUniqueName:Key to access localization strings.
  19. Api.Logger.Log(new LocalizedString("HELLO_WORLD"));
  20. Api.Logger.Log(new LocalizedString("HELLO_NAME", "John Doe"));
  21. // By prepending "PixiEditor:" to the key, you can access built-in PixiEditor localization strings.
  22. // if you prepend any other extension unique name, you can access that extension localization strings.
  23. Api.Logger.Log(new LocalizedString("PixiEditor:SHOW_IMAGE_PREVIEW_TASKBAR"));
  24. }
  25. }