예제 #1
0
 public void RefreshConfig(LocalizationType type, bool isDebug, BuildPlatform platform)
 {
     string isDebugStr = isDebug ? "_debug.xml" : "_release.xml";
     //TODO Fix me
     string path = Application.dataPath + "/../../Settings/BuildSettings/jenkins_" + platform.ToString() + "_" + type.ToString() + isDebugStr;
     RefreshConfig(path);
 }
예제 #2
0
 public static void BuildPcBundles(LocalizationType type)
 {
     //刷新配置文件
     JenkinsUtils.RefreshConfig(type, true, BuildPlatform.pc);
     //构建
     BuildBundles(BuildTarget.StandaloneWindows);
 }
예제 #3
0
 public static void BuildIOSBundles(LocalizationType type)
 {
     //刷新配置文件
     JenkinsUtils.RefreshConfig(type, true, BuildPlatform.ios);
     //构建
     BuildBundles(BuildTarget.iOS);
 }
예제 #4
0
        public void SetLanguage(LocalizationType languageType)
        {
            m_curLanguage = languageType;
            // 根据语言设置重载本地化表
            //	string dbPath = Application.persistentDataPath + "/"; // 语言包文件路径;
            m_dictTextWithId.Clear();
            m_dictTextWithAlias.Clear();
            // 从dbPath读取数据,加入两个dict
            //	Console.Instance ().Debug (dbPath);
            SQLiteHelper     helper = new SQLiteHelper("Localization.db");
            SqliteDataReader reader = helper.ExecuteQuery("SELECT * FROM Localization");
            int idOrdinal           = reader.GetOrdinal("ID");
            int aliasOrdinal        = reader.GetOrdinal("Alias");
            int textOridinal        = reader.GetOrdinal(m_curLanguage.ToString());

            while (reader.Read())
            {
                int    nId      = reader.GetInt32(idOrdinal);
                string strAlias = reader.GetString(aliasOrdinal);
                string strText  = reader.GetString(textOridinal);

                m_dictTextWithId [nId]         = strText;
                m_dictTextWithAlias [strAlias] = strText;
            }
            reader.Close();
            helper.CloseConnection();
            Debug.LogFormat("加载了{0}条本地化记录", m_dictTextWithId.Count);
        }
예제 #5
0
 public static Models.Localization Get(string portalId, LocalizationType type, string ns, string key, string locale)
 {
     return Repository.Current.GetResources<Models.Localization>(type.ToString(), l =>
         l.Data.PortalId == portalId &&
         l.Data.Namespace == ns &&
         l.Data.Key == key &&
         ((string.IsNullOrEmpty(l.Data.Locale) && string.IsNullOrEmpty(locale) ) || (l.Data.Locale == locale ))
         ).Select(l => l.Data).SingleOrDefault();
 }
예제 #6
0
 public static void SetLanguage(LocalizationType lan)
 {
     if (language != lan)
     {
         language = lan;
         reloadLocalizationStrings();
         RFManager.Ins.DoCommand("ChangeLanguage");
     }
 }
예제 #7
0
 public static Models.Localization Get(string portalId, LocalizationType type, string ns, string key, string locale)
 {
     return(Repository.Current.GetResources <Models.Localization>(type.ToString(), l =>
                                                                  l.Data.PortalId == portalId &&
                                                                  l.Data.Namespace == ns &&
                                                                  l.Data.Key == key &&
                                                                  ((string.IsNullOrEmpty(l.Data.Locale) && string.IsNullOrEmpty(locale)) || (l.Data.Locale == locale))
                                                                  ).Select(l => l.Data).SingleOrDefault());
 }
예제 #8
0
        public static List <Models.Localization> GetLocalizations(LocalizationType type, Func <Models.Localization, bool> query, string portalId = null)
        {
            portalId = string.IsNullOrEmpty(portalId) ? Services.Portal.CurrentPortalId : portalId;
            //var locs = Get(type, portalId).Where(query);
            var queries      = GetLocalizationQueries(portalId, portalId, CurrentUserLocale); //GetLocalizationQueries(CurrentUserLocale);
            var resourceLocs = Repository.Current.GetResources <Models.Localization>(type.ToString(), l => l.Data.PortalId == portalId && l.Data.Key.EndsWith(".Client"));

            return(Repository.Current.GetResources <Models.Localization>(resourceLocs, queries, true).Select(r => r.Data).ToList());
            //return queries.GetMatches(locs, true);
        }
