From c51ec2896c7825ce790c045eeefc2ad9843db49e Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 14 Jun 2022 09:32:37 -0700 Subject: [PATCH] Localized strings. --- Terminal.Gui/Resources/Strings.Designer.cs | 27 ++++ Terminal.Gui/Resources/Strings.fr-FR.resx | 149 ++++++++++++--------- Terminal.Gui/Resources/Strings.ja-JP.resx | 9 ++ Terminal.Gui/Resources/Strings.pt-PT.resx | 149 ++++++++++++--------- Terminal.Gui/Resources/Strings.resx | 149 ++++++++++++--------- Terminal.Gui/Windows/Wizard.cs | 12 +- UnitTests/ButtonTests.cs | 40 +++++- 7 files changed, 349 insertions(+), 186 deletions(-) diff --git a/Terminal.Gui/Resources/Strings.Designer.cs b/Terminal.Gui/Resources/Strings.Designer.cs index e15a9e6a9..4c10f6e7d 100644 --- a/Terminal.Gui/Resources/Strings.Designer.cs +++ b/Terminal.Gui/Resources/Strings.Designer.cs @@ -185,5 +185,32 @@ namespace Terminal.Gui.Resources { return ResourceManager.GetString("fdSelectMixed", resourceCulture); } } + + /// + /// Looks up a localized string similar to _Back. + /// + internal static string wzBack { + get { + return ResourceManager.GetString("wzBack", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fi_nish. + /// + internal static string wzFinish { + get { + return ResourceManager.GetString("wzFinish", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to _Next.... + /// + internal static string wzNext { + get { + return ResourceManager.GetString("wzNext", resourceCulture); + } + } } } diff --git a/Terminal.Gui/Resources/Strings.fr-FR.resx b/Terminal.Gui/Resources/Strings.fr-FR.resx index 1ecb1394a..28a48dc1d 100644 --- a/Terminal.Gui/Resources/Strings.fr-FR.resx +++ b/Terminal.Gui/Resources/Strings.fr-FR.resx @@ -1,76 +1,96 @@  + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + - + + @@ -89,13 +109,13 @@ text/microsoft-resx - 1.3 + 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 _Copier @@ -139,4 +159,13 @@ Sélection _mixte + + _Précédent + + + Fi_nir + + + Prochai_n... + \ No newline at end of file diff --git a/Terminal.Gui/Resources/Strings.ja-JP.resx b/Terminal.Gui/Resources/Strings.ja-JP.resx index 726e1c256..68b15dda8 100644 --- a/Terminal.Gui/Resources/Strings.ja-JP.resx +++ b/Terminal.Gui/Resources/Strings.ja-JP.resx @@ -159,4 +159,13 @@ 混在選択 + + 戻る + + + 終える + + + 次に + \ No newline at end of file diff --git a/Terminal.Gui/Resources/Strings.pt-PT.resx b/Terminal.Gui/Resources/Strings.pt-PT.resx index c336bf7b8..a8385c556 100644 --- a/Terminal.Gui/Resources/Strings.pt-PT.resx +++ b/Terminal.Gui/Resources/Strings.pt-PT.resx @@ -1,76 +1,96 @@  + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + - + + @@ -89,13 +109,13 @@ text/microsoft-resx - 1.3 + 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 _Copiar @@ -139,4 +159,13 @@ Selecione misto + + _Voltar + + + Acabam_ento + + + S_eguir + \ No newline at end of file diff --git a/Terminal.Gui/Resources/Strings.resx b/Terminal.Gui/Resources/Strings.resx index 734d8aed4..f6cfb7b4b 100644 --- a/Terminal.Gui/Resources/Strings.resx +++ b/Terminal.Gui/Resources/Strings.resx @@ -1,76 +1,96 @@  + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + - + + @@ -89,13 +109,13 @@ text/microsoft-resx - 1.3 + 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 _Select All @@ -139,4 +159,13 @@ Select Mixed + + _Back + + + Fi_nish + + + _Next... + \ No newline at end of file diff --git a/Terminal.Gui/Windows/Wizard.cs b/Terminal.Gui/Windows/Wizard.cs index cd8b3dc20..d7e9494df 100644 --- a/Terminal.Gui/Windows/Wizard.cs +++ b/Terminal.Gui/Windows/Wizard.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using NStack; +using Terminal.Gui.Resources; namespace Terminal.Gui { /// @@ -232,10 +233,11 @@ namespace Terminal.Gui { }; Add (separator); - backBtn = new Button ("_Back") { AutoSize = true }; + // BUGBUG: Space is to work around https://github.com/migueldeicaza/gui.cs/issues/1812 + backBtn = new Button (" ") { AutoSize = true }; AddButton (backBtn); - nextfinishBtn = new Button ("_Next...") { AutoSize = true }; + nextfinishBtn = new Button (" ") { AutoSize = true }; nextfinishBtn.IsDefault = true; AddButton (nextfinishBtn); @@ -498,14 +500,14 @@ namespace Terminal.Gui { // TODO: Move strings to loc // Configure the Back button - backBtn.Text = newStep.BackButtonText != ustring.Empty ? newStep.BackButtonText : "_Back"; + backBtn.Text = newStep.BackButtonText != ustring.Empty ? newStep.BackButtonText : Strings.wzBack; // "_Back"; backBtn.Visible = (newStep != steps.First.Value); // Configure the Next/Finished button if (newStep == steps.Last.Value) { - nextfinishBtn.Text = newStep.NextButtonText != ustring.Empty ? newStep.NextButtonText : "Fi_nish"; + nextfinishBtn.Text = newStep.NextButtonText != ustring.Empty ? newStep.NextButtonText : Strings.wzFinish; // "Fi_nish"; } else { - nextfinishBtn.Text = newStep.NextButtonText != ustring.Empty ? newStep.NextButtonText : "_Next..."; + nextfinishBtn.Text = newStep.NextButtonText != ustring.Empty ? newStep.NextButtonText : Strings.wzNext; // "_Next..."; } // Set focus to the nav buttons diff --git a/UnitTests/ButtonTests.cs b/UnitTests/ButtonTests.cs index 6c42514d1..ccf8c71dd 100644 --- a/UnitTests/ButtonTests.cs +++ b/UnitTests/ButtonTests.cs @@ -267,6 +267,7 @@ namespace Terminal.Gui.Views { Assert.Equal (new Rect (0, 0, 30, 5), pos); } + [Fact, AutoInitShutdown] public void AutoSize_Stays_True_Center () { @@ -322,7 +323,7 @@ namespace Terminal.Gui.Views { Text = "Say Hello 你", AutoSize = true }; - btn.X = Pos.AnchorEnd () - Pos.Function (() => TextFormatter.GetTextWidth (btn.TextFormatter.Text)); + btn.X = Pos.AnchorEnd () - Pos.Function (() => TextFormatter.GetTextWidth (btn.TextFormatter.Text)); var win = new Window () { Width = Dim.Fill (), @@ -360,5 +361,42 @@ namespace Terminal.Gui.Views { GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); } + + + [Fact, AutoInitShutdown] + public void AutoSize_Stays_True_With_EmptyText () + { + var btn = new Button () { + X = Pos.Center (), + Y = Pos.Center (), + AutoSize = true + }; + + var win = new Window () { + Width = Dim.Fill (), + Height = Dim.Fill (), + Title = "Test Demo 你" + }; + win.Add (btn); + Application.Top.Add (win); + + Assert.True (btn.AutoSize); + + btn.Text = "Say Hello 你"; + + Assert.True (btn.AutoSize); + + Application.Begin (Application.Top); + ((FakeDriver)Application.Driver).SetBufferSize (30, 5); + var expected = @" + ┌ Test Demo 你 ──────────────┐ + │ │ + │ [ Say Hello 你 ] │ + │ │ + └────────────────────────────┘ + "; + + GraphViewTests.AssertDriverContentsWithFrameAre (expected, output); + } } }