-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate HTML summary of localization status (#2071)
- Loading branch information
Showing
5 changed files
with
109 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import json | ||
|
||
|
||
def main(): | ||
script_path = os.path.dirname(__file__) | ||
root_path = os.path.abspath(os.path.join(script_path, os.pardir, os.pardir)) | ||
|
||
with open(os.path.join(root_path, ".github", "stats.json")) as f: | ||
stats = json.load(f) | ||
|
||
with open(os.path.join(root_path, ".github", "templates", "index.html")) as f: | ||
html_template = f.read() | ||
|
||
body_localized = [] | ||
body_not_localized = [] | ||
for file_name, file_stats in stats.items(): | ||
if file_stats["count"] > 0: | ||
body_localized.append( | ||
f""" | ||
<tr> | ||
<td>{file_name}</td> | ||
<td>{file_stats['count']}</td> | ||
<td>{', '.join(file_stats['locales'])}</td> | ||
</tr>""" | ||
) | ||
else: | ||
body_not_localized.append( | ||
f""" | ||
<tr> | ||
<td>{file_name}</td> | ||
</tr>""" | ||
) | ||
|
||
html_template = html_template.replace( | ||
"%TABLEBODYLOCALIZED%", "\n".join(body_localized) | ||
).replace("%TABLEBODYNOTLOCALIZED%", "\n".join(body_not_localized)) | ||
|
||
os.makedirs(os.path.join(root_path, "docs"), exist_ok=True) | ||
with open(os.path.join(root_path, "docs", "index.html"), "w") as f: | ||
f.write(html_template) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Legal Documents — Localization Summary</title> | ||
<meta charSet="utf-8" /> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" | ||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" | ||
crossorigin="anonymous"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h1>Localized Documents</h1> | ||
<table class="table table-striped table-bordered table-sm"> | ||
<thead class="table-dark"> | ||
<tr> | ||
<th>Filename</th> | ||
<th># Locales</th> | ||
<th>Locales</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
%TABLEBODYLOCALIZED% | ||
</tbody> | ||
</table> | ||
|
||
<h1>English-only Documents</h1> | ||
<table class="table table-striped table-bordered table-sm"> | ||
<thead class="table-dark"> | ||
<tr> | ||
<th>Filename</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
%TABLEBODYNOTLOCALIZED% | ||
</tbody> | ||
</table> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters