Пример #1
0
        protected override async Task OnParametersSetAsync()
        {
            var cultureCode = await LocalStorage.GetItemAsync <string>("bartvanhoey_culturecode") ?? "en-US";

            SelectedLanguage = string.IsNullOrWhiteSpace(cultureCode) ? "English" : GetDisplayLanguageFromCultureCode(cultureCode);
            LanguageContainer.SetLanguage(CultureInfo.GetCultureInfo(cultureCode));
        }
Пример #2
0
        protected async Task ChangeLanguageAsync(string cultureCode)
        {
            SelectedLanguage = GetDisplayLanguageFromCultureCode(cultureCode);
            await LocalStorage.SetItemAsync("altandenter_culturecode", cultureCode);

            LanguageContainer.SetLanguage(CultureInfo.GetCultureInfo(cultureCode));
            NavigationManager.NavigateTo(NavigationManager.Uri, true);
        }
Пример #3
0
        protected async Task ChangeLanguageAsync(string cultureCode)
        {
            var navigationManagerUri = NavigationManager.Uri;

            SelectedLanguage = GetDisplayLanguageFromCultureCode(cultureCode);
            await LocalStorage.SetItemAsync("bartvanhoey_culturecode", cultureCode);

            LanguageContainer.SetLanguage(CultureInfo.GetCultureInfo(cultureCode));
            NavigationManager.NavigateTo(navigationManagerUri, true);
        }
 public LanguageConfigViewModel(
     LanguageContainer languageContainer,
     ICoreTranslations coreTranslations,
     IDemoConfiguration demoConfiguration,
     IEventAggregator eventAggregator)
 {
     _languageContainer = languageContainer;
     _eventAggregator   = eventAggregator;
     DemoConfiguration  = demoConfiguration;
     CoreTranslations   = coreTranslations;
 }
Пример #5
0
        private async Task <LanguageContainer> CreateContainer(ILanguage language)
        {
            var languageConfig = LanguageConfigBuilder.Create()
                                 .WithApplicationName("Dapplo")
                                 .WithSpecificDirectories(@"LanguageTests\LanguageTestFiles")
                                 .BuildLanguageConfig();

            var result = new LanguageContainer(languageConfig, new[] { language });
            await result.ReloadAsync().ConfigureAwait(false);

            result.CorrectMissingTranslations();
            return(result);
        }
Пример #6
0
 /// <summary>
 /// Loads the laguage of the given language code if availible.
 /// Language codes adhere to the ISO 639-1 standard for language codes.
 /// </summary>
 /// <param name="languageCode">The code of the language in compliance with ISO 639-1</param>
 public void LoadLanguage(string languageCode)
 {
     if (_AvailibleLanguages.Contains(languageCode))
     {
         _CurrentLanguage = XML_to_Class.LoadClassFromXML <LanguageContainer>("\\StreamingAssets\\Languages\\" + languageCode + ".xml");
         LanguageLoaded   = languageCode;
         if (LanguageChangedEvent != null) //could be nothing is registered
         {
             LanguageChangedEvent.Invoke();
         }
     }
     else
     {
         Debug.LogWarning("LanguageController | LoadLanguage | Attempted to load a language that is not available.");
     }
 }
Пример #7
0
        public override PipelineProcessorResponseValue ProcessRequest()
        {
            if (RequestContext.Item == null)
            {
                return(new PipelineProcessorResponseValue
                {
                    AbortMessage = Translate.Text("The target item could not be found.")
                });
            }

            var languageVersions = LanguageContainer.GetLanguageVersions(RequestContext.Item);

            return(new PipelineProcessorResponseValue
            {
                Value = languageVersions
            });
        }
