Click here to Skip to main content
15,906,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to use constants of different spoken languages in my C# code. I have to declare a "const" for each language or it is already declared in .Net? Please help me out.
Posted
Comments
BillWoodruff 21-Oct-13 2:31am    
Are you asking how you can use characters in non-Roman alphabets like Urdu, Devanagari, etc., in your C# code ? Please clarify.
sp_suresh 21-Oct-13 4:47am    
What is exact requirement ?Do u want to allow to save data in multiple languages ? Or
If you want to use in label then use resource file where you can define your own lable in website .
ahsanriaz1K 21-Oct-13 5:15am    
@BillWoodRuff, @spshewale : i have to declare some languages like English, French, German, etc. as const string. As you know it is a long list, that's why I am asking it that is there any predefined thing in .Net.

You can use the build-in Enumeration of CultureInfo objects that .NET provides. Try this:
// reference the the System.Globalization library
using System.Globalization;
//
// these libraries referenced only because I used Linq to get a List<CultureInfo>
//
using System.Collections.Generic;
using System.Linq;
//
private void ListAllCultures()
{
    List<CultureInfo> culturesList =
        CultureInfo.GetCultures(CultureTypes.AllCultures).ToList<CultureInfo>();

    foreach(CultureInfo theCulture in culturesList)
    {
        Console.WriteLine
        (
            "Culture : {0} Language: {1}",
            theCulture.Name,
            theCulture.EnglishName
        );
    }
}
//
// in your code somewhere run this, then examine the Output Window contents
ListAllCultures();
On my machine right now, the list of Cultures has #378 entries. There is a wealth of information in each CultureInfo object including Calendar information, etc.

Resources: [^], [^]
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900