Пример #1
0
 public string getLangString(int stringId, int languageIndex)
 {
     this.temp_strArr = LocaleManager.getInstance().getSupportedLocales();
     this.temp_str    = this.temp_strArr[languageIndex];
     this.temp_str2   = LocaleManager.getString(stringId, this.temp_str);
     return(this.temp_str2);
 }
Пример #2
0
        private void CheckedLanguageCommandExecute(object e)
        {
            var commandParam = (string)((e as EkushApp.ShellService.Commands.EventToCommandArgs).CommandParameter);

            LocaleManager.SetCurrentLanguage(commandParam);
            RegistryUtility.WriteRegistryKey(Globals.RegistryConstants.KEY_PATH, Globals.RegistryConstants.LOCALE_KEY_NAME, commandParam);
        }
Пример #3
0
    public void Awake()
    {
        DontDestroyOnLoad(gameObject);
        m_Instance = this;

        FillDictionary();
    }
Пример #4
0
 private void UpdateTextTitleStatus()
 {
     if (TextTitleStatus != null && SliderLoader != null)
     {
         if (SliderLoader.value >= 0 && SliderLoader.value < 15)
         {
             TextTitleStatus.text = LocaleManager.Inst().TranslateStr("PRELOAD_SCREEN_GAME1");
         }
         else if (SliderLoader.value >= 15 && SliderLoader.value < 30)
         {
             TextTitleStatus.text = LocaleManager.Inst().TranslateStr("PRELOAD_SCREEN_GAME2");
         }
         else if (SliderLoader.value >= 30 && SliderLoader.value < 45)
         {
             TextTitleStatus.text = LocaleManager.Inst().TranslateStr("PRELOAD_SCREEN_GAME3");
         }
         else if (SliderLoader.value >= 45 && SliderLoader.value < 60)
         {
             TextTitleStatus.text = LocaleManager.Inst().TranslateStr("PRELOAD_SCREEN_GAME4");
         }
         else if (SliderLoader.value >= 60 && SliderLoader.value < 75)
         {
             TextTitleStatus.text = LocaleManager.Inst().TranslateStr("PRELOAD_SCREEN_GAME5");
         }
         else if (SliderLoader.value >= 75)
         {
             TextTitleStatus.text = LocaleManager.Inst().TranslateStr("PRELOAD_SCREEN_GAME6");
         }
     }
 }
Пример #5
0
        private static void AddLanguageList(UIHelper group)
        {
            var locales  = GetSupportLanguages().ToArray();
            var dropDown = (group.self as UIComponent).AddUIComponent <LanguageDropDown>();

            dropDown.AddItem(string.Empty, Localize.Mod_LocaleGame);

            foreach (var locale in locales)
            {
                var localizeString = $"Mod_Locale_{locale}";
                var localeText     = Localize.ResourceManager.GetString(localizeString, Localize.Culture);
                if (Localize.Culture.Name.ToLower() != locale)
                {
                    localeText += $" ({Localize.ResourceManager.GetString(localizeString, new CultureInfo(locale))})";
                }

                dropDown.AddItem(locale, localeText);
            }

            dropDown.SelectedObject = Locale.value;

            dropDown.eventSelectedIndexChanged += IndexChanged;

            void IndexChanged(UIComponent component, int value)
            {
                var locale = dropDown.SelectedObject;

                Locale.value = locale;
                Mod.Instance.LocaleChanged();
                LocaleManager.ForceReload();
            }
        }
Пример #6
0
        public static void RemoveRange(this LocaleManager localeManager, Locale.Key id)
        {
            var locale = localeManager.GetLocale();

            // Set index to 0 so we can check for the string count
            id.m_Index = 0;

            if (!locale.Exists(id))
            {
                Log._Debug($"[{nameof(LocaleManagerExtensions)}.{nameof(RemoveRange)}] Could not remove locale range {id}; localized string {id} does not exist!");

                return;
            }

            var localizedStrings      = locale.GetLocalizedStrings();
            var localizedStringsCount = locale.GetLocalizedStringsCount();

            for (int index = 0, lastIndex = locale.CountUnchecked(id); index <= lastIndex; index++, id.m_Index = index)
            {
                localizedStrings.Remove(id);
                localizedStringsCount.Remove(id);
            }

            Log._Debug($"[{nameof(LocaleManagerExtensions)}.{nameof(RemoveRange)}] Removed locale range {id.m_Identifier}[{id.m_Key}].");
        }