Пример #8
0
    private void Awake()
    {
        persistantHandler = GameObject.FindGameObjectsWithTag("PersistentObject")[0];
        //persistantHandler.GetComponent<InputHandler>().addObserver(this);
        this.gameObject.GetComponent <UIFader>().FadeIn(0.3f);
        Invoke("StopTime", 0.4f);
        //RefreshBubbles();

        LanguageFileInfo languageSave = SaveSystem.LoadLanguage();

        if (languageSave == null)
        {
            languageSave = new LanguageFileInfo();
        }
        Debug.Log("language chargé : " + languageSave.chosenLanguage.name);

        //We load all the possible languages
        string loadedJsonFile = Resources.Load <TextAsset>("languages").text;

        allLanguages = JsonUtility.FromJson <LanguageContainer>(loadedJsonFile);
        //When we get to the one with te right code, we keep the index to be able to access the info easily
        for (int i = 0; i < allLanguages.languages.Length; i++)
        {
            Debug.Log(allLanguages.languages[i].code);
            if (allLanguages.languages[i].code == languageSave.chosenLanguage.name)
            {
                Debug.Log("This is the right language");
                language = i;
                //We store in an environment variable the adress of the right dialogues
                languageSave.chosenLanguage.name = allLanguages.languages[i].adress;

                ActualLanguage.actualLanguage = languageSave.Clone();
            }
        }

        //We then fill our dropdown with every language
        dropDown.options.Clear();
        for (int i = 0; i < allLanguages.languages.Length; i++)
        {
            dropDown.options.Add(allLanguages.languages[i].name);
        }


        HandleSelect();
    }
Пример #9
0
        public ExternalFileKeysProviderTests()
        {
            //*************************************************************************************************
            // For UWP apps the resources can be Embedded or placed in externals files - either in the app's
            // installation directory or the in a subfolder of the app's LocalFolder.
            //
            // Unremark the code below to test the scenarios'.  Note that when you use the LocalFolder option
            // you will need to manually create a folder under the app's LocalFolder location and copy all of
            // language resource files, prior to running the app.  In this case the app will be installed
            // in this location:
            //     C:\Users\<your user>\AppData\Local\Packages\aaab2d02-8d02-4b44-b948-1d2c8fa9138a_3xecenf62363c\LocalState.
            //
            //*************************************************************************************************
            //var keysProvider = new ExternalFileKeysProvider(Assembly.GetExecutingAssembly(), "Resources", LocalizationFolderType.InstallationFolder);
            var keysProvider = new ExternalFileKeysProvider(Assembly.GetExecutingAssembly(), "Localization", LocalizationFolderType.LocalFolder);

            _service = new LanguageContainer(CultureInfo.GetCultureInfo("ca-ES"), keysProvider);
        }
Пример #10
0
    //Called by Central
    public void LoadLanguage(string languageCode)
    {
        string path = "Languages/" + languageCode + ".xml";

        if (!BetterStreamingAssets.FileExists(path))
        {
            Debug.LogErrorFormat("Streaming asset not found: {0}", path);
        }
        else
        {
            using (var stream = BetterStreamingAssets.OpenRead(path))
            {
                var serializer = new System.Xml.Serialization.XmlSerializer(typeof(LanguageContainer));
                LoadedLanguage = (LanguageContainer)serializer.Deserialize(stream);
            }
            OnNewLanguageLoaded.Invoke();
        }
    }
Пример #11
0
        public ConfigViewModel(
            LanguageContainer languageContainer,
            IEnumerable <Lazy <IConfigScreen> > configScreens,
            IDemoConfigTranslations configTranslations,
            ICoreTranslations coreTranslations,
            IDemoConfiguration demoConfiguration)
        {
            ConfigScreens      = configScreens;
            ConfigTranslations = configTranslations;
            CoreTranslations   = coreTranslations;

            // automatically update the DisplayName
            CoreTranslations.CreateDisplayNameBinding(this, nameof(ICoreTranslations.Settings));

            // Set the current language (this should update all registered OnPropertyChanged anyway, so it can run in the background
            var lang = demoConfiguration.Language;

            Task.Run(async() => await languageContainer.ChangeLanguageAsync(lang).ConfigureAwait(false));
        }
