Globalization application
Vipul given good example Here
Now we need to modified little bit code because of next time onwards application will be open last time selected language.
Just we need to store selected language in Isolated storage file like below :-
Vipul given good example Here
Now we need to modified little bit code because of next time onwards application will be open last time selected language.
Just we need to store selected language in Isolated storage file like below :-
Make sure your Page has these name spaces
using System.Globalization;
using System.Threading;
using System.IO.IsolatedStorage;
private IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
// Constructor
public MainPage()
{
if (appSettings != null && appSettings.Count >0)
{
ApplyCulture(new CultureInfo((string)appSettings["lan"]));
}
InitializeComponent();
}
// this above condition is next time onwards just check the isolated storage memory if it has any language then it will open last time selected language.
private void radioButtonenUS_Checked(object sender, RoutedEventArgs e) { ApplyCulture(new CultureInfo("en-US"));
appSettings["lan"] = "en-US"; }
here we save the Selected language in Isolated storage memory . private void radiobuttonfrFR_Checked(object sender, RoutedEventArgs e) { ApplyCulture(new CultureInfo("fr-FR"));
appSettings["lan"] = "fr-FR"; }
private void ApplyCulture(CultureInfo cul) { Thread.CurrentThread.CurrentCulture = cul; Thread.CurrentThread.CurrentUICulture = cul; DateTime current = DateTime.Now; textBoxLongDate.Text = current.ToString("D"); textBoxShortDate.Text = current.ToString("d"); textBoxTime.Text = current.ToString("T"); textBoxCurrency.Text = 100.ToString("C"); textBlockLongDate.Text = AppResources.TextLabelLongDate; textBlockShortDate.Text = AppResources.TextLabelShortDate; textBlockTime.Text = AppResources.TextLabelTime; textBlockCurrency.Text = AppResources.TextLabelCurrency; textBlockUser.Text = AppResources.UserName; textBlockHello.Text = AppResources.Salutation; }//if we don't write the above method your current page doesn't convert to selected language this is for immediate effect for current page.
No comments:
Post a Comment