From 6d4f58bf14ae2a4b38d938e3bd8c553aae91baee Mon Sep 17 00:00:00 2001 From: "Andrew Hall (METAL)" Date: Tue, 19 Mar 2019 14:40:09 -0700 Subject: [PATCH] Move strings to resource file --- src/Test/Utilities/Portable/Traits/Traits.cs | 1 + .../MoveToNamespaceDialogViewModel.cs | 8 +-- .../Core/Def/ServicesVSResources.Designer.cs | 18 +++++ .../Core/Def/ServicesVSResources.resx | 6 ++ .../Core/Def/xlf/ServicesVSResources.cs.xlf | 10 +++ .../Core/Def/xlf/ServicesVSResources.de.xlf | 10 +++ .../Core/Def/xlf/ServicesVSResources.es.xlf | 10 +++ .../Core/Def/xlf/ServicesVSResources.fr.xlf | 10 +++ .../Core/Def/xlf/ServicesVSResources.it.xlf | 10 +++ .../Core/Def/xlf/ServicesVSResources.ja.xlf | 10 +++ .../Core/Def/xlf/ServicesVSResources.ko.xlf | 10 +++ .../Core/Def/xlf/ServicesVSResources.pl.xlf | 10 +++ .../Def/xlf/ServicesVSResources.pt-BR.xlf | 10 +++ .../Core/Def/xlf/ServicesVSResources.ru.xlf | 10 +++ .../Core/Def/xlf/ServicesVSResources.tr.xlf | 10 +++ .../Def/xlf/ServicesVSResources.zh-Hans.xlf | 10 +++ .../Def/xlf/ServicesVSResources.zh-Hant.xlf | 10 +++ .../MoveToNamespaceDialogViewModelTests.vb | 66 +++++++++++++++++++ 18 files changed, 224 insertions(+), 5 deletions(-) create mode 100644 src/VisualStudio/Core/Test/MoveToNamespace/MoveToNamespaceDialogViewModelTests.vb diff --git a/src/Test/Utilities/Portable/Traits/Traits.cs b/src/Test/Utilities/Portable/Traits/Traits.cs index b5da3351f74..825427ccff2 100644 --- a/src/Test/Utilities/Portable/Traits/Traits.cs +++ b/src/Test/Utilities/Portable/Traits/Traits.cs @@ -111,6 +111,7 @@ public static class Features public const string CodeActionsMergeConsecutiveIfStatements = "CodeActions.MergeConsecutiveIfStatements"; public const string CodeActionsMergeNestedIfStatements = "CodeActions.MergeNestedIfStatements"; public const string CodeActionsMoveDeclarationNearReference = "CodeActions.MoveDeclarationNearReference"; + public const string CodeActionsMoveToNamespace = nameof(CodeActionsMoveToNamespace); public const string CodeActionsMoveToTopOfFile = "CodeActions.MoveToTopOfFile"; public const string CodeActionsMoveType = "CodeActions.MoveType"; public const string CodeActionsOrderModifiers = "CodeActions.OrderModifiers"; diff --git a/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/MoveToNamespaceDialogViewModel.cs b/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/MoveToNamespaceDialogViewModel.cs index 8122e452b98..f8af7c48aab 100644 --- a/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/MoveToNamespaceDialogViewModel.cs +++ b/src/VisualStudio/Core/Def/Implementation/MoveToNamespace/MoveToNamespaceDialogViewModel.cs @@ -2,10 +2,8 @@ using System.Collections.Immutable; using Microsoft.VisualStudio.Imaging.Interop; -using Microsoft.VisualStudio.Language.Intellisense; using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities; using Microsoft.VisualStudio.Imaging; -using Microsoft.CodeAnalysis.MoveToNamespace; using Roslyn.Utilities; namespace Microsoft.VisualStudio.LanguageServices.Implementation.MoveToNamespace @@ -19,7 +17,7 @@ class MoveToNamespaceDialogViewModel : AbstractNotifyPropertyChanged NamespaceName = defaultNamespace; AvailableNamespaces = availableNamespaces; - this.PropertyChanged += MoveToNamespaceDialogViewModel_PropertyChanged; + PropertyChanged += MoveToNamespaceDialogViewModel_PropertyChanged; } private void MoveToNamespaceDialogViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -40,14 +38,14 @@ public void OnNamespaceUpdated() if (isNewNamespace && isValidName) { Icon = KnownMonikers.StatusInformation; - Message = $"'{NamespaceName}' will be created as a new namespace"; + Message = string.Format(ServicesVSResources._0_will_be_created_as_a_new_namespace, NamespaceName); ShowMessage = true; CanSubmit = true; } else if (!isValidName) { Icon = KnownMonikers.StatusInvalid; - Message = $"'{NamespaceName}' is not a valid namespace"; + Message = string.Format(ServicesVSResources._0_is_an_invalid_namespace, NamespaceName); ShowMessage = true; CanSubmit = false; } diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs b/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs index b8300fe79b3..31adcece426 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs +++ b/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs @@ -69,6 +69,15 @@ internal class ServicesVSResources { } } + /// + /// Looks up a localized string similar to '{0}' is an invalid namespace. + /// + internal static string _0_is_an_invalid_namespace { + get { + return ResourceManager.GetString("_0_is_an_invalid_namespace", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} references. /// @@ -116,6 +125,15 @@ internal class ServicesVSResources { } } + /// + /// Looks up a localized string similar to '{0}' will be created as a new namespace. + /// + internal static string _0_will_be_created_as_a_new_namespace { + get { + return ResourceManager.GetString("_0_will_be_created_as_a_new_namespace", resourceCulture); + } + } + /// /// Looks up a localized string similar to 1 reference. /// diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index b618538e019..5160fc60687 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1210,4 +1210,10 @@ I agree to all of the foregoing: Target Namespace: + + '{0}' is an invalid namespace + + + '{0}' will be created as a new namespace + \ No newline at end of file diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index ef74d6d8714..c35b49af7fb 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -432,6 +432,11 @@ Není platnou hodnotou. + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. {0} se změní na abstraktní. @@ -447,6 +452,11 @@ {0} se změní na veřejný. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo Daný pracovní prostor nepodporuje vrácení akce zpátky. diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index d89163769e2..a4f80320fd9 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -432,6 +432,11 @@ Kein gültiger Wert. + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. "{0}" wird in abstrakten Wert geändert. @@ -447,6 +452,11 @@ "{0}" wird in öffentlichen Wert geändert. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo Der angegebene Arbeitsbereich unterstützt die Funktion "Rückgängig" nicht. diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index a652e4b3501..f15db8ca380 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -432,6 +432,11 @@ No es un valor válido + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. "{0}" se cambiará a abstracto. @@ -447,6 +452,11 @@ "{0}" se cambiará a público. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo el área de trabajo determinada no permite deshacer diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index abf2fe93cf3..5b445603aa0 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -432,6 +432,11 @@ Valeur non valide + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. '{0}' va être changé en valeur abstraite. @@ -447,6 +452,11 @@ '{0}' va être changé en valeur publique. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo l'espace de travail donné ne prend pas en charge la fonction Annuler diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index 465712bde78..279183b57bb 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -432,6 +432,11 @@ Valore non valido + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. '{0}' verrà modificato in astratto. @@ -447,6 +452,11 @@ '{0}' verrà modificato in pubblico. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo l'area di lavoro specificata non supporta l'annullamento di operazioni diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index 8a8662ae979..a2d16066e17 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -432,6 +432,11 @@ 有効な値ではありません + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. '{0}' は抽象に変更されます。 @@ -447,6 +452,11 @@ '{0}' はパブリックに変更されます。 + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo 指定されたワークスペースは元に戻す操作をサポートしていません diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index a10677dbf8e..ca6c472486d 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -432,6 +432,11 @@ 값이 잘못되었습니다. + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. '{0}'이(가) 추상으로 변경됩니다. @@ -447,6 +452,11 @@ '{0}'이(가) 공용으로 변경됩니다. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo 지정한 작업 영역에서 실행을 취소할 수 없습니다. diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index 0c4276963f1..37fdf14d496 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -432,6 +432,11 @@ Nieprawidłowa wartość + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. Element „{0}” zostanie zmieniony na abstrakcyjny. @@ -447,6 +452,11 @@ Element „{0}” zostanie zmieniony na publiczny. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo dany obszar roboczy nie obsługuje operacji cofania diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index 48882487170..86c7d49e82b 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -432,6 +432,11 @@ O valor não é válido + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. '{0}' será alterado para abstrato. @@ -447,6 +452,11 @@ '{0}' será alterado para público. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo o workspace fornecido não dá suporte a desfazer diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index e8e733afbae..370521bce90 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -432,6 +432,11 @@ Недопустимое значение + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. Элемент "{0}" будет изменен на абстрактный. @@ -447,6 +452,11 @@ Элемент "{0}" будет изменен на открытый. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo заданная рабочая область не поддерживает отмену. diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index 444f04bd48c..691978322ea 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -432,6 +432,11 @@ Geçerli bir değer değil + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. '{0}' soyut olacak şekilde değiştirildi. @@ -447,6 +452,11 @@ '{0}' ortak olacak şekilde değiştirildi. + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo sağlanan çalışma alanı, geri almayı desteklemiyor diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index 9198b7bb785..804e954cbd0 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -432,6 +432,11 @@ 值无效 + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. “{0}”将更改为“抽象”。 @@ -447,6 +452,11 @@ “{0}”将更改为“公共”。 + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo 给定的工作区不支持撤消 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index 2d50cb1ee8e..302adca52a7 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -432,6 +432,11 @@ 值無效 + + '{0}' is an invalid namespace + '{0}' is an invalid namespace + + '{0}' will be changed to abstract. '{0}' 會變更為抽象。 @@ -447,6 +452,11 @@ '{0}' 會變更為公用。 + + '{0}' will be created as a new namespace + '{0}' will be created as a new namespace + + given workspace doesn't support undo 指定的工作區不支援復原 diff --git a/src/VisualStudio/Core/Test/MoveToNamespace/MoveToNamespaceDialogViewModelTests.vb b/src/VisualStudio/Core/Test/MoveToNamespace/MoveToNamespaceDialogViewModelTests.vb new file mode 100644 index 00000000000..da66ee2f416 --- /dev/null +++ b/src/VisualStudio/Core/Test/MoveToNamespace/MoveToNamespaceDialogViewModelTests.vb @@ -0,0 +1,66 @@ +' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +Imports System.Collections.Immutable +Imports Microsoft.CodeAnalysis.Test.Utilities +Imports Microsoft.VisualStudio.Imaging +Imports Microsoft.VisualStudio.LanguageServices.Implementation.MoveToNamespace + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.MoveToNamespace + + <[UseExportProvider]> + Public Class MoveToNamespaceDialogViewModelTests + + Public Sub TestMoveToNamespace_ErrorState() + Dim viewModel = CreateViewModel() + + Assert.True(viewModel.CanSubmit) + Assert.False(viewModel.ShowMessage) + + viewModel.NamespaceName = "2InvalidNamespace" + + Assert.False(viewModel.CanSubmit) + Assert.True(viewModel.ShowMessage) + Assert.Equal(viewModel.Icon, KnownMonikers.StatusInvalid) + + viewModel.NamespaceName = viewModel.AvailableNamespaces.First() + + Assert.True(viewModel.CanSubmit) + Assert.False(viewModel.ShowMessage) + End Sub + + + Public Sub TestMoveToNamespace_NewNamespaceState() + Dim viewModel = CreateViewModel() + + Assert.True(viewModel.CanSubmit) + Assert.False(viewModel.ShowMessage) + + viewModel.NamespaceName = viewModel.AvailableNamespaces.Last() & ".NewNamespace" + + Assert.True(viewModel.CanSubmit) + Assert.True(viewModel.ShowMessage) + Assert.Equal(viewModel.Icon, KnownMonikers.StatusInformation) + + viewModel.NamespaceName = viewModel.AvailableNamespaces.First() + + Assert.True(viewModel.CanSubmit) + Assert.False(viewModel.ShowMessage) + End Sub + + Private Function CreateViewModel(Optional defaultNamespace As String = Nothing, Optional availableNamespaces As ImmutableArray(Of String) = Nothing) As MoveToNamespaceDialogViewModel + If (defaultNamespace Is Nothing) Then + defaultNamespace = "Default.Namespace" + End If + + If (availableNamespaces = Nothing) Then + availableNamespaces = ImmutableArray.Create({ + defaultNamespace, + defaultNamespace & "1", + defaultNamespace & "2"}) + End If + + Return New MoveToNamespaceDialogViewModel(defaultNamespace, availableNamespaces) + End Function + End Class +End Namespace + -- GitLab