Пример #12
0
    private void Awake()
    {
        BetterStreamingAssets.Initialize();

        Instance = this;
        //Inventorize availible laguages and make them availible
        foreach (string s in BetterStreamingAssets.GetFiles("Languages", "*.xml", SearchOption.AllDirectories))
        {
            AvailableLanguages.Add(s.Split('.')[0].Split('/')[1]);
        }
        //load english, if not availible load first langauge found
        if (LoadedLanguage == null)
        {
            if (AvailableLanguages.Contains("en"))
            {
                LoadLanguage("en");
            }
            else
            {
                LoadedLanguage = new LanguageContainer();
            }
        }
    }
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="languageContainer">LanguageContainer</param>
 public LanguageService(LanguageContainer languageContainer)
 {
     _languageContainer = languageContainer;
 }
Пример #14
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            try
            {
                //处理未捕获的异常 Add by ChengSk - 20180809
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                //处理  UI线程异常 Add by ChengSk - 20180809
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                //处理非UI线程异常 Add by ChengSk - 20180809
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandleException);

                // nLength = Marshal.SizeOf(typeof(stWeightBaseInfo));
#if REALEASE
                GlobalDataInterface.CreatErorrFile();
#endif

                // int nLength = Marshal.SizeOf(typeof(stGlobal));

                //语言选择功能
                GlobalDataInterface.selectLanguage = Common.Commonfunction.GetAppSetting("选择的语言");

                //string path; //Add by xcw - 20191031
                //string currentPath = System.AppDomain.CurrentDomain.BaseDirectory;
                //PrintProtocol.logoPathName = currentPath + PrintProtocol.logoPathName;  //更改LOGO标签地址(相对地址转绝对地址)
                //string currentDefaultPath = currentPath + "config\\";
                //path = currentDefaultPath + "languagekind.txt"; //Add by xcw - 20191031
                //if (!Directory.Exists(currentDefaultPath))
                //{
                //    Directory.CreateDirectory(currentDefaultPath);
                //}

                //if (!File.Exists(path))
                //{
                //    FileStream fs = File.Create(path);
                //    fs.Close();
                //}


                //StreamReader sr = new StreamReader(path, Encoding.Default);
                //string m = sr.ReadToEnd();//显示内容
                //m = m.Replace("\r\n", ""); //Add by xcw - 20191031
                //sr.Close();
                //GlobalDataInterface.selectLanguage = m;
                //MessageBox.Show(GlobalDataInterface.selectLanguage);
                if (GlobalDataInterface.selectLanguage == "" || GlobalDataInterface.selectLanguage == "null")
                //if (true)
                {
                    LanguageSelectForm languageSelectForm = new LanguageSelectForm();
                    languageSelectForm.ShowDialog();
                }
                Thread.CurrentThread.CurrentUICulture   = new System.Globalization.CultureInfo(GlobalDataInterface.selectLanguage);
                GlobalDataInterface.selectLanguageIndex = LanguageContainer.LanguageVersionIndex(GlobalDataInterface.selectLanguage);

                //信息提示框按钮附名称
                //MessageBoxManager.OK = "OK";
                //MessageBoxManager.No = "No";
                //MessageBoxManager.Yes = "Yes";
                //MessageBoxManager.Cancel = "Cancel";
                //MessageBoxManager.Retry = "Retry";
                //MessageBoxManager.Ignore = "Ignore";
                //MessageBoxManager.Abort = "Abort";
                //MessageBoxManager.Register();
                MessageBoxManager.OK     = LanguageContainer.ProgramMessageBoxManagerOK[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.No     = LanguageContainer.ProgramMessageBoxManagerNo[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Yes    = LanguageContainer.ProgramMessageBoxManagerYes[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Cancel = LanguageContainer.ProgramMessageBoxManagerCancel[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Retry  = LanguageContainer.ProgramMessageBoxManagerRetry[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Ignore = LanguageContainer.ProgramMessageBoxManagerIgnore[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Abort  = LanguageContainer.ProgramMessageBoxManagerAbort[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Register();

                ////显示启动界面线程
                Thread thSplash = new Thread(new ThreadStart(ShowSplashForm));
                thSplash.Priority     = ThreadPriority.Normal;
                thSplash.IsBackground = true;
                thSplash.Start();
                //初始化系统线程
                Thread thInitialSysterm = new Thread(new ThreadStart(InitialSysterm));
                thInitialSysterm.Priority     = ThreadPriority.Highest;
                thInitialSysterm.IsBackground = true;
                thInitialSysterm.Start();
                thInitialSysterm.Join();

                if (m_splashForm != null)
                {
                    m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.Close(); }));
                }
                thSplash.Join();

                //模拟测试广播通信代码 正常工作时注释掉
                Thread thSendBroadcast = new Thread(new ThreadStart(sendBroadcast));
                thSendBroadcast.IsBackground = true;
                thSendBroadcast.Start();

                if (IsSystemContinue)
                {
                    ////语言选择功能
                    //GlobalDataInterface.selectLanguage = Common.Commonfunction.GetAppSetting("选择的语言"); //Note by ChengSk - 20180723 代码放到网络连接之前
                    //if (GlobalDataInterface.selectLanguage == "null")
                    //{
                    //    LanguageSelectForm languageSelectForm = new LanguageSelectForm();
                    //    languageSelectForm.ShowDialog();
                    //}
                    //Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(GlobalDataInterface.selectLanguage);
                    //GlobalDataInterface.selectLanguageIndex = LanguageContainer.LanguageVersionIndex(GlobalDataInterface.selectLanguage);

                    //数据库配置功能  Add by ChengSk 20140320  ---START---
                    GlobalDataInterface.currentDatabase = Common.Commonfunction.GetAppSetting("当前数据库");
                    GlobalDataInterface.dataBaseConn    = "data source=" + Common.Commonfunction.GetAppSetting("数据源") +
                                                          ";database=" + Common.Commonfunction.GetAppSetting("数据库") +
                                                          ";user="******"用户名") +
                                                          ";pwd=" + Common.Commonfunction.GetAppSetting("密码");
                    bool          isConnSuccess = false;
                    SqlConnection conn          = new SqlConnection(GlobalDataInterface.dataBaseConn);
                    try
                    {
                        conn.Open();
                        isConnSuccess = true;
                        conn.Close();   //Add 20180919
                        conn.Dispose(); //Add 20180919
                    }
                    catch (Exception ex)
                    {
                        isConnSuccess = false;
                    }
                    if (GlobalDataInterface.currentDatabase == "null" || !isConnSuccess)
                    {
                        DatabaseSetForm databaseSetForm = new DatabaseSetForm();
                        databaseSetForm.ShowDialog();
                        if (GlobalDataInterface.DatabaseSet)
                        {
                            return;
                        }
                    }
                    GlobalDataInterface.databaseOperation = new DB.DataBaseOperation();
                    // ---END-- -


                    GlobalDataInterface.mainform = new MainForm();
                    Application.Run(GlobalDataInterface.mainform);
                }

                global.DestroyTCPServerMarsterSocket(); //Add by ChengSk - 20180723
#if REALEASE
                System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
                int handleCount = p.HandleCount;  //程序的句柄数     Add by ChengSk - 20180906
                GlobalDataInterface.WriteErrorInfo("程序即将退出...,当前句柄数量:" + handleCount.ToString());
                GlobalDataInterface.CloseErorrFile();
#endif
                Application.ThreadException -= new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                AppDomain.CurrentDomain.UnhandledException -= new UnhandledExceptionEventHandler(CurrentDomain_UnhandleException);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Program中函数Main出错:" + ex + "\n代码定位:" + ex.StackTrace);
#if REALEASE
                System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
                int handleCount = p.HandleCount;  //程序的句柄数     Add by ChengSk - 20180906
                GlobalDataInterface.WriteErrorInfo("程序即将退出...,当前句柄数量:" + handleCount.ToString());
                GlobalDataInterface.WriteErrorInfo(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "Program中函数Main出错:" + ex + "\n代码定位:" + ex.StackTrace);
#endif
            }
        }
        public EmbeddedResourceKeysProviderTests()
        {
            var keysProvider = new EmbeddedResourceKeysProvider(Assembly.GetExecutingAssembly(), "Resources");

            _service = new LanguageContainer(CultureInfo.GetCultureInfo("ca-ES"), keysProvider);
        }