From 69e9c10b5aaf0e624c3b9994f52c2f70974b89d4 Mon Sep 17 00:00:00 2001 From: Balaji Krishnan Date: Sun, 28 Feb 2016 14:07:12 -0800 Subject: [PATCH] Localize strings. --- .../CSharp/Impl/CSharpVSResources.Designer.cs | 81 +++++++++++++++++++ .../CSharp/Impl/CSharpVSResources.resx | 27 +++++++ .../Impl/Options/Formatting/StyleViewModel.cs | 22 +++-- .../Core/Def/ServicesVSResources.Designer.cs | 18 +++++ .../Core/Def/ServicesVSResources.resx | 6 ++ .../AbstractCodeStyleOptionViewModel.cs | 7 +- 6 files changed, 145 insertions(+), 16 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/CSharpVSResources.Designer.cs b/src/VisualStudio/CSharp/Impl/CSharpVSResources.Designer.cs index 2b8144b5ca9..165c1ed3c94 100644 --- a/src/VisualStudio/CSharp/Impl/CSharpVSResources.Designer.cs +++ b/src/VisualStudio/CSharp/Impl/CSharpVSResources.Designer.cs @@ -105,6 +105,15 @@ internal class CSharpVSResources { } } + /// + /// Looks up a localized string similar to Do not prefer 'this.'. + /// + internal static string DoNotPreferThis { + get { + return ResourceManager.GetString("DoNotPreferThis", resourceCulture); + } + } + /// /// Looks up a localized string similar to Place "else" on new line. /// @@ -618,6 +627,33 @@ internal class CSharpVSResources { } } + /// + /// Looks up a localized string similar to predefined type preferences:. + /// + internal static string PredefinedTypesGroupTitle { + get { + return ResourceManager.GetString("PredefinedTypesGroupTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Prefer explicit type. + /// + internal static string PreferExplicitType { + get { + return ResourceManager.GetString("PreferExplicitType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Prefer framework type. + /// + internal static string PreferFrameworkType { + get { + return ResourceManager.GetString("PreferFrameworkType", resourceCulture); + } + } + /// /// Looks up a localized string similar to For locals, parameters and members. /// @@ -636,6 +672,33 @@ internal class CSharpVSResources { } } + /// + /// Looks up a localized string similar to Prefer predefined type. + /// + internal static string PreferPredefinedType { + get { + return ResourceManager.GetString("PreferPredefinedType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Prefer 'this.'. + /// + internal static string PreferThis { + get { + return ResourceManager.GetString("PreferThis", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Prefer 'var'. + /// + internal static string PreferVar { + get { + return ResourceManager.GetString("PreferVar", resourceCulture); + } + } + /// /// Looks up a localized string similar to Qualify event access with 'this'. /// @@ -654,6 +717,15 @@ internal class CSharpVSResources { } } + /// + /// Looks up a localized string similar to 'this.' preferences:. + /// + internal static string QualifyGroupTitle { + get { + return ResourceManager.GetString("QualifyGroupTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Qualify method access with 'this'. /// @@ -987,6 +1059,15 @@ internal class CSharpVSResources { } } + /// + /// Looks up a localized string similar to 'var' preferences:. + /// + internal static string VarGroupTitle { + get { + return ResourceManager.GetString("VarGroupTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Leave statements and member declarations on the same line. /// diff --git a/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx b/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx index c72fadaaca2..ebeff3fa906 100644 --- a/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx +++ b/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx @@ -432,4 +432,31 @@ Qualify property access with 'this' + + Prefer explicit type + + + Prefer framework type + + + Prefer predefined type + + + Prefer 'this.' + + + Prefer 'var' + + + 'this.' preferences: + + + 'var' preferences: + + + Do not prefer 'this.' + + + predefined type preferences: + \ No newline at end of file diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs index 37e02e0a87d..9923928e859 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs @@ -170,31 +170,29 @@ internal StyleViewModel(OptionSet optionSet, IServiceProvider serviceProvider) : { CodeStyleItems = new ObservableCollection(); - ListCollectionView collectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(CodeStyleItems); + var collectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(CodeStyleItems); collectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AbstractCodeStyleOptionViewModel.GroupName))); - // TODO: move all strings from here to resx for loc. - - const string qualifyGroupTitle = "this. preferences:"; - const string predefinedTypesGroupTitle = "predefined type preferences:"; - const string varGroupTitle = "'var' preferences:"; + var qualifyGroupTitle = CSharpVSResources.QualifyGroupTitle; + var predefinedTypesGroupTitle = CSharpVSResources.PredefinedTypesGroupTitle; + var varGroupTitle = CSharpVSResources.VarGroupTitle; var qualifyMemberAccessPreferences = new List { - new CodeStylePreference("Prefer this.", true), - new CodeStylePreference("Do not prefer this.", false), + new CodeStylePreference(CSharpVSResources.PreferThis, isChecked: true), + new CodeStylePreference(CSharpVSResources.DoNotPreferThis, isChecked: false), }; var predefinedTypesPreferences = new List { - new CodeStylePreference("Prefer predefined type", true), - new CodeStylePreference("Prefer framework type", false), + new CodeStylePreference(CSharpVSResources.PreferPredefinedType, isChecked: true), + new CodeStylePreference(CSharpVSResources.PreferFrameworkType, isChecked: false), }; var useVarPreferences = new List { - new CodeStylePreference("Prefer 'var'", true), - new CodeStylePreference("Prefer explicit type", false), + new CodeStylePreference(CSharpVSResources.PreferVar, isChecked: true), + new CodeStylePreference(CSharpVSResources.PreferExplicitType, isChecked: false), }; CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(SimplificationOptions.QualifyMemberAccessWithThisOrMe, CSharpVSResources.QualifyMemberAccessWithThis, s_declarationPreviewTrue, s_declarationPreviewFalse, this, optionSet, qualifyGroupTitle, qualifyMemberAccessPreferences)); diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs b/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs index 9922678e866..47d26610d75 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs +++ b/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs @@ -764,6 +764,15 @@ internal class ServicesVSResources { } } + /// + /// Looks up a localized string similar to No. + /// + internal static string No { + get { + return ResourceManager.GetString("No", resourceCulture); + } + } + /// /// Looks up a localized string similar to No Changes. /// @@ -1227,6 +1236,15 @@ internal class ServicesVSResources { } } + /// + /// Looks up a localized string similar to Yes. + /// + internal static string Yes { + get { + return ResourceManager.GetString("Yes", resourceCulture); + } + } + /// /// Looks up a localized string similar to You must select at least one member.. /// diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index 600799deaf2..41c16759baa 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -513,4 +513,10 @@ Use the dropdown to view and switch to other projects this file may belong to. <Unknown> + + No + + + Yes + \ No newline at end of file diff --git a/src/VisualStudio/Core/Impl/Options/AbstractCodeStyleOptionViewModel.cs b/src/VisualStudio/Core/Impl/Options/AbstractCodeStyleOptionViewModel.cs index 276fc911156..0aefcfd5bdb 100644 --- a/src/VisualStudio/Core/Impl/Options/AbstractCodeStyleOptionViewModel.cs +++ b/src/VisualStudio/Core/Impl/Options/AbstractCodeStyleOptionViewModel.cs @@ -37,7 +37,7 @@ internal abstract class AbstractCodeStyleOptionViewModel : AbstractNotifyPropert public List NotificationPreferences { get; set; } public abstract bool NotificationsAvailable { get; } - public virtual string GetPreview() => SelectedPreference.IsChecked? _truePreview : _falsePreview; + public virtual string GetPreview() => SelectedPreference.IsChecked ? _truePreview : _falsePreview; public AbstractCodeStyleOptionViewModel( IOption option, @@ -77,9 +77,8 @@ private static List GetDefaultPreferences() { return new List { - // TODO: move to resx for loc. - new CodeStylePreference("Yes", true), - new CodeStylePreference("No", false), + new CodeStylePreference(ServicesVSResources.Yes, isChecked: true), + new CodeStylePreference(ServicesVSResources.No, isChecked: false), }; } -- GitLab