public static bool CommentsAreVisible(
     Project project,
     DataRow row,
     CommentVisibilityScope commentVisibilityScope)
 {
     return(CommentsAreVisible(project, row.Table, commentVisibilityScope));
 }
Ejemplo n.º 2
0
        private static bool areTranslationsMissing(Project project, DataRow row,
                                                   CommentVisibilityScope commentVisibilityScope)
        {
            var hasEmpty    = false;
            var hasNonEmpty = false;

            // AJ CHANGE
            // Don't check the comments column
            // Column 0=FileGroup checksum, column 1=Tag name.
            for (var i = 2; i < row.Table.Columns.Count -
                 (DataProcessing.CommentsAreVisible(project, row, commentVisibilityScope) ? 1 : 0); ++i)
            {
                var s = ConvertHelper.ToString(row[i], string.Empty);

                if (string.IsNullOrEmpty(s))
                {
                    hasEmpty = true;
                }
                else
                {
                    hasNonEmpty = true;
                }
            }

            return(hasEmpty && hasNonEmpty);
        }
Ejemplo n.º 3
0
        public static bool IsCompleteRowEmpty(
            DataRow row,
            CommentVisibilityScope commentVisibilityScope)
        {
            // Column 0=FileGroup checksum, column 1=Tag name.
            for (var i = 2; i < row.Table.Columns.Count; ++i)
            {
                if (ConvertHelper.ToString(row[i], string.Empty).Trim().Length > 0)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
        // AJ CHANGE
        private static bool doesAutomaticTranslationsExist(
            Project project,
            DataRow row,
            CommentVisibilityScope commentVisibilityScope)
        {
            // Column 0=FileGroup checksum, column 1=Tag name.
            for (var i = 2; i < row.Table.Columns.Count -
                 (DataProcessing.CommentsAreVisible(project, row, commentVisibilityScope) ? 1 : 0); ++i)
            {
                var s = ConvertHelper.ToString(row[i], string.Empty);
                if (s.StartsWith(DefaultTranslatedPrefix))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        private static bool hasPlaceholderMismatch(
            Project project,
            DataRow row,
            CommentVisibilityScope commentVisibilityScope)
        {
            // 2011-11-17, Uwe Keim.
            var neutralCode        = project == null ? @"en-US" : project.NeutralLanguageCode;
            var neutralColumnIndex = findColumnIndex(row.Table, neutralCode, 2);

            var columnCount = row.Table.Columns.Count;

            var s0 =
                columnCount > 0
                // Column 0=FileGroup checksum, column 1=Tag name.
                    ? ConvertHelper.ToString(row[neutralColumnIndex], string.Empty)
                    : string.Empty;
            var firstPlaceholderCount = ExtractPlaceholders(s0);

            // AJ CHANGE, skip the comments column
            // Column 0=FileGroup checksum, column 1=Tag name.
            for (var i = 2; i < columnCount -
                 (DataProcessing.CommentsAreVisible(project, row, commentVisibilityScope) ? 1 : 0); ++i)
            {
                if (i != neutralColumnIndex)
                {
                    var s = ConvertHelper.ToString(row[i], string.Empty);

                    // 2011-11-16, Uwe Keim: Only check if non-empty, non-default-language.
                    if (!string.IsNullOrEmpty(s))
                    {
                        var other = ExtractPlaceholders(s);

                        if (other != firstPlaceholderCount)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
        // AJ CHANGE
        // Checks if the Column Comment is visible in the row
        public static bool CommentsAreVisible(
            Project project,
            DataTable table,
            CommentVisibilityScope commentVisibilityScope)
        {
            if (commentVisibilityScope == CommentVisibilityScope.InMemory || GetShowCommentColumn(project))
            {
                var colName = table.Columns[table.Columns.Count - 1].ColumnName;

                // Sometimes the comment column gets the prefix col, depends on the visibility state
                return(colName == @"colComment" ||
                       colName == @"Comment" ||
                       colName == @"col" + Resources.SR_ColumnCaption_Comment ||
                       colName == @"col" + Resources.SR_CommandProcessorSend_Process_Comment ||
                       colName == Resources.SR_ColumnCaption_Comment);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        public static FileGroupStates DoCalculateEditingState(
            Project project,
            DataTable table,
            CommentVisibilityScope commentVisibilityScope)
        {
            if (table == null)
            {
                return(FileGroupStates.Empty);
            }
            else
            {
                var result = FileGroupStates.CompletelyTranslated;

                foreach (DataRow row in table.Rows)
                {
                    if (IsCompleteRowEmpty(row, commentVisibilityScope))
                    {
                        result |= FileGroupStates.EmptyRows;
                    }

                    if (areTranslationsMissing(project, row, commentVisibilityScope))
                    {
                        result |= FileGroupStates.TranslationsMissing;
                    }

                    if (hasPlaceholderMismatch(project, row, commentVisibilityScope))
                    {
                        result |= FileGroupStates.FormatParameterMismatches;
                    }

                    if (doesAutomaticTranslationsExist(project, row, commentVisibilityScope))
                    {
                        result |= FileGroupStates.AutomaticTranslationsExist;
                    }
                }

                return(result);
            }
        }
        private static bool wantExportRow(
            SnapshotController ssc,
            PreparedInformation preparedInformation,
            IInheritedSettings settings,
            DataRow row,
            CommentVisibilityScope commentVisibilityScope)
        {
            if (FileGroup.IsCompleteRowEmpty(row) &&
                !preparedInformation.ExportCompletelyEmptyRows ||
                // http://www.codeproject.com/KB/aspnet/ZetaResourceEditor.aspx?msg=3367544#xx3367544xx)
                FileGroup.IsInternalRow(row))
            {
                return(false);
            }

            if (preparedInformation.OnlyExportRowsWithNoTranslation)
            {
                var emptyCount = 0;

                // ReSharper disable LoopCanBeConvertedToQuery
                foreach (DataColumn column in row.Table.Columns)
                // ReSharper restore LoopCanBeConvertedToQuery
                {
                    // Column 0=FileGroup checksum, column 1=Tag name.
                    if (column.Ordinal != 0 && column.Ordinal != 1 && !isCommentColumn(column))
                    {
                        var languageCode =
                            IsFileName(column.ColumnName)
                                ? new LanguageCodeDetection(preparedInformation.Project).DetectLanguageCodeFromFileName(
                                settings,
                                column.ColumnName)
                                : column.ColumnName;

                        if (string.Compare(languageCode, preparedInformation.ReferenceLanguageCode,
                                           StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            if (ConvertHelper.ToString(row[column], string.Empty).Trim().Length <= 0)
                            {
                                emptyCount++;
                            }
                        }
                    }
                }

                if (preparedInformation.Project.EnableExcelExportSnapshots)
                {
                    return(emptyCount > 0 ||
                           preparedInformation.OnlyExportRowsWithChangedTexts &&
                           hasChangedTextSinceLastExport(ssc, preparedInformation, settings, row));
                }
                else
                {
                    return(emptyCount > 0);
                }
            }
            else
            {
                if (preparedInformation.Project.EnableExcelExportSnapshots)
                {
                    return(!preparedInformation.OnlyExportRowsWithChangedTexts ||
                           hasChangedTextSinceLastExport(ssc, preparedInformation, settings, row));
                }
                else
                {
                    return(true);
                }
            }
        }
Ejemplo n.º 9
0
		public static bool CommentsAreVisible(
			Project project,
			DataRow row,
			CommentVisibilityScope commentVisibilityScope)
		{
			return CommentsAreVisible(project, row.Table, commentVisibilityScope);
		}
Ejemplo n.º 10
0
		// AJ CHANGE
		// Checks if the Column Comment is visible in the row
		public static bool CommentsAreVisible(
			Project project,
			DataTable table,
			CommentVisibilityScope commentVisibilityScope)
		{
			if (commentVisibilityScope == CommentVisibilityScope.InMemory || GetShowCommentColumn(project))
			{
				var colName = table.Columns[table.Columns.Count - 1].ColumnName;

				// Sometimes the comment column gets the prefix col, depends on the visibility state
				return colName == @"colComment" ||
					   colName == @"Comment" ||
					   colName == @"col" + Resources.SR_ColumnCaption_Comment ||
					   colName == @"col" + Resources.SR_CommandProcessorSend_Process_Comment ||
					   colName == Resources.SR_ColumnCaption_Comment;
			}
			else
			{
				return false;
			}
		}