Example #1
0
def progress_bar(total, fuzzy, translated):
    if not total:
        fuzzy_frac = translated_frac = untranslated_frac = 0
        cldrformat = "0%"
    else:
        untranslated = total - translated - fuzzy
        untranslated_frac = float(untranslated) / total
        fuzzy_frac = float(fuzzy) / total
        translated_frac = float(translated) / total
        cldrformat = "#,##0.0%"
    return dict(
        untranslated_percent_display=formatter.percent(untranslated_frac, cldrformat),
        fuzzy_percent_display=formatter.percent(fuzzy_frac, cldrformat),
        translated_percent_display=formatter.percent(translated_frac, cldrformat),
        untranslated_bar=round(untranslated_frac * 100, 1),
        fuzzy_bar=round(fuzzy_frac * 100, 1),
        translated_bar=round(translated_frac * 100, 1),
    )
Example #2
0
def progress_bar(total, fuzzy, translated):
    if not total:
        fuzzy_frac = translated_frac = untranslated_frac = 0
        cldrformat = "0%"
    else:
        untranslated = total - translated - fuzzy
        untranslated_frac = float(untranslated) / total
        fuzzy_frac = float(fuzzy) / total
        translated_frac = float(translated) / total
        cldrformat = "#,##0.0%"
    return dict(
        untranslated_percent_display=formatter.percent(untranslated_frac,
                                                       cldrformat),
        fuzzy_percent_display=formatter.percent(fuzzy_frac, cldrformat),
        translated_percent_display=formatter.percent(translated_frac,
                                                     cldrformat),
        untranslated_bar=round(untranslated_frac * 100, 1),
        fuzzy_bar=round(fuzzy_frac * 100, 1),
        translated_bar=round(translated_frac * 100, 1))
Example #3
0
def progress_bar(total, fuzzy, translated):
    if not total:
        fuzzy_frac = translated_frac = untranslated_frac = 0
        cldrformat = "0%"
    else:
        untranslated = total - translated - fuzzy
        untranslated_frac = float(untranslated) / total
        fuzzy_frac = float(fuzzy) / total
        translated_frac = float(translated) / total
        cldrformat = "#,##0.0%"
    untranslated_display = (_("{percentage} untranslated")).format(
        percentage=formatter.percent(untranslated_frac, cldrformat))
    fuzzy_display = (_("{percentage} needs work")).format(
        percentage=formatter.percent(fuzzy_frac, cldrformat))
    translated_display = (_("{percentage} translated")).format(
        percentage=formatter.percent(translated_frac, cldrformat))
    return dict(untranslated_percent_display=untranslated_display,
                fuzzy_percent_display=fuzzy_display,
                translated_percent_display=translated_display,
                untranslated_bar=round(untranslated_frac * 100, 1),
                fuzzy_bar=round(fuzzy_frac * 100, 1),
                translated_bar=round(translated_frac * 100, 1))
Example #4
0
def progress_bar(total, fuzzy, translated):
    if not total:
        fuzzy_frac = translated_frac = untranslated_frac = 0
        cldrformat = "0%"
    else:
        untranslated = total - translated - fuzzy
        untranslated_frac = float(untranslated)/total
        fuzzy_frac = float(fuzzy)/total
        translated_frac = float(translated)/total
        cldrformat = "#,##0.0%"
    untranslated_display = (_("{percentage} untranslated")).format(
        percentage=formatter.percent(untranslated_frac, cldrformat))
    fuzzy_display = (_("{percentage} needs work")).format(
        percentage=formatter.percent(fuzzy_frac, cldrformat))
    translated_display = (_("{percentage} translated")).format(
        percentage=formatter.percent(translated_frac, cldrformat))
    return dict(
        untranslated_percent_display=untranslated_display,
        fuzzy_percent_display=fuzzy_display,
        translated_percent_display=translated_display,
        untranslated_bar=round(untranslated_frac * 100, 1),
        fuzzy_bar=round(fuzzy_frac * 100, 1),
        translated_bar=round(translated_frac * 100, 1))
Example #5
0
 def states(self):
     states = get_translation_states(self.object)
     stats = self.stats
     for state in states:
         if state["state"] == "untranslated":
             if stats["total"]:
                 stats[state["state"]] = state["count"] = (
                     stats["total"] - stats["fuzzy"] - stats["translated"])
         else:
             stats[state["state"]] = state["count"] = stats[state["state"]]
         if state.get("count"):
             state["count_display"] = formatter.number(state["count"])
             state["percent"] = round(
                 float(state["count"]) / stats["total"], 3)
             state["percent_display"] = formatter.percent(
                 state["percent"], "#,##0.0%")
     return states
Example #6
0
 def states(self):
     states = get_translation_states(self.object)
     stats = self.stats
     for state in states:
         if state["state"] == "untranslated":
             if stats["total"]:
                 stats[state["state"]] = state["count"] = (
                     stats["total"] - stats["fuzzy"] - stats["translated"])
         else:
             stats[state["state"]] = state["count"] = stats[state["state"]]
         if state.get("count"):
             state["count_display"] = formatter.number(state["count"])
             state["percent"] = round(
                 float(state["count"]) / stats["total"], 3)
             state["percent_display"] = formatter.percent(
                 state["percent"], "#,##0.0%")
     return states
Example #7
0
def test_percent_format(language, expected):
    with override(language):
        assert percent(10.005, '#,##0.0%') == expected
Example #8
0
def test_percent(language, expected):
    with override(language):
        assert percent(10.005) == expected