Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();

            #region Binding button to the localiztion system
            // Creating GUI content.
            var content = new GUIContent()
            {
                // Adding the title that will displayed in case if localization key not found via loaded.
                DefaultTitle = "Native title",

                // Adding the key that will be looking into the loaded dictionaries.
                TitleLocalizationResourseKey = "localizedLabelCustomKey"
            };

            // Binding the content to the button's label.
            content.BindToLabel(localizedButton);
            #endregion

            #region Loading localization dictionaries
            LocalizationHandler.LoadDictionaries(
                // Getting local lang folder from the source project.
                langDictsPath,
                // Request english localization as prior.
                new CultureInfo("en-US"),
                // Request russian localization as secondary in case if english not found.
                new CultureInfo("ru-RU"));
            #endregion

            // Subscribing on the event of the language change.
            langPanel.ValueChanged += LangPanel_ValueChanged;
        }
        public override void OnLoaded()
        {
            LocalizationHandler.LoadDictionaries(
                // Getting local lang folder from the source project.
                langDictsPath,
                // Request english localization as prior.
                new CultureInfo("en-US"),
                // Request russian localization as secondary in case if english not found.
                new CultureInfo("ru-RU"));


            // Subdcribing on lang value update.
            GetField("lang").ValueChanged += OnLanguageChanged;
        }
        /// <summary>
        /// Occurs when language changed.
        /// </summary>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        private void OnLanguageChanged(IGUIField arg1, object[] arg2)
        {
            switch (lang)
            {
            case LangOptions.En:
                LocalizationHandler.LoadDictionaries(
                    langDictsPath,
                    new CultureInfo("en-US"));
                break;

            case LangOptions.Ru:
                LocalizationHandler.LoadDictionaries(
                    langDictsPath,
                    new CultureInfo("ru-RU"));
                break;
            }
        }
Exemple #4
0
        /// <summary>
        /// Occurs when user decide to change the current app's language.
        /// </summary>
        /// <param name="obj"></param>
        private void LangPanel_ValueChanged(IGUIField obj, object[] args)
        {
            var togglePanel = obj as FlatTogglesGroup;

            switch (togglePanel.Index)
            {
            case 0:
                LocalizationHandler.LoadDictionaries(langDictsPath, new CultureInfo("en-US"));
                break;

            case 1:
                LocalizationHandler.LoadDictionaries(langDictsPath, new CultureInfo("ru-RU"));
                break;

            default:
                LocalizationHandler.UnloadDictionaries();
                break;
            }

            // Buferizing current index.
            LangIndex = togglePanel.Index;
        }