Skip to content

Commit

Permalink
Fix several missing translation strings in messages.pot
Browse files Browse the repository at this point in the history
xgettext doesn't pick up calls to GetString() inside of interpolated strings, so for now we avoid that.

In DocumentLayer.cs I also adjusted a couple of the translation strings to allow more control for translators, rather than a hardcoded concatenation that might have some English-based assumptions

Fixes #1954919
  • Loading branch information
cameronwhite committed Dec 15, 2021
1 parent 8656c2d commit 4c269ee
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 19 deletions.
7 changes: 5 additions & 2 deletions Pinta.Core/Classes/DocumentLayers.cs
Expand Up @@ -131,7 +131,8 @@ internal void Close ()
/// </summary>
public UserLayer CreateLayer (string? name = null, int? width = null, int? height = null)
{
name ??= $"{Translations.GetString ("Layer")} {layer_name_int++}";
// Translators: {0} is a unique id for new layers, e.g. "Layer 2".
name ??= Translations.GetString ("Layer {0}", layer_name_int++);
width ??= document.ImageSize.Width;
height ??= document.ImageSize.Height;

Expand Down Expand Up @@ -228,7 +229,9 @@ public void DestroySelectionLayer ()
public UserLayer DuplicateCurrentLayer ()
{
var source = CurrentUserLayer;
var layer = CreateLayer ($"{source.Name} {Translations.GetString ("copy")}");
// Translators: this is the auto-generated name for a duplicated layer.
// {0} is the name of the source layer. Example: "Layer 3 copy".
var layer = CreateLayer (Translations.GetString ("{0} copy", source.Name));

using (var g = new Context (layer.Surface)) {
g.SetSource (source.Surface);
Expand Down
7 changes: 4 additions & 3 deletions Pinta.Core/Extensions/ToolBoxButton.cs
Expand Up @@ -48,9 +48,10 @@ public ToolBoxButton (BaseTool tool)

Show ();

if (tool.ShortcutKey != 0)
TooltipText = $"{tool.Name}\n{Translations.GetString ("Shortcut key")}: {tool.ShortcutKey.ToString ().ToUpperInvariant ()}\n\n{tool.StatusBarText}";
else
if (tool.ShortcutKey != 0) {
var shortcut_label = Translations.GetString ("Shortcut key");
TooltipText = $"{tool.Name}\n{shortcut_label}: {tool.ShortcutKey.ToString ().ToUpperInvariant ()}\n\n{tool.StatusBarText}";
} else
TooltipText = tool.Name;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Core/Managers/ToolManager.cs
Expand Up @@ -336,7 +336,7 @@ public override int Compare (BaseTool? x, BaseTool? y)
private ToolBarImage? tool_image;
private SeparatorToolItem? tool_sep;

private ToolBarLabel ToolLabel => tool_label ??= new ToolBarLabel ($" {Translations.GetString ("Tool")}: ");
private ToolBarLabel ToolLabel => tool_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Tool")));
private ToolBarImage ToolImage => tool_image ??= new ToolBarImage (string.Empty);
private SeparatorToolItem ToolSeparator => tool_sep ??= new SeparatorToolItem ();
}
Expand Down
4 changes: 3 additions & 1 deletion Pinta.Gui.Widgets/Widgets/StatusBarColorPaletteWidget.cs
Expand Up @@ -226,7 +226,9 @@ private void HandleQueryTooltip (object o, Gtk.QueryTooltipArgs args)
text = Translations.GetString ("Click to select secondary color.");
break;
case WidgetElement.SwapColors:
text = $"{Translations.GetString ("Click to switch between primary and secondary color.")} {Translations.GetString ("Shortcut key")}: {"X"}";
var label = Translations.GetString ("Click to switch between primary and secondary color.");
var shortcut_label = Translations.GetString ("Shortcut key");
text = $"{label} {shortcut_label}: {"X"}";
break;
case WidgetElement.ResetColors:
text = Translations.GetString ("Click to reset primary and secondary color.");
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Tools/Tools/BaseBrushTool.cs
Expand Up @@ -101,6 +101,6 @@ protected override void OnSaveSettings (ISettingsService settings)
private ToolBarLabel? brush_width_label;

protected ToolBarWidget<SpinButton> BrushWidthSpinButton => brush_width ??= new (new SpinButton (1, 1e5, 1) { Value = Settings.GetSetting (BRUSH_WIDTH_SETTING, DEFAULT_BRUSH_WIDTH) });
protected ToolBarLabel BrushWidthLabel => brush_width_label ??= new ToolBarLabel ($" {Translations.GetString ("Brush width")}: ");
protected ToolBarLabel BrushWidthLabel => brush_width_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Brush width")));
}
}
4 changes: 2 additions & 2 deletions Pinta.Tools/Tools/ColorPickerTool.cs
Expand Up @@ -194,8 +194,8 @@ private ColorBgra GetPixel (Document document, int x, int y)
private ToolBarDropDownButton? sample_type;
private SeparatorToolItem? sample_sep;

private ToolBarLabel ToolSelectionLabel => tool_select_label ??= new ToolBarLabel ($" {Translations.GetString ("After select")}: ");
private ToolBarLabel SamplingLabel => sampling_label ??= new ToolBarLabel ($" {Translations.GetString ("Sampling")}: ");
private ToolBarLabel ToolSelectionLabel => tool_select_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("After select")));
private ToolBarLabel SamplingLabel => sampling_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Sampling")));
private SeparatorToolItem Separator => sample_sep ??= new SeparatorToolItem ();

private ToolBarDropDownButton ToolSelectionDropDown {
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Tools/Tools/EraserTool.cs
Expand Up @@ -260,7 +260,7 @@ private unsafe void EraseSmooth (ImageSurface surf, Context g, PointD start, Poi
private ToolBarLabel? type_label;
private ToolBarComboBox? type_combobox;

private ToolBarLabel TypeLabel => type_label ??= new ToolBarLabel ($" {Translations.GetString ("Type")}: ");
private ToolBarLabel TypeLabel => type_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Type")));
private ToolBarComboBox TypeComboBox {
get {
if (type_combobox is null) {
Expand Down
4 changes: 2 additions & 2 deletions Pinta.Tools/Tools/FloodTool.cs
Expand Up @@ -123,8 +123,8 @@ protected override void OnSaveSettings (ISettingsService settings)
protected virtual void OnFillRegionComputed (Document document, Point[][] polygonSet) { }
protected virtual void OnFillRegionComputed (Document document, BitMask stencil) { }

protected ToolBarLabel ModeLabel => mode_label ??= new ToolBarLabel ($" {Translations.GetString ("Flood Mode")}: ");
protected ToolBarLabel ToleranceLabel => tolerance_label ??= new ToolBarLabel ($" {Translations.GetString ("Tolerance")}: ");
protected ToolBarLabel ModeLabel => mode_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Flood Mode")));
protected ToolBarLabel ToleranceLabel => tolerance_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Tolerance")));
protected ToolBarSlider ToleranceSlider => tolerance_slider ??= new ToolBarSlider (0, 100, 1, Settings.GetSetting (FILL_TOLERANCE_SETTING, 0));
protected SeparatorToolItem Separator => mode_sep ??= new SeparatorToolItem ();

Expand Down
2 changes: 1 addition & 1 deletion Pinta.Tools/Tools/FreeformShapeTool.cs
Expand Up @@ -219,7 +219,7 @@ protected override void OnSaveSettings (ISettingsService settings)
private SeparatorToolItem? fill_sep;

private SeparatorToolItem Separator => fill_sep ??= new SeparatorToolItem ();
private ToolBarLabel FillLabel => fill_label ??= new ToolBarLabel ($" {Translations.GetString ("Fill Style")}: ");
private ToolBarLabel FillLabel => fill_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Fill Style")));
private ToolBarDropDownButton FillDropDown {
get {
if (fill_button == null) {
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Tools/Tools/GradientTool.cs
Expand Up @@ -151,7 +151,7 @@ private GradientRenderer CreateGradientRenderer ()
private ToolBarLabel? gradient_label;
private ToolBarDropDownButton? gradient_button;

private ToolBarLabel GradientLabel => gradient_label ??= new ToolBarLabel ($" {Translations.GetString ("Gradient")}: ");
private ToolBarLabel GradientLabel => gradient_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Gradient")));
private ToolBarDropDownButton GradientDropDown {
get {
if (gradient_button == null) {
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Tools/Tools/PaintBrushTool.cs
Expand Up @@ -159,7 +159,7 @@ protected override void OnSaveSettings (ISettingsService settings)
private SeparatorToolItem? separator;

private SeparatorToolItem Separator => separator ??= new SeparatorToolItem ();
private ToolBarLabel BrushLabel => brush_label ??= new ToolBarLabel ($" {Translations.GetString ("Type")}: ");
private ToolBarLabel BrushLabel => brush_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Type")));

private ToolBarComboBox BrushComboBox {
get {
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Tools/Tools/RecolorTool.cs
Expand Up @@ -197,7 +197,7 @@ private static byte AdjustColorByte (byte oldByte, byte newByte, byte basisByte)
private ToolBarSlider? tolerance_slider;
private SeparatorToolItem? separator;

private ToolBarLabel ToleranceLabel => tolerance_label ??= new ToolBarLabel ($" {Translations.GetString ("Tolerance")}: ");
private ToolBarLabel ToleranceLabel => tolerance_label ??= new ToolBarLabel (string.Format (" {0}: ", Translations.GetString ("Tolerance")));
private ToolBarSlider ToleranceSlider => tolerance_slider ??= new ToolBarSlider (0, 100, 1, Settings.GetSetting (TOLERANCE_SETTING, 50));
private SeparatorToolItem Separator => separator ??= new SeparatorToolItem ();
}
Expand Down
52 changes: 50 additions & 2 deletions po/messages.pot
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-15 10:43-0500\n"
"POT-Creation-Date: 2021-12-15 11:19-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -106,6 +106,10 @@ msgstr ""
msgid "Additional extensions are required to perform this operation."
msgstr ""

#: ../Pinta.Tools/Tools/ColorPickerTool.cs:197
msgid "After select"
msgstr ""

#: ../Pinta/Actions/File/OpenDocumentAction.cs:71
#: ../Pinta.Core/Actions/EditActions.cs:378
msgid "All files"
Expand Down Expand Up @@ -249,6 +253,7 @@ msgid "Brush Size"
msgstr ""

#: ../Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs:266
#: ../Pinta.Tools/Tools/BaseBrushTool.cs:104
msgid "Brush width"
msgstr ""

Expand Down Expand Up @@ -352,7 +357,7 @@ msgstr ""
msgid "Click and drag to navigate image."
msgstr ""

#: ../Pinta.Gui.Widgets/Widgets/StatusBarColorPaletteWidget.cs:232
#: ../Pinta.Gui.Widgets/Widgets/StatusBarColorPaletteWidget.cs:234
msgid "Click to reset primary and secondary color."
msgstr ""

Expand All @@ -368,6 +373,10 @@ msgstr ""
msgid "Click to select secondary color."
msgstr ""

#: ../Pinta.Gui.Widgets/Widgets/StatusBarColorPaletteWidget.cs:229
msgid "Click to switch between primary and secondary color."
msgstr ""

#: ../Pinta/Dialogs/NewImageDialog.cs:161
#: ../Pinta/Dialogs/NewImageDialog.cs:199
#: ../Pinta/Dialogs/NewImageDialog.cs:341
Expand Down Expand Up @@ -686,6 +695,7 @@ msgid "Fill Shape"
msgstr ""

#: ../Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs:292
#: ../Pinta.Tools/Tools/FreeformShapeTool.cs:222
msgid "Fill Style"
msgstr ""

Expand Down Expand Up @@ -734,6 +744,10 @@ msgstr ""
msgid "Flip Vertical"
msgstr ""

#: ../Pinta.Tools/Tools/FloodTool.cs:126
msgid "Flood Mode"
msgstr ""

#: ../Pinta.Tools/Tools/TextTool.cs:143
msgid "Font"
msgstr ""
Expand Down Expand Up @@ -777,6 +791,7 @@ msgid "Glow"
msgstr ""

#: ../Pinta.Tools/Tools/GradientTool.cs:50
#: ../Pinta.Tools/Tools/GradientTool.cs:154
msgid "Gradient"
msgstr ""

Expand Down Expand Up @@ -991,6 +1006,12 @@ msgstr ""
msgid "Layer Shown"
msgstr ""

#. Translators: {0} is a unique id for new layers, e.g. "Layer 2".
#: ../Pinta.Core/Classes/DocumentLayers.cs:135
#, csharp-format
msgid "Layer {0}"
msgstr ""

#: ../Pinta/Pads/LayersPad.cs:40 ../Pinta/Pads/LayersPad.cs:60
msgid "Layers"
msgstr ""
Expand Down Expand Up @@ -1776,6 +1797,10 @@ msgstr ""
msgid "Rulers"
msgstr ""

#: ../Pinta.Tools/Tools/ColorPickerTool.cs:198
msgid "Sampling"
msgstr ""

#: ../Pinta.Core/Effects/UserBlendOps.cs:48
#: ../Pinta.Effects/Adjustments/HueSaturationEffect.cs:70
msgid "Saturation"
Expand Down Expand Up @@ -1854,6 +1879,11 @@ msgstr ""
msgid "Sharpen"
msgstr ""

#: ../Pinta.Core/Extensions/ToolBoxButton.cs:52
#: ../Pinta.Gui.Widgets/Widgets/StatusBarColorPaletteWidget.cs:230
msgid "Shortcut key"
msgstr ""

#: ../Pinta/Actions/Layers/LayerPropertiesAction.cs:104
msgid "Show Layer"
msgstr ""
Expand Down Expand Up @@ -2030,9 +2060,15 @@ msgid "Title"
msgstr ""

#: ../Pinta.Effects/Effects/RedEyeRemoveEffect.cs:70
#: ../Pinta.Tools/Tools/FloodTool.cs:127
#: ../Pinta.Tools/Tools/RecolorTool.cs:200
msgid "Tolerance"
msgstr ""

#: ../Pinta.Core/Managers/ToolManager.cs:339
msgid "Tool"
msgstr ""

#: ../Pinta.Core/Actions/ViewActions.cs:74
msgid "Tool Box"
msgstr ""
Expand Down Expand Up @@ -2066,6 +2102,11 @@ msgstr ""
msgid "Twist"
msgstr ""

#: ../Pinta.Tools/Tools/EraserTool.cs:263
#: ../Pinta.Tools/Tools/PaintBrushTool.cs:162
msgid "Type"
msgstr ""

#: ../Pinta/MainWindow.cs:559
#, csharp-format
msgid ""
Expand Down Expand Up @@ -2299,6 +2340,13 @@ msgstr ""
msgid "{0} + left click to set origin, left click to paint."
msgstr ""

#. Translators: this is the auto-generated name for a duplicated layer.
#. {0} is the name of the source layer. Example: "Layer 3 copy".
#: ../Pinta.Core/Classes/DocumentLayers.cs:234
#, csharp-format
msgid "{0} copy"
msgstr ""

#: ../Pinta.Core/ImageFormats/FormatDescriptor.cs:93
#, csharp-format
msgid "{0} image ({1})"
Expand Down

0 comments on commit 4c269ee

Please sign in to comment.