/// <summary> /// Creates a <see cref="LocalizedStringList"/> from a <see cref="SecondGenMultilingualStringList"/>. /// </summary> /// <param name="group">The string list to load from.</param> /// <param name="languageIndex">Index of the language.</param> /// <param name="table">The string table to load from.</param> /// <returns>The created string list.</returns> private static LocalizedStringList CreateList(SecondGenMultilingualStringList group, int languageIndex, List <LocalizedString> table) { var startIndex = group.Ranges[languageIndex].StartIndex; var size = group.Ranges[languageIndex].Size; var strings = table.Skip(startIndex).Take(size).ToList(); return(new LocalizedStringList(group.Tag, strings)); }
/// <summary> /// Loads group info from a cache file. /// </summary> /// <param name="reader">The stream to read from.</param> /// <param name="cacheFile">The cache file.</param> private void LoadGroups(IReader reader, ICacheFile cacheFile) { foreach (var tag in cacheFile.Tags.FindTagsByGroup("unic")) { var group = new SecondGenMultilingualStringList(reader, tag, _buildInfo); _groupsByTag[tag] = group; } }
/// <summary> /// Merges a <see cref="LocalizedStringList"/> with string list information for a language. /// </summary> /// <param name="stringList">The string list.</param> /// <param name="languageIndex">Index of the language.</param> /// <param name="startIndex">The index where strings in the list will start at.</param> /// <returns>The number of strings in the string list.</returns> private int MergeStringList(LocalizedStringList stringList, int languageIndex, int startIndex) { // TODO: Assert that the tag exists SecondGenMultilingualStringList group; _groupsByTag.TryGetValue(stringList.SourceTag, out group); if (group == null) { // Create a new string list // Assume there's going to be at least one group already and use that to get the number of languages... // TODO: Read this from build info or something var ranges = _groupsByTag.Values.First().Ranges.Select(r => new StringRange(0, 0)).ToArray(); group = new SecondGenMultilingualStringList(stringList.SourceTag, ranges, _buildInfo); _groupsByTag[stringList.SourceTag] = group; } group.Ranges[languageIndex].StartIndex = startIndex; group.Ranges[languageIndex].Size = stringList.Strings.Count; return(stringList.Strings.Count); }