Пример #1
0
        public static void AddExtended(string lang)
        {
            StringList list = StringList.GetList(lang);

            if (list == null)
            {
                list = StringList.AddLanguage(lang);
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(Path.Combine(Core.BaseDirectory, String.Format("Data/Localization/{0}.xml", lang)));

            XmlElement root = doc["locs"];

            foreach (XmlElement loc in root.GetElementsByTagName("loc"))
            {
                int         number = Utility.GetXMLInt32(Utility.GetAttribute(loc, "num", "0"), -1);
                StringEntry entry  = list[number];

                if (number > 500000)
                {
                    string text = Utility.GetText(loc, String.Empty);

                    if (entry != null)
                    {
                        entry.State = LState.Replaced;
                    }
                    else
                    {
                        entry = new StringEntry(number, LState.Extended, text);
                    }
                }
            }
        }
Пример #2
0
        public static void AddCliloc(string lang)
        {
            StringList list = StringList.GetList(lang);

            if (list == null)
            {
                list = StringList.AddLanguage(lang);
            }

            string path = Core.FindDataFile(String.Format("cliloc.{0}", lang));

            if (path == null)
            {
                Console.WriteLine("Warning: cliloc.{0} not found", lang);
                return;
            }

            using (BinaryReader bin = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.ASCII))
            {
                bin.ReadInt32();
                bin.ReadInt16();

                Encoding utf8 = Encoding.GetEncoding("UTF-8", new EncoderReplacementFallback(""), new DecoderReplacementFallback(""));

                while (bin.PeekChar() != -1)
                {
                    int number = bin.ReadInt32();
                    bin.ReadByte();                     //State in Cliloc
                    int length = bin.ReadInt16();       //Max of 65535 characters

                    StringEntry entry = new StringEntry(number, LState.Original, StringList.FormatArguments(utf8.GetString(bin.ReadBytes(length))));

                    list.Table[number] = entry;
                }

                bin.Close();
            }
        }