/// <summary> /// Translate content. /// </summary> /// <param name="input">Input content to translate.</param> /// <returns>Translated content.</returns> public static String Translate(String input) { var output = input; for (int n = 0; n < pairs.Size(); n++) { var line = Strings.Trim((String)pairs[n], "\r\n"); if (BLANK(line) || line.IndexOf("#") == 0) { continue; } if (line.IndexOf("|") == -1) { continue; } String[] chunks = (String[])null; var needRegex = false; if (line.IndexOf("/") == 0) { chunks = Strings.Split("\\|", line.Substring(1)); needRegex = true; } else { chunks = Strings.Split("\\|", line); } var to = SIZE(chunks) > 1 ? chunks[1] : ""; output = needRegex ? Regex.Replace(output, chunks[0], to) : Strings.Replace(chunks[0], to, output); } return(output); }
/// <summary> /// Initialize translation table. /// </summary> /// @param String @fileName Filename to load translation table from. /// <returns>Number of actual pairs in translation table.</returns> public static int Initialize(String fileName) { String[] lines = Helper.ReadAllLines(fileName); if (lines == null) { return(0); } pairs = new TArrayList(lines); return(pairs.Size()); }
/// <summary> /// Merge array lists. /// </summary> /// <param name="input">Original array list.</param> /// <param name="extra">Array list to merge with original one.</param> /// <returns>Resulting array list.</returns> public TArrayList Merge(TArrayList extra) { var output = Create(); for (int n1 = 0; n1 < this.Size(); n1++) { output.Add(this[n1]); } if (extra == null) { return(output); } for (int n2 = 0; n2 < extra.Size(); n2++) { output.Add(extra[n2]); } return(output); }