-
Notifications
You must be signed in to change notification settings - Fork 275
Making Your Addin Translatable
Pinta is translated into over 55 different languages, so you'll want to make sure that your add-in can be translated into other languages as well!
This guide builds on the effect written in Writing an Effect or Adjustment.
In your add-in's .addin.xml
file, you can specify the localizer that should be used. Using string resources is the recommended method, since there is no additional work required when packaging the add-in (the satellite assemblies are automatically included).
<Addin ...>
<Localizer type="StringResource" />
</Addin>
Create a resource file Resources/Language.resx
which contains the untranslated strings. Files such as Resources/Language.fr.resx
will contain the translated strings for each language, which have been provided by translators. See the Night Vision Add-in for an example.
You can use a service such as Weblate to provide a convenient interface for translators to edit the strings. Add-ins can also be added to Pinta's main Weblate instance - please create a ticket at https://github.com/PintaProject/Pinta-Community-Addins if you wish to have this set up.
Elements in the add-in header, such as the name and description, can only be translated by embedding the translated strings in .addin.xml
. Pinta provides a tool to merge translations from resource files into .addin.xml
at build time, to allow the translations to still be included in the resource files for easy integration with Weblate. See the Night Vision Add-in's build script for an example of doing this.
To use translated strings in your add-in's code, you can use AddinManager.CurrentLocalizer.GetString
to fetch the translated string for the user's locale. For example, here is the Name
property of the Night Vision add-in:
public override string Name => AddinManager.CurrentLocalizer.GetString ("Night Vision");
When creating an effect dialog using SimpleEffectDialog
, you must also pass AddinManager.CurrentLocalizer
into the dialog so that it can find translations for the names of any properties of your effect:
public override void LaunchConfiguration ()
{
LaunchSimpleEffectDialog (AddinManager.CurrentLocalizer);
}