?
Solved

asp.net globalization

Posted on 2011-05-03
7
Medium Priority
?
387 Views
Last Modified: 2012-05-11
Hi,

I can handle static data for globalization using resource files, how to handle dynamic data for globalization? The dynamic data means data is stored in database and I want to display it by pressing flag of country.

Any advise?
0
Comment
Question by:sindhuxyz
  • 3
  • 3
7 Comments
 
LVL 9

Expert Comment

by:sarabhai
ID: 35512571
The following code example shows an ASP.NET Web page that lets users select their preferred language from a drop-down list. The page imports two namespaces to make it more convenient to work with threading and globalization classes.

<%@ Page Language="VB" uiculture="auto" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
  1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">
    Protected Overrides Sub InitializeCulture()
        If Request.Form("ListBox1") IsNot Nothing Then
            Dim selectedLanguage As String = _
                Request.Form("ListBox1")
            UICulture = Request.Form("ListBox1")
            Culture = Request.Form("ListBox1")
            Thread.CurrentThread.CurrentCulture = _
                CultureInfo.CreateSpecificCulture(selectedLanguage)
            Thread.CurrentThread.CurrentUICulture = New _
                CultureInfo(selectedLanguage)
        End If
        MyBase.InitializeCulture()
    End Sub
</script>
<html>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ListBox ID="ListBox1" runat="server">
            <asp:ListItem Value="en-US"
                Selected="True">English</asp:ListItem>
            <asp:ListItem Value="es-MX">Español</asp:ListItem>
            <asp:ListItem Value="de-DE">Deutsch</asp:ListItem>
        </asp:ListBox><br />
        <asp:Button ID="Button1" runat="server"
            Text="Set Language"
            meta:resourcekey="Button1" />
        <br />
        <asp:Label ID="Label1" runat="server"
            Text=""
            meta:resourcekey="Label1" />
        </div>
    </form>
</body>
</html>
0
 
LVL 8

Expert Comment

by:edemcs
ID: 35512601
You can create a resource table in your database and associate each translated word with an ID, Value, and locale.  i.e.

ID          Value          Locale
1            Hello           en-US
1            Hola            es-US

So, when you query this table to get hello, you'd pass in ID: 1, Locale: en-US into a stored proc, that would return the value.

0
 
LVL 5

Author Comment

by:sindhuxyz
ID: 35512664
I am talking about dynamic data not static. Static can be stored in database or resource file for every different language; again it is dynamic data.

Thanks
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 8

Expert Comment

by:edemcs
ID: 35512684
Dynamic or static, you still need it to be translated, and to do so, you still need a dictionary.  Can you give an example?
0
 
LVL 5

Author Comment

by:sindhuxyz
ID: 35512800
If there is text box on website and one user place content in it. I want it displayed in multiple languages, now how to do it?
0
 
LVL 8

Accepted Solution

by:
edemcs earned 1000 total points
ID: 35512893
You have to translate that word against a dictionary.  You could look for APIs that exist out there that will help you do it on the fly.  I'm sure Google Translate or babel fish may have something for you.
0
 
LVL 5

Author Closing Comment

by:sindhuxyz
ID: 35974676
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question