/// <summary> /// Counts how many columns are reserved for the translation key, based on the /// first column that can be identified as a language column. /// </summary> /// <param name="excelCells">The array conatining all cell values out of the sheet.</param> /// <returns>The number of columns reserved for the translation key.</returns> public static int GetNumberOfKeyParts(object[,] excelCells) { var maxColumn = excelCells.GetUpperBound(1); for (var column = 1; column <= maxColumn; column++) { var culture = CultureInfoUtil.GetCultureInfoOrDefault( ExcelCellToString(excelCells[1, column]), true); if (culture != null) { return(column - 1); } } return(maxColumn); }
/// <summary> /// Adds an entry consisting of <paramref name="keyOfRow" /> and the translation in /// <paramref name="translationCell" /> to <paramref name="dictionary" /> for the /// language in <paramref name="languageCell" />. /// If the language in <paramref name="languageCell" /> cannot be found or the /// <paramref name="translationCell" /> is empty, <paramref name="dictionary" /> will not be updated. /// </summary> public static void TryAddExcelCellToDictionary(Dictionary <CultureInfo, Dictionary <string, string> > dictionary, object languageCell, object translationCell, string keyOfRow) { var lang = CultureInfoUtil.GetCultureInfoOrDefault( ExcelCellToString(languageCell), true); if (lang == null) { return; } var translationString = translationCell as string; if (!string.IsNullOrEmpty(translationString)) { dictionary[lang].Add(keyOfRow, translationString); } }