예제 #9
0
        private string GetLocalizedLookupByKey(string lookupKey, LocalizationType localizationType = LocalizationType.Default)
        {
            var localizedLookupByKey = GetLocalizationForKey(typeof(LookupLocalization).Name, lookupKey, localizationType);

            if (string.IsNullOrWhiteSpace(localizedLookupByKey))
            {
                return(lookupKey);
            }

            return(localizedLookupByKey);
        }
예제 #10
0
            public virtual TData From(LocalizationType localization)
            {
                for (int i = 0; i < elements.Length; i++)
                {
                    if (elements[i].Localization == localization)
                    {
                        return(elements[i].Value);
                    }
                }

                return(Default);
            }
예제 #11
0
        public static string From(LocalizationType type)
        {
            for (int i = 0; i < list.Length; i++)
            {
                if (list[i].Type == type)
                {
                    return(list[i].Code);
                }
            }

            throw new NotImplementedException();
        }
        public virtual LocalizationPreset Get(LocalizationType type)
        {
            for (int i = 0; i < Count; i++)
            {
                if (this[i].Type == type)
                {
                    return(this[i]);
                }
            }

            return(null);
        }
예제 #13
0
        public virtual void Progress()
        {
            IList values = Enum.GetValues(typeof(LocalizationType));

            var index = values.IndexOf(target);

            if (index + 1 < values.Count)
            {
                Target = (LocalizationType)values[index + 1];
            }
            else
            {
                Target = (LocalizationType)values[0];
            }
        }
