Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts,

we are trying to have our existing aSP.net website into Spanish also.
For this I created a class Language which inherits System.Web.UI.Page. (Because all the content pages are inhereited from
System.Web.UI.Page

So I created Language class inherits System.web.UI.Page and then changed my content page inherits Language class)

My Language Class has following code

VB.NET
Public Class Language
  Inherits System.Web.UI.Page
  Protected Overrides Sub InitializeCulture()
    Dim cookie As HttpCookie = Request.Cookies("Lang")
    Dim lang As String = String.Empty
    If cookie IsNot Nothing AndAlso cookie.Value IsNot Nothing Then
      lang = cookie.Value
    End If
    If Not lang.Contains("Select") Then

      Dim culLan As CultureInfo = CultureInfo.CreateSpecificCulture(lang)
      Thread.CurrentThread.CurrentUICulture = culLan
      Thread.CurrentThread.CurrentCulture = culLan
    End If
    MyBase.InitializeCulture()
  End Sub
End Class 


One of the Content page is like below
VB.NET
Partial Class Products
  Inherits Language


Now My variable lang in Language class has value es-MX - Spanish and there are no errors while debugging this. However my ASPX page is not changing from English to Spanish .

Could anyone please help me ?

This has to do langue switch dynamic only. I don't have static single html/aspx pages . So please correct me where is the mistake in this?

What I have tried:

So far I have first with google translator and then the code shown above. I cannot do with resource files because my website is really huge and Its hard to resource value for each string and all the products or items have different descriptions that comes from DB.
I am not sure if i am missing any step in between these ...
Posted
Updated 5-Aug-16 9:30am
v3
Comments
AnvilRanger 5-Aug-16 15:33pm    
And what are you using or plan on using as your translation source? You are just sitting the Culture setting for the UI. This will not automatically change the language of the page. You need a resource of some kind that says for eng-US here are my values and for es-MX here are the corresponding values.
sudevsu 5-Aug-16 16:17pm    
I am not aware of that. I was in misconception that setting a culture would change the page automatically. It would help me if you could tell me how to do that? For example my website has 100 content pages 70 user controls and nested master pages, it means I have to create every value in english and its corresponding spanish. Thats a lot of work. Is there any plugin that can do this without setting all the resource files? I tried google translator but I cannot get rid of the google tool bar that says Switch to Original / Translated to Spanish .

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