页面添加
This commit is contained in:
29
Data/LanguageManager.cs
Normal file
29
Data/LanguageManager.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace 睡眠呼吸暂停治疗面罩多功能测试仪.Data
|
||||
{
|
||||
public static class LanguageManager
|
||||
{
|
||||
// 私有静态变量,只在首次访问时初始化一次
|
||||
private static readonly string _currentLanguage;
|
||||
|
||||
// 静态构造函数:程序启动时自动执行一次,读取配置
|
||||
static LanguageManager()
|
||||
{
|
||||
// 读取配置文件的Language值,没有的话默认zh-CN
|
||||
_currentLanguage = ConfigurationManager.AppSettings["Language"] ?? "zh-CN";
|
||||
}
|
||||
|
||||
// 对外只读的全局属性,项目任何地方都能直接调用
|
||||
public static string CurrentLanguage => _currentLanguage;
|
||||
|
||||
// 可选:给个更方便的判断属性,不用每次都写==判断
|
||||
public static bool IsEnglish => _currentLanguage == "en-US";
|
||||
public static bool IsChinese => _currentLanguage == "zh-CN";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user