Tuesday, January 27, 2009

Developing Websites in Regional Languages

Recently, I had a couple of queries on how to develop sites in Hindi, Marathi and other regional languages so I thought I will actually blog about it. I have also had questions on whether using images for regional text is the way to go but fortunately, .NET and Windows gives you better and slicker ways of doing this so read on. I am using Windows XP and VS 2008 but the steps should be similar for almost all the Operating Systems.

One of the first things that you need to do if you are developing sites in regional language is to set up your webserver to display this text. This is how you can do it.

Step – I

Go to Start -> Control Panel - > Regional and Language Options

Click Languages Tab and then check the two text boxes. If you are developing sites only in Indian Regional languages, checking the second check box should do.

Step – II

The next step is to add the ability to enter Hindi Text on your machine. This can either be your Development Machine or your web server.

In the same screen click on Details under the Text Services and Input Languages. You are taken to the Text Services and Input Languages Screen. This is the screen where you tell your computer that you wish to add the regional language of your choice as an input mechanism.

Step - III

In your installed services click Add and Select the Language you want to be able to input. This is how your screen will look when you do this. You will see that I have added Hindi.

Another small change that you will probably not notice is in your task bar. On the bottom right you should see EN next to the System tray. Click on that EN and you will see the screen below

Click on Hindi to be able to enter text in Hindi. The easiest way to check this is to open a Word document and type there.

Now we have our system enabled to enter text in Hindi. Its time we move on to our application. As I have said before I am going to use VS 2008 to demonstrate this to you. Open VS 2008 and create a new website. In the Default.aspx page add a calendar control. Open the web.config and add the following tag inside the system.web element

<globalization uiCulture="hi-IN" fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8"/>

 Now run the website. If you have done everything right you should see the calendar in Hindi, something like below

Monday, January 26, 2009

Jan quizzes in Chennai

The long weekend of the 24th, 25th and 26th Jan had three quizzes in Chennai. I attended two of those. The Mylapore Quiz which was a part of the Mylapore festival on the 25th and the IQL India Unplugged on the 26th of Jan. Both of them where conducted at the same venue. Hotel Karpagam Hall in Mylapore. Read on to know my views on how it went
The Mylapore quiz was a part of the Mylapore Festival that is fast becoming one of the famous neighborhood events in the city. The quiz master for the afternoon was Ashwin Prabhu. There was a prelims of 20 questions followed by the finals which was 6rounds.
The questions were very well framed and the enthusiasm of the participantsand their love for Mylapore was quite evident. The team of V.V. Ramanan and Ram Shankar walked away with the laurels. Overall the quiz was a very good experience. For somebody who is trying to get back to quizzing regularly, it was very enjoyable. Thanks to Ashwin and Srinivas for putting together a set of intriguing questions.
The second quiz was the India Unplugged conducted by the India Quizzing League. Personally, I thought the quiz would have had better participation if it was slotted in the evening. The quiz was scheduled at 09.30 AM in the morning. Karthik Narayanan started off the quiz with a fun question on JK Rithish. The prelims was a set of 30 questions. Again 6 teams got into the finals. This is where the quiz started to falter I thought. The questions for the finals could have been thought out better. Infact, the quiz seemed to get very long and the third round was a bit dry. I couldn’t stay till the end but kudos to the IQL Team for putting up this quiz. Jan 26th Is usually the date for the Odyssey Quiz but that didn’t happen this year. The IQL Team came forward and filled the void. This can only get better.

Tuesday, September 16, 2008

ADO.NET Data Services - Part - III


To work with ADO.NET Data Services, you should ensure that you have .NET 3.5 Framework SP1 installed. Apart from ADO.NET Data Services SP1 brings to the table a lot of new features. For a list of new features in SP1 refer to this link (VS 2008 and .NET 3.5 SP1 Features).


 


Once you have the SP1 installed, open VS 2008 and open a new web application. Right click on the solution and add a new ADO.NET Data Entity model. The extension of the file will be edmx. A wizard will guide you through the process of creating an entity model based on a selected database. I will not get into the details of the wizard for the sake of brevity. The wizard is quite self-explanatory. The only thing worth mentioning is to set support for MARS resultsets in your advanced window when you click new connection.



 


 


Once you have run through the wizard, depending on the tables you have selected you will see a data model like the one shown in the picture.


 


You can also create an entity model only for the tables you want, by selecting the appropriate tables in the wizard. We will now go on to add the ADO.NET Data Service. You can do this by opening  the add new item dialog box and selecting ADO.NET Data Service from it.


 


Once you have added the svc, you will see the code behind. Lets take a look at the only method that exists.


 


The method InitializeService is the first method that will be called when your service is invoked.  Any code that you write in this method is applicable to all the data models that you expose through your web service. One of the key things that you will do here is taking care of security. Though .NET gives us some built-in methods to set rights, more often than not we will be writing our code to monitor these accesses. The InitializeService gives us a single place where we can write code for access privileges for the whole service.


 


Coming back to the code behind, there are a couple of things you have to change in here to get it up and working. You will have to include the name of the datasource class in your servce name declaration. Replace the “/* TODO: put your data source class name here */ with the name of your entity class. You can find out the name of the entity class by looking the class name from the designer.cs file.


 


Build and run the solution. You will get a response like the one shown in the picture. This is because currently you have not set the rights. To view or access the exposed services, you should give rights explicitly.



 



 


Open your code editor. In your InitializeMethod uncomment the two statements


 


config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead);


config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);


 


Replace the “MyEntitySet” with the name of the Entity and “MyServiceOPeration” with the name of the operation or the methods that you write. To provide access to all the entities and the operations use “*”. In my code for testing, this is what I have done.


 


             config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);


             config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);


 


That’s it!! Your service is now ready to be accessed. Build and run the solution again. You will see something like below. Look at how the results have changed just by including those two lines in the InitializeService method.



 



 


One thing I would like you to note is the format of the data. In the above example, data is being returned as ATOM feeds.


 


Now that we have built a service, we next have to build a client to access this service. More of that in the next part. Happy Coding!!!