Beispiel #1
0
    def get_next_goal_count(self):
        # Putting the next import at the top of the file causes circular
        # import issues.
        from pootle_tagging.models import Goal

        goal = Goal.get_most_important_incomplete_for_path(self.directory)

        if goal is not None:
            return goal.get_incomplete_words_in_path(self.directory)

        return 0
Beispiel #2
0
    def _get_next_goal_count(self):
        # Putting the next import at the top of the file causes circular
        # import issues.
        from pootle_tagging.models import Goal

        goal = Goal.get_most_important_incomplete_for_path(self.directory)

        if goal is not None:
            return goal.get_incomplete_words_in_path(self.directory)

        return 0
Beispiel #3
0
    def get_next_goal_url(self):
        # Putting the next import at the top of the file causes circular
        # import issues.
        from pootle_tagging.models import Goal

        goal = Goal.get_most_important_incomplete_for_path(self.directory)

        if goal is not None:
            return goal.get_translate_url_for_path(self.directory.pootle_path,
                                                   state='incomplete')

        return ''
Beispiel #4
0
    def get_next_goal_url(self):
        # Putting the next import at the top of the file causes circular
        # import issues.
        from pootle_tagging.models import Goal

        goal = Goal.get_most_important_incomplete_for_path(self.directory)

        if goal is not None:
            return goal.get_translate_url_for_path(self.directory.pootle_path,
                                                   state='incomplete')

        return ''
Beispiel #5
0
    def get_next_goal_url(self):
        # Trigger only if it is a regular directory inside a TP.
        if self.pootle_path.count('/') > 3:
            # Putting the next import at the top of the file causes circular
            # import issues.
            from pootle_tagging.models import Goal

            goal = Goal.get_most_important_incomplete_for_path(self)

            if goal is not None:
                return goal.get_translate_url_for_path(self.pootle_path,
                                                       state='incomplete')
        return ''
Beispiel #6
0
    def get_next_goal_url(self):
        # Trigger only if it is a regular directory inside a TP.
        if self.pootle_path.count('/') > 3:
            # Putting the next import at the top of the file causes circular
            # import issues.
            from pootle_tagging.models import Goal

            goal = Goal.get_most_important_incomplete_for_path(self)

            if goal is not None:
                return goal.get_translate_url_for_path(self.pootle_path,
                                                       state='incomplete')
        return ''
Beispiel #7
0
def get_translate_actions(path_obj):
    """Return a list of translation action links to be displayed for each ``path_obj``."""
    goals_summary = []

    # Build URL for getting more summary information for the current path.
    url_path_summary_more = reverse('pootle-xhr-summary-more')

    if path_obj.is_dir:
        # Putting the next import at the top of the file causes circular
        # import issues.
        from pootle_tagging.models import Goal

        pootle_path = path_obj.pootle_path
        goal = Goal.get_most_important_incomplete_for_path(path_obj)

        if goal is not None:
            goal_words = goal.get_incomplete_words_in_path(path_obj)
            goal_url = goal.get_translate_url_for_path(pootle_path,
                                                       state='incomplete')
            if goal_words > 0:
                goals_summary.extend([
                    u'<br /><a class="continue-translation" href="%(url)s">' % {
                            'url': goal_url,
                        },
                    ungettext(u'<span class="caption">Next most important '
                              u'goal:</span> <span class="counter">%(num)d '
                              u'word left</span>',
                              u'<span class="caption">Next most important '
                              u'goal:</span> <span class="counter">%(num)d '
                              u'words left</span>',
                              goal_words,
                              {'num': goal_words, }),
                ])

    return {'is_dir': path_obj.is_dir,
            'goals_summary': u''.join(goals_summary),
            'summary_more_url': url_path_summary_more,
            'translate_url': path_obj.get_translate_url(state='all'),
            'incomplete_url': path_obj.get_translate_url(state='incomplete'),
            'suggestions_url': path_obj.get_translate_url(state='suggestions'),
            'critical_url': path_obj.get_critical_url(),
    }
