locked
basic questions in asp.net localization RRS feed

  • Question

  • User-74084792 posted

    Hi All,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

        I am new to .net and not developed any localization application before. Now I am planning to start an application with globalization and localization. I wanted to clear my basic doubts in localization before starting. Please help me. These are my basic doubts.<o:p></o:p>

    1) asp.net is taking care of displaying date, number and sorting etc., depends on the culture info but what are the things need to be done in the back end (sql server 2000)?<o:p></o:p>

    2) while inputting numbers. one culture will write 2000 other culture will write 2,000 or 2.000 or 2 000. Now in sql server assume our datatype is int. whether the int data type will support to store the above mentioned different kind of numbers?

    3) I worked with resource file but I don’t know how to create a resource file for each screen with all the labels and pictures for that page.

    Any help would be appriciated.

     

    Friday, December 9, 2005 4:35 AM

All replies

  • User1416329745 posted
    The answer is no and no because you have to define your data types as Unicode in SQL Server Nchar, Nvarchar and Ntext and no INT can only be used for whole numbers if you need decimal places you use Decimal and Numeric.  These let you set precision and scale but the later takes more bytes.  Run a search for all of the above in SQL Server BOL (books online).  Hope this helps.
    Friday, December 9, 2005 8:27 AM
  • User-74084792 posted

    Hi Caddre,

       Thanks for your reply. I am still in a confusion. Are you trying to say that i can't use any datatype other then nchar, nvarchar and ntext. There may be N no of ways of presenting and inputting numeric data, date etc., in different cultures. If it is so then can't we take the advantages of other datatypes like int, decimal and datetime ?.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

     

    Friday, December 9, 2005 9:50 AM
  • User1416329745 posted

    You must use Nchar, Nvarchar and Ntext for text data and I think the numeric formatting is covered in strings and formatting under culture specific formatting.  Try the thread below for MSDN links.   Hope this helps.

    http://forums.asp.net/971595/ShowPost.aspx

    Friday, December 9, 2005 11:15 AM
  • User-74084792 posted

    Hi Caddre,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    <o:p> </o:p>

               Thanks once again. I am clear with your point that .Net will take care of presenting and formatting data based on the culture. My question is while user inputs a numeric he/she may present the numeric in N no of ways. Ex: 2000 or 2 000 or 2,000. I can't declare this as ntext, nvarchar or nchar because i know this is a numeric field.<o:p></o:p>

    <o:p> </o:p>

              One more example for this could be a date field. In India we used to input date in dd/mm/yyyy format. if i declare this also as a nvarchar ,ntext or nchar then I can't take the advantage of querying the database like this.<o:p></o:p>

    <o:p> </o:p>

          select * from order where orderdt >='01/01/2005' and orderdt <='01/01/2006'<o:p></o:p>

    <o:p> </o:p>

             can't we set some culture param in SQL server like our config file in dotnet so it can understand the numeric format for that culture?.

    <o:p></o:p> 

    Saturday, December 10, 2005 12:31 AM
  • User1416329745 posted


    Try the link below for SQL Server Datetime info and if you use NText, Nchar and Nvarchar there is a function in C# strings and formatting that handle that like the Datetime ToString method.  Hope this helps.

    http://www.sqljunkies.com/Article/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDateTimeClassToStringTopic4.asp

    Monday, December 12, 2005 11:28 AM
  • User1183903743 posted

    Your question is by far not basic. You are talking about localization of CONTENT not UI. Asp.net localization is intended for UI like labels, and button text etc. This is also data but NOT content and can be handled at the application level(asp.net) ususally in the form of xml(resx files). The data from the resx is compiled into the assembly so the resx is not used directly at runtime. Here is a tutorial on that. http://beta.asp.net/QUICKSTART/aspnet/doc/localization/localization.aspx You can put more data in the resx especially the Global ones and access is now much improved with static strongly typed syntax but do not abuse that. Use it for what it was intended resources for the UI.

    For your question neither one of the datatypes suggested by Caddre( NText, Nchar and Nvarchar ) are appropriate!

    Let's look at your example. Let's say we are counting the inventory of bottles of wine. There are no half bottles so int is perfect for that. Now the absolute value of our inventory is 2000 and that is what should be stored inthe db. I don't care if my customer is French or Chinese I only have 2000 bottles. So in this case LANGUAGE DOES NOT MATTER.

    HTTP stands for hyperTEXT... So all input is text and needs to be parsed even if not localized.

     '2,000', '2 000', '2.000', '2000', '٠٠٠٢' It can be Arabic-Indic but the value is still 2000. It is your responsibility to parse it properly and store the proper int value in the db.

    What we are talking about here is capturing input. Formatting issues are not just limited to localization. What if the user formats incorrectly? We have to take steps ahead of time to prevent that. There are all kinds of masking controls, client and server validation etc. so that the data is cleaned up BEFORE it reaches the db. There is a lot of help with that too in the Framework in the form of several formatting classes in the System.Globalization namespace.

    You do your sql queries, calculations etc using int. You display this data in asp.net using the .Net formatting classes based on the culture or based on custom masks you prefer. That was for datatypes like datetime, int, decimal etc. for which the variant STRING versions should be kept away from the db.

    However, there is data that really does vary. For example the name, or translated text. The versions ARE all different and should be stored in a foreign key table and the queries should include a culture parameter. The data type in the db should be nvarchar.
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_na-nop_9msy.asp

    This is not really localization any more it is TRANSLATION at the db level and needs little intervention by asp.net. All you need to do here is make sure the encoding is correct(use Unicode UTF8) which is the default anyway, and the page layout accomodates that. For example do notleave limited space for German, which has very long words. RTL layout etc. There are lots of other issues like sorting, collation etc that are beyond the level of this post.

    HTH!

    Tuesday, December 13, 2005 7:08 PM
  • User-74084792 posted

    Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    <o:p> </o:p>

         Thank you very much for your detailed post. Now I am very much clear that while receiving input from the user I have to parse the data then store it to db (i can use any int,datetime etc.. for strings only nvarchar) and while displaying the data I have to format the data based on the culture.

     

     

    Tuesday, December 13, 2005 11:49 PM
  • User-74084792 posted

    Hi

        Is there any functions available for parsing the data from a culture to it's normal form.

    for example

    parse (dd-mm-yyy) should return mm/dd/yyyy

              2 000 should return 2000

     

     

    Tuesday, December 13, 2005 11:56 PM
  • User1183903743 posted

    All the basic valuetype objects have a static Parse method:

    int.Parse(...), decimal.Parse(...), double.Parse(...), DateTime.Parse(...), DateTime.ParseExact(...),

    especially the overload that take IFormatProvider. The CultureInfo implements IFormatProvider. 

    http://msdn.microsoft.com/en-us/library/kc8s65zs(en-US,VS.80).aspx

    They are all prone to exceptions so look at the TryParse(...) overload. Also look at the Convert class.

    I use clientside and serverside validation to make sure the input is parsable or I DONT ACCEPT IT!

    Actually for datetine I don't even use a textbox. I use Calendar datepicker controls. Everyhere I can, I use dropdown controls with  PRESET values.

    Ensuring data integrity at the time of input is a huge topic. It can take as much as half of your code. See these products:

    http://peterblum.com/Home.aspx
    http://intersoftpt.com/WebInput/
    http://telerik.com/Default.aspx?PageId=2601

    HTH!

     

    Wednesday, December 14, 2005 6:07 AM
  • User-74084792 posted

    Hi

       At the last i got how to localize an application in asp.net. I am planning to create database in SQL server 2000 with a dateformat (default) of mm/dd/yyyy. Then i will parse the user input (which ever way he/she enters the date) to en-US and store it to the database. for displaying it to the report i will retrieve this mm/dd/yyyy format and i will format it to the current culture. I am planning to do the same thing for numbers and currency.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

      Is it the right way of doing this or any other best practices are there to configure something in the back end.<o:p></o:p>

        Is there any code samples or article available for localization with database application from Microsoft or any other vendor.

    <o:p></o:p> 

     

    Saturday, December 17, 2005 12:57 AM
  • User1183903743 posted

    sounds good. So far you are not doing anything localized at the db level so go right ahead as usual.

    good luck

    Saturday, December 17, 2005 12:31 PM
  • User1416329745 posted

    Try the links below the first is a three part article and the second is old Mirocosft provided Localization tool kit.  Hope this helps.

    http://openmymind.net/index.aspx?documentId=52

    http://www.microsoft.com/downloads/details.aspx?FamilyID=6b6fb09f-f25c-48e9-9e26-b55144600da1&DisplayLang=en

    Monday, December 19, 2005 3:08 PM
  • User-74084792 posted

    Thanks caddre

    Tuesday, December 20, 2005 11:45 AM
  • User1416329745 posted
    I am glad I could help and I apologise for misunderstanding your needs during the first part of the thread.
    Tuesday, December 20, 2005 3:19 PM
  • User-74084792 posted

    Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

            I designed an asp.net application in 5 different languages. Each language has it's own  localization content. I am very much clear with localization of content.<o:p></o:p>

        This applications culture will be taken from web.config not from browser request. So the user will be from any of the 5 languages but he can't switch between languages.<o:p></o:p>

        In the back end I am not doing any settings it's just a default installation of sql server.<o:p></o:p>

        Now the problem i am facing is. I know the user input will be in one of the 5 language. I want all the user inputs to be converted to English so that I can validate the user input in English and i can update the same to db.<o:p></o:p>

        I am converting the user input to English since I don't know how to validate numbers and dates in these 5 languages. Even if i know that, then I have to write 5 different validation routines for each language.

    Wednesday, January 18, 2006 8:30 AM