Ejemplo n.º 1
0
		public virtual bool ReadTranslation(Encoding translationEncoding) {
			// Read translation file
			var translationFilepath = BuildTranslationFilepath();
			mTranslationFile = new PipeTrailedFile(translationEncoding, false, false);
			mTranslationFile.Read(translationFilepath);

			Entries.BeginInit();

			// Apply translations by the first column (always ID?)
			for (var r = 0; r < mTranslationFile.Entries.Rows.Count; r++) {
				var translatedRow = mTranslationFile.Entries.Rows[r];
				var pkey = int.Parse(translatedRow[0].ToString());
				if (RowSearchIndex.ContainsKey(pkey) == false) {
					continue;
				}

				var sourceIndex = RowSearchIndex[pkey];
				var sourceRow = Entries.Rows[sourceIndex];

				for (var c = 1; c < mTranslationFile.Entries.Columns.Count; c++) {
					var columnSourceValue = mTranslationFile.ColumnMappings[c];
					var columnSourceIndex = int.Parse(columnSourceValue);
					// Columns start with 0, numbers with 1
					columnSourceIndex--;
					sourceRow[columnSourceIndex] = translatedRow[c];
				}

			}

			Entries.EndInit();

			return true;
		}
Ejemplo n.º 2
0
        public virtual bool ReadTranslation(Encoding translationEncoding)
        {
            // Read translation file
            var translationFilepath = BuildTranslationFilepath();

            mTranslationFile = new PipeTrailedFile(translationEncoding, false, false);
            mTranslationFile.Read(translationFilepath);

            Entries.BeginInit();

            // Apply translations by the first column (always ID?)
            for (var r = 0; r < mTranslationFile.Entries.Rows.Count; r++)
            {
                var translatedRow = mTranslationFile.Entries.Rows[r];
                var pkey          = int.Parse(translatedRow[0].ToString());
                if (RowSearchIndex.ContainsKey(pkey) == false)
                {
                    continue;
                }

                var sourceIndex = RowSearchIndex[pkey];
                var sourceRow   = Entries.Rows[sourceIndex];

                for (var c = 1; c < mTranslationFile.Entries.Columns.Count; c++)
                {
                    var columnSourceValue = mTranslationFile.ColumnMappings[c];
                    var columnSourceIndex = int.Parse(columnSourceValue);
                    // Columns start with 0, numbers with 1
                    columnSourceIndex--;
                    sourceRow[columnSourceIndex] = translatedRow[c];
                }
            }

            Entries.EndInit();

            return(true);
        }