scalf Posted June 16, 2004 Posted June 16, 2004 (edited) Hello, I'm still trying to setup my multilinguage display in my webform and after having solved my problem of resource file compilation I'm expreriencing a new problem : I created two resource files : one is named "strings.fr-FR.resx" for french culture and the other is named "strings.en-US.resx" for english culture. I put in the two files differente labels in french and english and I initialised my webform with the code below : Public rm As ResourceManager Public ciFR As New CultureInfo("fr-FR") Public ciEN As New CultureInfo("en-US") Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Session("language") = "English" Then Thread.CurrentThread.CurrentCulture = ciEN Else Thread.CurrentThread.CurrentCulture = ciFR End If rm = New ResourceManager("Auditeurs_user.strings", Me.GetType.Assembly.GetExecutingAssembly) If Not Page.IsPostBack Then initpage() End If End Sub My problem is that anything I do, it's always the french culture which is chosen and my web page always displays the same french labels. If someone has an idea about how to switch from one culture to another. PS : the Session("language") = "English" is initialized when I click on an English flag button and the string value "English" is saved in a session varaible. Merci Beaucoup !!! Edited June 16, 2004 by scalf Quote Scalf. Do not want others to know what you have done? Better not have done it anyways.
Moderators Robby Posted June 16, 2004 Moderators Posted June 16, 2004 I would use a helper function such as the following... PublicFunction GetLangString(ByVal name AsString) AsString Dim info As CultureInfo = New CultureInfo(culture_string) Return rm.GetString(name, info) EndFunction Call the mthod with something like this.... homeTextbox.Text = GetLangString("myHomeMessage") and set the 'culture_string' when you instantiate the class or with the value of your Session("Language") variable ("en-US) Quote Visit...Bassic Software
*Experts* DiverDan Posted June 17, 2004 *Experts* Posted June 17, 2004 You might also give this a try... If Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName = "en" Then MessageBox.Show("English") ElseIf Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName = "fr" Then MessageBox.Show("French") End If or If Thread.CurrentThread.CurrentCulture.DisplayName = "English" Then MessageBox.Show("English") ElseIf Thread.CurrentThread.CurrentCulture.DisplayName = "France" Then MessageBox.Show("France") End If Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
scalf Posted June 17, 2004 Author Posted June 17, 2004 Many Thanks, I didn't try the different solutions you gave me. I just added the following line code : Thread.CurrentThread.CurrentUICulture = ciFR in the condition where the french flag is clicked and Thread.CurrentThread.CurrentUICulture = ciEN in the condition where the english flag is clicked NB: ciFR is declared as Public CultureInfo("fr-FR") ciEN is declared as Public CultureInfo("en-US") I'll write down the different solutions you gave me, it may help. Thanks for all. Quote Scalf. Do not want others to know what you have done? Better not have done it anyways.
Moderators Robby Posted June 17, 2004 Moderators Posted June 17, 2004 Another thing, instead of always checking on which laguage to display anything simply change the entire thread to follow the desired culture... Thread.CurrentThread.CurrentCulture = New CultureInfo(YourCultureString) Quote Visit...Bassic Software
scalf Posted June 17, 2004 Author Posted June 17, 2004 Thanks Robby, this is an interesting trick ;) , It works fine ! and that's what I did in my PageLoad. Quote Scalf. Do not want others to know what you have done? Better not have done it anyways.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.