예제 #14
0
 private void LocalizationPopup()
 {
     EditorGUILayout.BeginHorizontal();
     {
         EditorGUILayout.Space();
         EditorGUI.BeginChangeCheck();
         LocalizationType selectType = (LocalizationType)EditorGUILayout.Popup((int)Localization.CurrentType, Localization.LOCALIZATION_LABEL, GUILayout.Width(150));
         if (EditorGUI.EndChangeCheck())
         {
             Localization.SetLocalizationType(selectType);
         }
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
 }
예제 #15
0
        public static string GetLocalization(LocalizationType type, string key, string defaultText, string ns, string locale = null, string portalId = null, bool create = true)
        {
            locale   = string.IsNullOrEmpty(locale) ? CurrentUserLocale : locale;
            portalId = string.IsNullOrEmpty(portalId) ? Services.Portal.CurrentPortalId : portalId;
            var text = defaultText;

            var loc = Repository.Current.GetResourceData <Models.Localization>(type.ToString(), key, GetLocalizationQueries(portalId, ns, locale), null);

            if (loc == null && create)
            {
                Services.Localization.Save(new Models.Localization()
                {
                    Type = type, Key = key, Namespace = ns, Locale = null, PortalId = portalId, Text = defaultText
                }, Services.Account.AuditId);
            }
            else
            {
                text = loc.Text;
            }

            return(text);
        }
예제 #16
0
 public static List<Models.Localization> Get(LocalizationType type, string portalId)
 {
     return Repository.Current.GetResources<Models.Localization>(type.ToString(), l => l.Data.PortalId == portalId).Select(l => l.Data).ToList();
 }
예제 #17
0
 public static void BuildWebGLBundle(LocalizationType type)
 {
     JenkinsUtils.RefreshConfig(type, true, BuildPlatform.webgl);
     BuildBundles(BuildTarget.WebGL);
 }
예제 #18
0
 public static List<Models.Localization> Get(LocalizationType type, string portalId, string ns)
 {
     return Repository.Current.GetResources<Models.Localization>(type.ToString(), l => l.Data.PortalId == portalId && l.Data.Namespace.IndexOf(ns) == 0).Select(l => l.Data).ToList();
 }
예제 #19
0
 public bool Contains(LocalizationType type)
 {
     return(Contains(LocalizationCode.From(type)));
 }
예제 #20
0
 public static List <Models.Localization> Get(LocalizationType type, string portalId, string ns)
 {
     return(Repository.Current.GetResources <Models.Localization>(type.ToString(), l => l.Data.PortalId == portalId && l.Data.Namespace.IndexOf(ns) == 0).Select(l => l.Data).ToList());
 }
 public Element(LocalizationType type, Material value) : base(type, value)
 {
 }
예제 #22
0
 public static string GetPathToLocalizationFiles(LocalizationType localizationType)
 {
     return(string.Concat(PATH_TO_DATA, PATH_TO_LOCALIZATION_FILES, localizationType.ToString(), "/"));
 }
예제 #23
0
 public virtual string GetLocalizedEnum <TEnum>(TEnum enumValue, LocalizationType localizationType = LocalizationType.Default)
 {
     return(GetLocalizedEnumByKey(string.Format("{0}_{1}", enumValue.GetType().Name, enumValue), localizationType) ?? enumValue.ToString());
 }
예제 #24
0
 public static List <Models.Localization> Get(LocalizationType type, string portalId)
 {
     return(Repository.Current.GetResources <Models.Localization>(type.ToString(), l => l.Data.PortalId == portalId).Select(l => l.Data).ToList());
 }
예제 #25
0
 public Element(LocalizationType localization, TValue value)
 {
     this.localization = localization;
     this.value        = value;
 }
예제 #26
0
    private void Initialize()
    {
        var english = new Dictionary <string, string>
        {
            { "Lanquage", "Lanquage" },
            { "Sound", "Sound" },
            { "Effects", "Effects" },
            { "Support", "Next" },
            { "Load", "Load" },
            { "Start", "Start" },
            { "Art", "Art" },
            { "autor1", "Anatoli Zaicev" },
            { "Programming", "Programming" },
            { "autor2", "Stanislav Nos" },
            { "new", "New Game" },
            { "continue", "Continue" },
            { "Loading", "Loading" },
            { "baraban", "Show/Hide" },
            { "settings", "Settings" },
            { "hide", "Hide" },
            { "back", "Back" }
        };
        var russian = new Dictionary <string, string>
        {
            { "Lanquage", "Языкъ" },
            { "Sound", "Музыка" },
            { "Effects", "Звук" },
            { "Support", "Продолжить" },
            { "Load", "Загрузить" },
            { "Start", "Стреляться" },
            { "Art", "Художник" },
            { "autor1", "Анатолий Зайцев" },
            { "Programming", "Кудесник кода" },
            { "autor2", "Станислав Нос" },
            { "new", "Cначала" },
            { "continue", "Продолжить" },
            { "Loading", "Загрузка" },
            { "baraban", "Показать/Скрыть" },
            { "settings", "Настройки" },
            { "hide", "Скрыть" },
            { "back", "Назад" }
        };
        var belarus = new Dictionary <string, string>
        {
            { "Lanquage", "Мова" },
            { "Sound", "Музыка" },
            { "Effects", "іншы гук" },
            { "Support", "Далей" },
            { "Load", "Загрузить" },
            { "Start", "Страляцца" },
            { "Art", "Мастак" },
            { "autor1", "Анатоль Зайцаў" },
            { "Programming", "Праграміст" },
            { "autor2", "Станіслаў Нос" },
            { "new", "Спачатку" },
            { "continue", "Застацца" },
            { "Loading", "Пампуецца" },
            { "baraban", "Паказаць / Прыбраць" },
            { "settings", "Налады" },
            { "hide", "Hide" },
            { "back", "Вярнуцца" }
        };

        localizationLibrary = new Dictionary <string, Dictionary <string, string> >
        {
            { "English", english },
            { "Belarussian", belarus },
            { "Russian", russian }
        };


        var i = PlayerPrefs.GetInt("localize", 0);

        Debug.Log("Load LocalizationType " + i);
        Localization = (LocalizationType)i;
    }
예제 #27
0
 public string this[LocalizationType type] => Get(type);
예제 #28
0
        public static void SetLocalizationType(LocalizationType type)
        {
            string cfgPath = $"{FinalPatchConst.LOCALIZATION_DIR}/{type.ToString().ToLower()}{FinalPatchConst.LOCALIZATION_EXT}";
            bool   found   = false;

            try
            {
                using (FileStream fs = File.Open(cfgPath, FileMode.Open, FileAccess.Read))
                {
                    XmlSerializer    serializer = new XmlSerializer(typeof(LocalizationData));
                    LocalizationData data       = serializer.Deserialize(fs) as LocalizationData;

                    if (s_localizationMap == null)
                    {
                        s_localizationMap = new Dictionary <string, string>();
                    }
                    s_localizationMap.Clear();
                    foreach (var item in data.items)
                    {
                        s_localizationMap.Add(item.Key, item.Value);
                    }
                    found       = true;
                    CurrentType = type;
                    EditorPrefs.SetInt(FinalPatchConst.KEY_FINAL_PATCH_LOCALIZATION, (int)type);
                    OnLanguageChanged?.Invoke();
                }
            }
            catch { }

            if (!found)
            {
                // create localization file
                LocalizationData data = new LocalizationData()
                {
                    items = new List <LocalizationItem>()
                    {
                        new LocalizationItem()
                        {
                            Key   = "localization_key",
                            Value = "localization_value",
                        }
                    }
                };

                string dir = Path.GetDirectoryName(cfgPath);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                using (FileStream fs = new FileStream(cfgPath, FileMode.Create, FileAccess.Write))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(LocalizationData));
                    serializer.Serialize(fs, data);
                }

                Debug.LogFormat("Create Localization File:{0}", cfgPath);
                AssetDatabase.Refresh();
                SetLocalizationType(type);
            }
        }
