若是开发的语言想用多语言的话能够经过添加语言包的方式切换不一样的语言。app
1. 加载语言包ide
/// <summary> /// 语言包选择 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LangList_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { LoadLanguageFile("pack://application:,,,/CustomLanguage;component/Chinese.xaml"); LanguageChanged = false; UpdateLanguageHandler?.Invoke(); if (CurrentDevice?.DeviceProtocol != null) CurrentDevice.DeviceProtocol.UpdateDisplayItems(); UavProtocol protocol = CurrentDevice?.DeviceProtocol; m_frameGoogle.FreshLatLngJmpDes(); } catch (Exception ex) { LogHelper.ErrorLog(LogStr, ex); } } void LoadLanguageFile(string languagefileName) { Application.Current.Resources.MergedDictionaries[0] = new ResourceDictionary() { Source = new Uri(languagefileName, UriKind.RelativeOrAbsolute) }; }
2. 语言包的获取spa
strMsg = (string)FindResource("PUB_STR_IS_REMOVE_CURRENT_DEVICE");
3. 语言包的建立code
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib"> <s:String x:Key="WatchWord">智引将来,创新无限</s:String></ResourceDictionary>