Thursday, July 09, 2009

Ever wondered about programming in Hindi !!

Sounds crazy and completely useless, doesn't it? But I am sure I will be able to change you mind about that but then end of this post. However it wont be feasible in the real world as we all work in teams and English remains the primary programming language.

I started, as always, with google and ended up here on my blog which rarely meets anyone (including me).

Anyway I started a new project in Visual Studio 2008 and voila! Magic happens -

public class myClass
{
public void MyHindiTextFunction()
{
प्रबंधक<कंपनी<int>, List<कंपनी<int>>> प्रबंधक१ = new प्रबंधक<कंपनी<int>, List<कंपनी<int>>>();
प्रबंधक<परियोजना<Guid>, HashSet<परियोजना<Guid>>> प्रबंधक२ = new प्रबंधक<परियोजना<Guid>, HashSet<परियोजना<Guid>>>();

प्रबंधक१.प्रबंधित_इकाईयां.AddRange(new List<कंपनी<int>> {
new कंपनी<int>(1, "company1"),
new कंपनी<int>(2, "company2"),
new कंपनी<int>(3, "company3"),
new कंपनी<int>(4, "company4"),
new कंपनी<int>(5, "company5") });

प्रबंधक२.प्रबंधित_इकाईयां.Add(new परियोजना<Guid>(Guid.NewGuid(), "project1"));
प्रबंधक२.प्रबंधित_इकाईयां.Add(new परियोजना<Guid>(Guid.NewGuid(), "project2"));
प्रबंधक२.प्रबंधित_इकाईयां.Add(new परियोजना<Guid>(Guid.NewGuid(), "project3"));
प्रबंधक२.प्रबंधित_इकाईयां.Add(new परियोजना<Guid>(Guid.NewGuid(), "project4"));
प्रबंधक२.प्रबंधित_इकाईयां.Add(new परियोजना<Guid>(Guid.NewGuid(), "project5"));

//Select company where company id is in the Product's guid as string 0-o
var क्वेरी = प्रबंधक१.प्रबंधित_इकाईयां.Join(
प्रबंधक२.प्रबंधित_इकाईयां,
क => क.संख्या.ToString(),
क => क.संख्या.ToString(),
(क, ख) => ख.संख्या.ToString().Contains(क.संख्या.ToString()));

}
}

public class प्रबंधक<इकाई_प्रकार, सरणी_प्रकार>
where सरणी_प्रकार : new()
{
private सरणी_प्रकार _प्रबंधित_इकाईयां;
public सरणी_प्रकार प्रबंधित_इकाईयां
{
get { return _प्रबंधित_इकाईयां; }
}

public प्रबंधक()
{
_प्रबंधित_इकाईयां = new सरणी_प्रकार();
}
}

public class कंपनी<कंपनी_संख्या_प्रकार>
{
public कंपनी_संख्या_प्रकार संख्या { get; set; }
public string नाम { get; set; }
public कंपनी(कंपनी_संख्या_प्रकार _संख्या, string _नाम)
{
संख्या = _संख्या;
नाम = _नाम;
}
}

public class परियोजना<कंपनी_संख्या_प्रकार>
{
public कंपनी_संख्या_प्रकार संख्या { get; set; }
public string नाम { get; set; }

public परियोजना(कंपनी_संख्या_प्रकार _संख्या, string _नाम)
{
संख्या = _संख्या;
नाम = _नाम;
}
}
}


I know I know.. Mad Scientist at work :) But is stands to reason that Generics and crazy LINQ is always fun and allows getting more hindi then you could otherwise :)

Further:
  • SKTN - You have to watch his videos. I went LOL+ROLF
  • add en2hi@bot.talk.google.com to GTalks :D
Observations:
  • VS2008 is not complete in supporting Unicode unless the underlying OS is. So Kick you XP and pirate Win7 (Tooltips, Intellisense etc are just square blocks)
  • You can use the hindi transtation of numbers (१, २, ३..) as vars. That are still numbers :[
  • Go to Control panel>Language Ops>Add Hindi keyboard and enable the Language Bar. After that start>Accessories>Accessibility>OnScreen Keyboard. Who the hell owns a hindi keyboard anyways

Note: XP goes crazy with hindi file and folder names and no one want to set Hindi as the primary language. Vista and Win 7 are much better if you rally want to try this.