SetDefaultLanguage() публичный Метод

Sets the default language. This language will be loaded in Awake() if it exists By default this is set to = "en"
public SetDefaultLanguage ( CultureInfo, languageInfo ) : void
languageInfo CultureInfo,
Результат void
Пример #1
0
        public BaseController(IServiceProvider serviceProvider, IHostingEnvironment hostingEnvironment)
        {
            _locker = new object();
            _languageReceiveAdapter = serviceProvider.GetService <ILanguageReceiveAdapter>();

            _hostingEnvironment = hostingEnvironment;
            // 在这里,我默认语言文件为{语言标识符}.mo,如en-US.mo,依此类推
            _contentRootPath = _hostingEnvironment.WebRootPath + @"\mofile";
            _languageManager = _languageReceiveAdapter.GetLanguageManager();

            // 检测语言管理器是否初始化
            if (_languageManager == null)
            {
                lock (_locker)
                {
                    if (_languageManager == null)
                    {
                        List <SingleLanguage> singleLanguages = CreateSingleLanguageList(_contentRootPath);
                        _languageReceiveAdapter.InitLanguageManager(singleLanguages);

                        _languageManager = _languageReceiveAdapter.GetLanguageManager();
                        _languageManager.SetDefaultLanguage("zh-CN");
                    }
                }
            }

            _currentLanguage = _languageManager.DefaultLanguage;
        }
Пример #2
0
    void Start()
    {
        langManager = LanguageManager.Instance;

        string systemLang = langManager.GetSystemLanguage();
        if(langManager.IsLanguageSupported(systemLang))
            langManager.SetDefaultLanguage(systemLang);
    }