J.S. J.S. - 1 year ago 87
C# Question

Visual Studio Designer Choosable Language Limitation

I am developing in Visual Studio 2013 (C#) atm. and am searching for a way to make the selection of languages for a windows form easier for localization.

In the designer you have the possibility to select the language you want under "Design"→"Language" and Visual Studio does the rest by creating the necessary localization files if you need a new localized form.

The problem is: Currently I only work with two different languages, and everytime when I switch between those localized forms it shows me a list of all possible languages, where a wrong click can cause visual studio to create localized version of a language I don't want, which is just annoying and clutters the project with more files.

Does anyone know a way to limit the languages shown in the designer options to a desired amount and selection?

Answer Source

Language property is a design-time only property which doesn't belong to Form class. It's an extended property added using an extender provider to design-time of form. It is of type of CultureInfo and uses a TypeConverter which shows all available cultures.

As a workaround , you can have a BaseForm containing a property like FormLanguage and in the get, return value of Language property and in the set, set the value of Language property. Then inherit all your forms from this BaseForm. This way, it's enough to change FormLanguage property.

Also create a custom type converter for CultureInfo which shows only those culture which you want, then to change language, it's enough to change FormLanguage property.

Localization Language

Here is the code I used as workaround. Don't forget to inherit your forms from this BaseClass.

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Windows.Forms;
public partial class BaseForm : Form
    public CultureInfo FormLanguage
            return TypeDescriptor.GetProperties(this)["Language"].GetValue(this) as CultureInfo;
            TypeDescriptor.GetProperties(this)["Language"].SetValue(this, value);
public class MyCultureInfoConverter : CultureInfoConverter
    public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        var values = CultureInfo.GetCultures(CultureTypes.SpecificCultures | CultureTypes.NeutralCultures)
                                .Where(x => x.Name == "fa-IR" || x.Name == "en-US").ToList();
        values.Insert(0, CultureInfo.InvariantCulture);
        return new StandardValuesCollection(values);

When you select fa-IR from FormLanguage then the Language becomes Persian automatically because of the code which we wrote in setter of FormLanguage. You can add any other language which you need in MyCultureInfoConverter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download