Esempio n. 1
0
 public static string SearchTranslation(string tNamespace, string tKey, string ifNotFound)
 {
     if (HotfixLocResDict != null &&
         HotfixLocResDict.ContainsKey(tNamespace) &&
         HotfixLocResDict[tNamespace].ContainsKey(tKey) &&
         HotfixLocResDict[tNamespace][tKey].ContainsKey(GetLanguageCode()))
     {
         return(HotfixLocResDict[tNamespace][tKey][GetLanguageCode()]);
     }
     else if (FProp.Default.FLanguage == "English")
     {
         return(ifNotFound);
     }
     else if (BRLocResDict != null && BRLocResDict.ContainsKey(tNamespace) && BRLocResDict[tNamespace].ContainsKey(tKey))
     {
         return(BRLocResDict[tNamespace][tKey]);
     }
     else if (STWLocResDict != null && STWLocResDict.ContainsKey(tNamespace) && STWLocResDict[tNamespace].ContainsKey(tKey))
     {
         return(STWLocResDict[tNamespace][tKey]);
     }
     else
     {
         return(ifNotFound);
     }
 }
        public static string SearchTranslation(string tNamespace, string tKey, string ifNotFound)
        {
            if (HotfixLocResDict != null &&
                HotfixLocResDict.ContainsKey(tNamespace) &&
                HotfixLocResDict[tNamespace].ContainsKey(tKey) &&
                HotfixLocResDict[tNamespace][tKey].ContainsKey(ifNotFound))
            {
                string ifNotFoundTemp = ifNotFound;

                // If there is a default text in hotfix, it's changed.
                bool isHotfixDefault = false;
                if (HotfixLocResDict[tNamespace][tKey].ContainsKey("en"))
                {
                    ifNotFound      = HotfixLocResDict[tNamespace][tKey][ifNotFound]["en"];
                    isHotfixDefault = true;
                }

                if (HotfixLocResDict[tNamespace][tKey][ifNotFoundTemp].ContainsKey(GetLanguageCode()))
                {
                    string hotfixString = HotfixLocResDict[tNamespace][tKey][ifNotFoundTemp][GetLanguageCode()];

                    // ONLY if there is english in the hotfix.
                    // If the translation is empty, it will be the default text.
                    if (isHotfixDefault && !string.IsNullOrEmpty(ifNotFound) && string.IsNullOrEmpty(hotfixString))
                    {
                        hotfixString = ifNotFound;
                    }

                    return(hotfixString);
                }
            }

            if (FProp.FLanguage == "English")
            {
                return(ifNotFound);
            }
            else if (BRLocResDict != null && BRLocResDict.ContainsKey(tNamespace) && BRLocResDict[tNamespace].ContainsKey(tKey))
            {
                return(BRLocResDict[tNamespace][tKey]);
            }
            else if (STWLocResDict != null && STWLocResDict.ContainsKey(tNamespace) && STWLocResDict[tNamespace].ContainsKey(tKey))
            {
                return(STWLocResDict[tNamespace][tKey]);
            }
            else
            {
                return(ifNotFound);
            }
        }
Esempio n. 3
0
        private static void HFedStringsProcess(string line)
        {
            if (line.StartsWith("+TextReplacements=(Category=Game,"))
            {
                string txtNamespace    = GetValueFromParam(line, "Namespace=\"", "\",");
                string txtKey          = GetValueFromParam(line, "Key=\"", "\",");
                string txtNativeString = GetValueFromParam(line, "NativeString=\"", "\",");

                string translations = GetValueFromParam(line, "LocalizedStrings=(", "))");
                if (!translations.EndsWith(")"))
                {
                    translations += ")";
                }

                if (!HotfixLocResDict.ContainsKey(txtNamespace))
                {
                    HotfixLocResDict[txtNamespace] = new Dictionary <string, Dictionary <string, Dictionary <string, string> > >();
                }

                if (!HotfixLocResDict[txtNamespace].ContainsKey(txtKey))
                {
                    HotfixLocResDict[txtNamespace][txtKey] = new Dictionary <string, Dictionary <string, string> >();
                }

                if (!HotfixLocResDict[txtNamespace][txtKey].ContainsKey(txtNativeString))
                {
                    HotfixLocResDict[txtNamespace][txtKey][txtNativeString] = new Dictionary <string, string>();
                }

                Regex regex = new Regex(@"(?<=\().+?(?=\))");
                foreach (Match match in regex.Matches(translations))
                {
                    try
                    {
                        string[] langParts = match.Value.Substring(1, match.Value.Length - 2).Split(new string[] { "\",\"" }, StringSplitOptions.None);
                        HotfixLocResDict[txtNamespace][txtKey][txtNativeString][langParts[0]] = langParts[1];
                    }
                    catch (IndexOutOfRangeException)
                    {
                        string[] langParts = match.Value.Substring(1, match.Value.Length - 2).Split(new string[] { "\", \"" }, StringSplitOptions.None);
                        if (langParts.Length > 1)
                        {
                            // 02/22/2020 legendary trad in spanish is miss-typed and cause crash ("es",Legendario""),
                            HotfixLocResDict[txtNamespace][txtKey][txtNativeString][langParts[0]] = langParts[1];
                        }
                    }
                }
            }
        }