예제 #29
0
 void LocalizationTargetChanged(LocalizationType target)
 {
     UpdateState();
 }
예제 #30
0
 public static void RefreshConfig(LocalizationType type, bool isDebug, BuildPlatform platform)
 {
     JenkinsBuildConfig.Instance.RefreshConfig(type, isDebug, platform);
 }
예제 #31
0
 public virtual string Get(string ID, LocalizationType code)
 {
     return(Get(ID, LocalizationCode.From(code)));
 }
예제 #32
0
 private void LocalizationTargetChangedCallback(LocalizationType target)
 {
     UpdateState();
 }
예제 #33
0
            protected override void TargetChangeCallback(LocalizationType type)
            {
                base.TargetChangeCallback(type);

                UpdateState();
            }
예제 #34
0
 public static void Initialize(LocalizationType type)
 {
     Language = type.ToString();
 }
예제 #35
0
        public static string GetLocalization(LocalizationType type, string key, string defaultText, string ns, string locale = null, string portalId = null, bool create = true)
        {
            locale = string.IsNullOrEmpty(locale) ? CurrentUserLocale : locale;
            portalId = string.IsNullOrEmpty(portalId) ? Services.Portal.CurrentPortalId : portalId;
            var text = defaultText;

            var loc = Repository.Current.GetResourceData<Models.Localization>(type.ToString(), key, GetLocalizationQueries(portalId, ns, locale), null);
            if (loc == null && create)
                Services.Localization.Save(new Models.Localization() { Type = type, Key = key, Namespace = ns, Locale = null, PortalId = portalId, Text = defaultText }, Services.Account.AuditId);
            else
                text = loc.Text;

            return text;
        }
예제 #36
0
 public static void BuildWPBundle(LocalizationType type)
 {
     JenkinsUtils.RefreshConfig(type, true, BuildPlatform.wp8);
     BuildBundles(BuildTarget.WP8Player);
 }
예제 #37
0
 public static List<Models.Localization> GetLocalizations(LocalizationType type, Func<Models.Localization, bool> query, string portalId = null)
 {
     portalId = string.IsNullOrEmpty(portalId) ? Services.Portal.CurrentPortalId : portalId;
     //var locs = Get(type, portalId).Where(query);
     var queries = GetLocalizationQueries(portalId, portalId, CurrentUserLocale); //GetLocalizationQueries(CurrentUserLocale);
     var resourceLocs = Repository.Current.GetResources<Models.Localization>(type.ToString(), l => l.Data.PortalId == portalId && l.Data.Key.EndsWith(".Client"));
     return Repository.Current.GetResources<Models.Localization>(resourceLocs, queries, true).Select(r => r.Data).ToList();
     //return queries.GetMatches(locs, true);
 }
예제 #38
0
 private string GetLocalizedEnumByKey(string enumKey, LocalizationType localizationType = LocalizationType.Default)
 {
     return(GetLocalizationForKey(typeof(EnumLocalization).Name, enumKey, localizationType));
 }
예제 #39
0
 public string Get(LocalizationType type)
 {
     return(Get(LocalizationCode.From(type)));
 }
예제 #40
0
        protected string GetLocalizationForKey(string classKey, string resourceEntryKey, LocalizationType localizationType)
        {
            var localizedValue = GetLocalizationForKey(classKey, string.Format("{0}_{1}", localizationType, resourceEntryKey));

            if (localizationType == LocalizationType.Default || string.IsNullOrEmpty(localizedValue))
            {
                return(GetLocalizationForKey(classKey, resourceEntryKey));
            }

            return(localizedValue);
        }
예제 #41
0
 public string GetLocalizedBelastungskategorieTyp(string belastungskategorieTyp, LocalizationType localizationType = LocalizationType.Default)
 {
     return(GetLocalizedLookupByKey(belastungskategorieTyp, localizationType));
 }
예제 #42
0
 public static void ControlLocalized(LocalizationType localizationType)
 {
     LocalizationConfigHandler.RuntimeLocalizationType = localizationType;
     ControlLocalized();
 }
예제 #43
0
 public override string GetLocalizedEnum <TEnum>(TEnum enumValue, LocalizationType localizationType = LocalizationType.Default)
 {
     return(enumValue.ToString());
 }