Пример #1
0
        /// <summary>
        /// Creates a <see cref="LocalizedStringList"/> from a <see cref="ThirdGenMultilingualStringList"/>.
        /// </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(ThirdGenMultilingualStringList 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));
        }
Пример #2
0
 /// <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.FindTagsByClass("unic"))
     {
         var group = new ThirdGenMultilingualStringList(reader, tag, _buildInfo);
         _groupsByTag[tag] = group;
     }
 }
Пример #3
0
        /// <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
            ThirdGenMultilingualStringList 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 ThirdGenMultilingualStringList(stringList.SourceTag, ranges, _buildInfo);
                _groupsByTag[stringList.SourceTag] = group;
            }
            group.Ranges[languageIndex].StartIndex = startIndex;
            group.Ranges[languageIndex].Size       = stringList.Strings.Count;
            return(stringList.Strings.Count);
        }
		/// <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.FindTagsByClass("unic"))
			{
				var group = new ThirdGenMultilingualStringList(reader, tag, _buildInfo);
				_groupsByTag[tag] = group;
			}
		}
		/// <summary>
		/// Creates a <see cref="LocalizedStringList"/> from a <see cref="ThirdGenMultilingualStringList"/>.
		/// </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(ThirdGenMultilingualStringList 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>
		/// 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
			ThirdGenMultilingualStringList 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 ThirdGenMultilingualStringList(stringList.SourceTag, ranges, _buildInfo);
				_groupsByTag[stringList.SourceTag] = group;
			}
			group.Ranges[languageIndex].StartIndex = startIndex;
			group.Ranges[languageIndex].Size = stringList.Strings.Count;
			return stringList.Strings.Count;
		}