Пример #7
0
        public void GetLocales()
        {
            List <WebLocale> locales;

            locales = LocaleManager.GetLocales(GetContext());
            Assert.IsTrue(locales.IsNotEmpty());
        }
Пример #8
0
        /// <summary>
        /// Disposes the GUIManager.
        /// </summary>
        /// <param name="disposing">Whether Dispose has been called.</param>
        protected virtual void Dispose(bool disposing)
        {
            this.InputManager  = null;
            this.LocaleManager = null;

            this.ReleaseFocusedAndGrabbedControl();
            this.lastMouseClickControl = null;
            this.lastMouseDownControl  = null;

            if (this.CurrentToolTip != null)
            {
                this.CurrentToolTip.Dispose();
                this.CurrentToolTip = null;
            }

            this.DisposeAllGUIs();

            if (this.Cursor != null)
            {
                this.Cursor.Dispose();
                this.Cursor = null;
            }

            this.Disposing = null;
        }
Пример #9
0
        protected bool TryGetLocalizedText(out string p_localizedValue)
        {
            bool v_sucess = false;

            if ((!string.IsNullOrEmpty(m_key) || m_autoTrackKey) && LocaleManager.InstanceExists())
            {
                // If no localization key has been specified, use the label's/Input's text as the key
                if (m_autoTrackKey && string.IsNullOrEmpty(_language) && string.IsNullOrEmpty(m_key))
                {
                    m_key = Text;
                }

                // If we still don't have a key, leave the value as blank
                if (string.IsNullOrEmpty(m_key))
                {
                    p_localizedValue = "";
                }
                else
                {
                    v_sucess = LocaleManager.TryGetLocalizedText(m_key, out p_localizedValue, m_supportLocaleRichTextTags);
                }

                //Return Key value if localization is empty
                if (!v_sucess)
                {
                    p_localizedValue = m_key;
                }
            }
            else
            {
                p_localizedValue = m_key != null? m_key : "";
            }

            return(v_sucess);
        }
Пример #10
0
 public void SetLanguage(int value)
 {
     LanguageLoader.LoadInternalLanguages(LocaleManager.instance);
     LanguageLoader.LoadExternalLanguages(LocaleManager.instance);
     LocaleManager.instance.PrepareInit += AfterLangChange;
     LocaleManager.SelectLocale(false);
 }
    public void ChangeTextDescriptionLevel()
    {
        string descriptText = null;

        switch (toggleGame.idToggle)
        {
        case "easy":
            descriptText = "DESCRIPT_EASY";
            break;

        case "middle":
            descriptText = "DESCRIPT_MIDDLE";
            break;

        case "hard":
            descriptText = "DESCRIPT_HARD";
            break;

        case "extreme":
            descriptText = "DESCRIPT_EXTREME";
            break;
        }
        string[] values = { "3" };
        descriptionLevel.text = LocaleManager.GetInstance().TranslateStr(descriptText) + "\n\n" + LocaleManager.GetInstance().TranslateStr("DESCRIPT_BASE", values);
    }
Пример #12
0
        protected override void Apply()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            if (LocaleManager.InstanceExists())
            {
                UnregisterEvents();

                string v_localizedValue;
                if (TryGetLocalizedText(out v_localizedValue))
                {
                    Text = v_localizedValue;
                }

                _language = LocaleManager.Instance.CurrentLanguage;

                if (enabled && gameObject.activeInHierarchy)
                {
                    RegisterEvents();
                }
            }

            _lastLocalizedValue = Text;
        }