Beispiel #8
0
def get_translate_actions(path_obj):
    """Return a list of translation action links to be displayed for each ``path_obj``."""
    goals_summary = []

    if path_obj.is_dir:
        # Putting the next import at the top of the file causes circular
        # import issues.
        from pootle_tagging.models import Goal

        pootle_path = path_obj.pootle_path
        goal = Goal.get_most_important_incomplete_for_path(path_obj)

        if goal is not None:
            goal_words = goal.get_incomplete_words_in_path(path_obj)
            goal_url = goal.get_translate_url_for_path(pootle_path,
                                                       state='incomplete')
            if goal_words > 0:
                goals_summary.extend([
                    u'<br /><a class="continue-translation" href="%(url)s">' %
                    {
                        'url': goal_url,
                    },
                    ungettext(
                        u'<span class="caption">Next most important '
                        u'goal:</span> <span class="counter">%(num)d '
                        u'word left</span>',
                        u'<span class="caption">Next most important '
                        u'goal:</span> <span class="counter">%(num)d '
                        u'words left</span>', goal_words, {
                            'num': goal_words,
                        }),
                ])

    return {
        'is_dir': path_obj.is_dir,
        'goals_summary': u''.join(goals_summary),
        'translate_url': path_obj.get_translate_url(state='all'),
        'incomplete_url': path_obj.get_translate_url(state='incomplete'),
        'suggestions_url': path_obj.get_translate_url(state='suggestions'),
        'critical_url': path_obj.get_critical_url(),
    }
Beispiel #9
0
def get_translate_actions(path_obj):
    """Return a list of translation action links to be displayed for each ``path_obj``."""
    goals_summary = []

    if path_obj.is_dir:
        # Putting the next import at the top of the file causes circular
        # import issues.
        from pootle_tagging.models import Goal

        pootle_path = path_obj.pootle_path
        goal = Goal.get_most_important_incomplete_for_path(path_obj)

        if goal is not None:
            goal_words = goal.get_incomplete_words_in_path(path_obj)
            goal_url = goal.get_translate_url_for_path(pootle_path, state="incomplete")
            if goal_words > 0:
                goals_summary.extend(
                    [
                        u'<br /><a class="continue-translation" href="%(url)s">' % {"url": goal_url},
                        ungettext(
                            u'<span class="caption">Next most important '
                            u'goal:</span> <span class="counter">%(num)d '
                            u"word left</span>",
                            u'<span class="caption">Next most important '
                            u'goal:</span> <span class="counter">%(num)d '
                            u"words left</span>",
                            goal_words,
                            {"num": goal_words},
                        ),
                    ]
                )

    return {
        "is_dir": path_obj.is_dir,
        "goals_summary": u"".join(goals_summary),
        "translate_url": path_obj.get_translate_url(state="all"),
        "incomplete_url": path_obj.get_translate_url(state="incomplete"),
        "suggestions_url": path_obj.get_translate_url(state="suggestions"),
        "critical_url": path_obj.get_critical_url(),
    }
Beispiel #10
0
def get_path_summary(path_obj):
    """Return a list of sentences to be displayed for each ``path_obj``."""
    goals_summary = []

    # Build URL for getting more summary information for the current path.
    url_path_summary_more = reverse('pootle-xhr-summary-more')

    if path_obj.is_dir:
        # Putting the next import at the top of the file causes circular
        # import issues.
        from pootle_tagging.models import Goal

        pootle_path = path_obj.pootle_path
        goal = Goal.get_most_important_incomplete_for_path(path_obj)

        if goal is not None:
            goal_words = goal.get_incomplete_words_in_path(path_obj)
            goal_url = goal.get_translate_url_for_path(pootle_path,
                                                       state='incomplete')
            if goal_words > 0:
                goals_summary.extend([
                    u'<br /><a class="path-incomplete" href="%(url)s">' % {
                            'url': goal_url,
                        },
                    ungettext(u'Next most important goal (%(num)d word left)',
                              u'Next most important goal (%(num)d words left)',
                              goal_words,
                              {'num': goal_words, }),
                ])

    return {'is_dir': path_obj.is_dir,
            'goals_summary': u''.join(goals_summary),
            'summary_more_url': url_path_summary_more,
            'translate_url': path_obj.get_translate_url(state='all'),
            'incomplete_url': path_obj.get_translate_url(state='incomplete'),
            'suggestions_url': path_obj.get_translate_url(state='suggestions')}
