Skip to content

Commit 13b7707

Browse files
RobPasMuesneakers-the-rat
authored andcommitted
Update _ext/translation_graph.py
Co-authored-by: Jonny Saunders <sneakers-the-rat@protonmail.com>
1 parent dc7c20e commit 13b7707

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

_ext/translation_graph.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
from pathlib import Path
22
import json
3+
from typing import TypeAlias, TypedDict, Annotated as A
34

45
from docutils import nodes
56
from docutils.parsers.rst import Directive
67
import plotly.graph_objects as go
78
from plotly.offline import plot
89

10+
11+
class ModuleStats(TypedDict):
12+
total: int
13+
translated: int
14+
fuzzy: int
15+
untranslated: int
16+
percentage: float
17+
18+
TranslationStats: TypeAlias = dict[A[str, "locale"], dict[A[str, "module"], ModuleStats]]
19+
20+
921
class TranslationGraph(Directive):
1022
# Tells Sphinx that this directive can be used in the document body
1123
# and has no content
@@ -15,7 +27,7 @@ def run(self):
1527
# Read the JSON file containing translation statistics
1628
json_path = Path(__file__).parent.parent / "_static" / "translation_stats.json"
1729
with json_path.open("r") as f:
18-
data = json.load(f)
30+
data: TranslationStats = json.load(f)
1931

2032
# Collect all module names -- iterates over the JSON data in 2 levels
2133
all_modules = {module for stats in data.values() for module in stats}

0 commit comments

Comments
 (0)