Пример #13
0
        private LoadFolderResult OpenFolder(string localeFolder)
        {
            _localeManager = new LocaleManager
            {
                LocaleRoot = localeFolder
            };
            _localeManager.LoadLocales();

            if (_localeManager.Locales.Count == 0)
            {
                var result =
                    MessageBox.Show(
                        "No valid locales were detected in the selected folder. This is either an empty project, or the wrong folder was selected.\r\n\r\nDo you want to continue loading this project?",
                        "No Locales Found", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                if (result == DialogResult.Yes)
                {
                    return(LoadFolderResult.Success);
                }

                _localeManager = null;

                if (result == DialogResult.No)
                {
                    return(LoadFolderResult.Retry);
                }

                if (result == DialogResult.Cancel)
                {
                    return(LoadFolderResult.Cancel);
                }
            }

            return(LoadFolderResult.Success);
        }
Пример #14
0
	public void Awake()
	{
		DontDestroyOnLoad( gameObject );
		m_Instance = this;

		FillDictionary();
	}
Пример #15
0
 public static void SetLocaleManager(LocaleManager manager)
 {
     if (localeManager == null)
     {
         localeManager = manager;
     }
 }
Пример #16
0
        public static void LoadInternalLanguages(LocaleManager manager)
        {
            manager.Locales.Clear();

            for (int i = 0; i < manager.textData.Length; i++)
            {
                LocaleData data = JsonMapper.ToObject <LocaleData>(manager.textData[i].text);
                manager.Locales.Add(data);
            }

            if (Directory.Exists(GamePath.LanguagePath()))
            {
                DirectoryInfo dir   = new DirectoryInfo(GamePath.LanguagePath());
                FileInfo[]    files = dir.GetFiles();

                for (int i = 0; i < files.Length; i++)
                {
                    Debug.Log("External locale file: " + files[i].FullName);
                    StreamReader reader = new StreamReader(files[i].FullName);
                    LocaleData   data   = JsonMapper.ToObject <LocaleData>(reader);
                    manager.Locales.Add(data);
                    reader.Close();
                }
            }

            Debug.Log("Totla locale count: " + manager.Locales.Count);
        }
Пример #17
0
        public static void AddString(this LocaleManager localeManager, LocalizedString localizedString)
        {
            Locale locale = localeManager.GetLocale();

            // Construct 0-index id for the localized string from argument
            Locale.Key id;
            id.m_Identifier = localizedString.Identifier;
            id.m_Key        = localizedString.Key;
            id.m_Index      = 0;

            // Check if the id already exists; if so find next index
            if (locale.Exists(id))
            {
                // Log message lags game on large namelists
                // Log($"Localized string {localizedString.Identifier}[{localizedString.Key}] already exists, adding it with next available index.");
                id.m_Index = locale.CountUnchecked(id);
            }

            // Add the localized string
            locale.AddLocalizedString(id, localizedString.Value);

            // Set the string counts accordingly
            Dictionary <Locale.Key, int> localizedStringCounts = locale.GetLocalizedStringsCount();

            // The count at the exact index appears to always be 0
            localizedStringCounts[id] = 0;

            // index = 0 appears to be a special case and indicates the count of localized strings with the same identifier and key
            Locale.Key zeroIndexID = id;
            zeroIndexID.m_Index = 0;
            localizedStringCounts[zeroIndexID] = id.m_Index + 1;

            // Log message lags game on large namelists
            // Log($"Added localized string {id} = '{localizedString.Value}', count = {localizedStringCounts[zeroIndexID]}.");
        }
Пример #18
0
        private void AddLanguageList(UIHelper group)
        {
            var dropDown = (group.self as UIComponent).AddUIComponent <LanguageDropDown>();

            dropDown.AddItem(string.Empty, CommonLocalize.ResourceManager.GetString("Mod_LocaleGame", CommonLocalize.Culture));

            foreach (var locale in GetSupportLanguages())
            {
                var localizeString = $"Mod_Locale_{locale}";
                var localeText     = CommonLocalize.ResourceManager.GetString(localizeString, CommonLocalize.Culture);
                if (SingletonMod <TypeMod> .Instance.Culture.Name.ToLower() != locale)
                {
                    localeText += $" ({CommonLocalize.ResourceManager.GetString(localizeString, new CultureInfo(locale))})";
                }

                dropDown.AddItem(locale, localeText);
            }

            dropDown.SelectedObject             = Locale.value;
            dropDown.eventSelectedIndexChanged += IndexChanged;

            void IndexChanged(UIComponent component, int value)
            {
                var locale = dropDown.SelectedObject;

                Locale.value = locale;
                LocaleManager.ForceReload();
            }
        }
Пример #19
0
 private void UpdateCustomTextSlider()
 {
     if (text != null)
     {
         text.text = LocaleManager.Inst().TranslateStr(textsCustom[(int)slider.value]);
     }
 }
Пример #20
0
        public void Constructor()
        {
            LocaleManager localeManager;

            localeManager = new LocaleManager();
            Assert.IsNotNull(localeManager);
        }
Пример #21
0
 public static void init()
 {
     if (instance == null)
     {
         instance = new LocaleManager();
         instance.ReadJSON();
     }
 }
 protected virtual void HandleOnLocalize(bool p_forceReapply)
 {
     if (LocaleManager.InstanceExists() && m_isLocalized && (p_forceReapply || !string.Equals(_lastLocalizedLanguage, LocaleManager.Instance.CurrentLanguage)))
     {
         //Invalidate Text
         SetText(m_text);
     }
 }
 public static void loadLocale(string localeId, bool force)
 {
     if (force)
     {
         LocaleManager.ForceReload();
     }
     loadLocaleIntern(localeId, true);
 }
Пример #24
0
        /// <summary>
        /// Get query info
        /// </summary>
        /// <param name="templateQueryInfo">Template node query info</param>
        /// <returns>Query info</returns>
        public List <QueryInfo> GetQueryByTemplateNodeQueryInfo(TemplateNodeQueryInfo templateQueryInfo)
        {
            log.InfoFormat("templateQueryInfo:QueryFileName:'{0}';QueryName:'{1}'",
                           templateQueryInfo.QueryFileName,
                           templateQueryInfo.QueryName
                           );

            string key = templateQueryInfo.QueryFileName + "|" + templateQueryInfo.QueryName;

            if (!this._queriesCache.Any(x => x.Item1 == key))
            {
                log.DebugFormat("QueryFileName:'{0}'",
                                FilesProvider.GetQueryFileName(
                                    templateQueryInfo.QueryFileName,
                                    templateQueryInfo.TemplateNode.ConnectionGroup.TemplateDir
                                    )
                                );

                List <QueryInfo> queries =
                    LoadQueries(FilesProvider.GetQueryFileName(
                                    templateQueryInfo.QueryFileName,
                                    templateQueryInfo.TemplateNode.ConnectionGroup.TemplateDir
                                    ),
                                templateQueryInfo.TemplateNode.ConnectionGroup.IsExternal
                                );

                foreach (QueryInfo query in queries)
                {
                    log.InfoFormat("query:name:'{0}';source:'{1}'",
                                   query.Name,
                                   query.Source
                                   );

                    string curKey = templateQueryInfo.QueryFileName + "|" + query.Name;

                    if (!this._queriesCache.Any(x => x.Item1 == curKey && x.Item2.Source == query.Source))
                    {
                        this._queriesCache.Add(new Tuple <string, QueryInfo>(curKey, query));
                    }
                }
            }

            if (!this._queriesCache.Any(x => x.Item1 == key))
            {
                throw new ArgumentException(
                          string.Format(
                              LocaleManager.GetLocalizedText(
                                  LocaleManager.Exceptions,
                                  "querynotfound"
                                  ),
                              key
                              )
                          );
            }

            return(this._queriesCache.Where(x => x.Item1 == key).Select(x => x.Item2).ToList());
        }
Пример #25
0
 public override void Group9SettingsUI(UIHelperExtension group9)
 {
     group9.AddDropdownLocalized("KCM_MOD_LANG", KCLocaleUtils.instance.getLanguageIndex(), KCLocaleUtils.currentLanguageId.value, delegate(int idx)
     {
         KCLocaleUtils.currentLanguageId.value = idx;
         LocaleManager.ForceReload();
     });
     group9.AddLabel(Locale.Get("KCM_LANG_NOTICE"));
 }
Пример #26
0
 private LocaleManager GetLocaleManager(Boolean refresh)
 {
     if (_localeManager.IsNull() || refresh)
     {
         _localeManager            = new LocaleManager();
         _localeManager.DataSource = new LocaleDataSource();
     }
     return(_localeManager);
 }
Пример #27
0
 private void UpdateTextTitleStatus()
 {
     if (TextTitleStatus != null && SliderLoader != null &&
         SliderLoader.value > 60 && !_textChanged)
     {
         TextTitleStatus.text = LocaleManager.Inst().TranslateStr("PRELOAD_SCREEN_GAME2");
         _textChanged         = true;
     }
 }
Пример #28
0
 public void SetLocale(string locale)
 {
     LocaleManager.LoadLocale(SidebarWindow.sett.path, locale);
     SystemTray.SetLocale();
     foreach (Tile tile in TilesGrid.Children)
     {
         tile.ChangeLocale(locale);
     }
 }
Пример #29
0
        private static void AddLanguageList(UIHelper group)
        {
            var locales  = GetSupportLanguages().ToArray();
            var dropDown = (group.self as UIComponent).AddUIComponent <LanguageDropDown>();

            dropDown.atlas                = TextureUtil.InGameAtlas;
            dropDown.size                 = new Vector2(400, 38);
            dropDown.listBackground       = "OptionsDropboxListbox";
            dropDown.itemHeight           = 24;
            dropDown.itemHover            = "ListItemHover";
            dropDown.itemHighlight        = "ListItemHighlight";
            dropDown.normalBgSprite       = "OptionsDropbox";
            dropDown.hoveredBgSprite      = "OptionsDropboxHovered";
            dropDown.focusedBgSprite      = "OptionsDropboxFocused";
            dropDown.autoListWidth        = true;
            dropDown.listHeight           = 700;
            dropDown.listPosition         = PopupListPosition.Below;
            dropDown.clampListToScreen    = false;
            dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropDown.popupColor           = Color.white;
            dropDown.popupTextColor       = new Color32(170, 170, 170, 255);
            dropDown.textScale            = 1.25f;
            dropDown.textFieldPadding     = new RectOffset(14, 40, 7, 0);
            dropDown.popupColor           = Color.white;
            dropDown.popupTextColor       = new Color32(170, 170, 170, 255);
            dropDown.verticalAlignment    = UIVerticalAlignment.Middle;
            dropDown.horizontalAlignment  = UIHorizontalAlignment.Left;
            dropDown.itemPadding          = new RectOffset(14, 14, 0, 0);
            dropDown.triggerButton        = dropDown;

            dropDown.AddItem(string.Empty, Localize.Mod_LocaleGame);

            foreach (var locale in locales)
            {
                var localizeString = $"Mod_Locale_{locale}";
                var localeText     = Localize.ResourceManager.GetString(localizeString, Localize.Culture);
                if (Localize.Culture.Name.ToLower() != locale)
                {
                    localeText += $" ({Localize.ResourceManager.GetString(localizeString, new CultureInfo(locale))})";
                }

                dropDown.AddItem(locale, localeText);
            }

            dropDown.SelectedObject = Locale.value;

            dropDown.eventSelectedIndexChanged += IndexChanged;

            void IndexChanged(UIComponent component, int value)
            {
                var locale = dropDown.SelectedObject;

                Locale.value = locale;
                LocaleManager.ForceReload();
            }
        }
Пример #30
0
        public void Dispose()
        {
            _container.Unregister <ILocaleManager>();
            _container = null;

            _configManager.RemovePropertyChangeListener(ConfigManager_UpdateLanguage);
            _configManager = null;

            _localeManager = null;
        }
Пример #31
0
        public Translator(LocaleManager localeManager, Locale parentLocale = null)
        {
            _localeManager = localeManager;
            _parentLocale  = parentLocale;
            InitializeComponent();

            imageList1.Images.Add(@"red", Properties.Resources.red);
            imageList1.Images.Add(@"orange", Properties.Resources.orange);
            imageList1.Images.Add(@"green", Properties.Resources.green);
        }
Пример #32
0
    private void SetCulture(string langType)
    {
        if (!String.IsNullOrEmpty(langType))
            {
                try
                {
                    LocaleData currentlocale = null;

                    String cacheKey = String.Format(CACHE_KEY_FORMAT, langType);
                    if (HttpContext.Current.Cache[cacheKey] == null)
                    {
                        lock (padlock)
                        {
                            if (HttpContext.Current.Cache[cacheKey] == null)
                            {
                                // Look up culture information from CMS

                                LocaleManager localeManager = new LocaleManager(Ektron.Cms.Framework.ApiAccessMode.Admin);
                                Criteria<LocaleProperty> criteria = new Criteria<LocaleProperty>();
                                criteria.AddFilter(LocaleProperty.Id, CriteriaFilterOperator.EqualTo, langType);
                                List<LocaleData> matchingLocals = localeManager.GetList(criteria);
                                if (matchingLocals != null && matchingLocals.Count > 0)
                                {
                                    currentlocale = matchingLocals[0];
                                    HttpContext.Current.Cache.Insert(cacheKey, currentlocale);
                                }
                            }
                        }
                    }

                    if (HttpContext.Current.Cache[cacheKey] != null)
                    {
                        currentlocale = (LocaleData)HttpContext.Current.Cache[cacheKey];
                        // Set asp.net culture property.
                        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(currentlocale.Culture);
                        Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(currentlocale.UICulture);
                    }

                }
                catch (Exception exc)
                {
                    _error = exc.Message;
                }
            }
    }