Beispiel #11
0
def get_path_summary(path_obj, path_stats, latest_action):
    """Returns a list of sentences to be displayed for each ``path_obj``."""
    summary = []
    incomplete = []
    suggestions = []

    if path_obj.is_dir:
        summary.append(
            ungettext("This folder has %(num)d word, %(percentage)d%% of "
                "which is translated.",
                "This folder has %(num)d words, %(percentage)d%% of "
                "which are translated.",
                path_stats['total']['words'],
                {
                    'num': path_stats['total']['words'],
                    'percentage': path_stats['translated']['percentage']
                })
        )
    else:
        summary.append(
            ungettext("This file has %(num)d word, %(percentage)d%% of "
                "which is translated.",
                "This file has %(num)d words, %(percentage)d%% of "
                "which are translated.",
                path_stats['total']['words'],
                {
                    'num': path_stats['total']['words'],
                    'percentage': path_stats['translated']['percentage']
                })
        )

    tp = path_obj.translation_project
    project = tp.project
    language = tp.language

    # Build URL for getting more summary information for the current path
    url_args = [language.code, project.code, path_obj.path]
    url_path_summary_more = reverse('tp.path_summary_more', args=url_args)

    summary.append(u''.join([
        ' <a id="js-path-summary" data-target="js-path-summary-more" '
        'href="%s">' % url_path_summary_more,
        force_unicode(_(u'Expand details')),
        '</a>'
    ]))


    if path_stats['untranslated']['words'] > 0 or path_stats['fuzzy']['words'] > 0:
        num_words = path_stats['untranslated']['words'] + path_stats['fuzzy']['words']
        incomplete.extend([
            u'<a class="path-incomplete" href="%(url)s">' % {
                    'url': path_obj.get_translate_url(state='incomplete')
                },
            ungettext(u'Continue translation (%(num)d word left)',
                      u'Continue translation (%(num)d words left)',
                      num_words,
                      {'num': num_words, }),
        ])

        if path_obj.is_dir:
            # Putting the next import at the top of the file causes circular
            # import issues.
            from pootle_tagging.models import Goal

            pootle_path = path_obj.pootle_path
            goal = Goal.get_most_important_incomplete_for_path(pootle_path)

            if goal is not None:
                goal_words = goal.get_incomplete_words_in_path(pootle_path)
                goal_url = goal.get_translate_url_for_path(pootle_path,
                                                           state='incomplete')
                incomplete.extend([
                    u'<br /><a class="path-incomplete" href="%(url)s">' % {
                            'url': goal_url,
                        },
                    ungettext(u'Next most important goal (%(num)d word left)',
                              u'Next most important goal (%(num)d words left)',
                              goal_words,
                              {'num': goal_words, }),
                ])
    else:
        incomplete.extend([
            u'<a class="path-incomplete" href="%(url)s">' % {
                    'url': path_obj.get_translate_url(state='all')
                },
            force_unicode(_('Translation is complete')),
        ])

    incomplete.append(u'</a>')


    if path_stats['suggestions'] > 0:
        suggestions.append(u'<a class="path-incomplete" href="%(url)s">' % {
            'url': path_obj.get_translate_url(state='suggestions')
        })
        suggestions.append(
            ungettext(u'Review suggestion (%(num)d left)',
                      u'Review suggestions (%(num)d left)',
                      path_stats['suggestions'],
                      {'num': path_stats['suggestions'], })
        )
        suggestions.append(u'</a>')

    return [u''.join(summary), latest_action, u''.join(incomplete),
            u''.join(suggestions)]