Add the Dark version to the data.js file and render it in the webpage.

This commit is contained in:
Benoit Marty
2024-03-08 12:07:26 +01:00
parent 4c062a6188
commit c7fa94e58f
3 changed files with 1001 additions and 978 deletions

View File

@@ -100,21 +100,34 @@ def detectRecordedLanguages():
return sorted([f for f in os.listdir("screenshots") if len(f) == 2])
def computeDarkFileName(lightFileName):
if "-Day_0" in lightFileName:
return lightFileName.replace("-Day_0", "-Night_1")
match = re.match("(.*)-Day-(\d+)_(\d+)(.*)", lightFileName, flags=re.ASCII)
if match:
return match.group(1) + "-Night-" + match.group(2) + "_" + str((int(match.group(3)) + 1)) + match.group(4)
return ""
def generateJavascriptFile():
__doc__ = "Generate a javascript file to load the screenshots"
print("Generating javascript file...")
languages = detectRecordedLanguages()
# First item is the list of languages, adding "en" at the beginning
data = [["en"] + languages]
# First item is the list of languages, adding "en" and "en-dark" at the beginning
data = [["en", "en-dark"] + languages]
files = sorted(
os.listdir("tests/uitests/src/test/snapshots/images/"),
key=lambda file: file[file.find("_", 6):],
)
for file in files:
# Continue if file contains "-Night", keep only light screenshots (maybe the night screenshots could be on the second column?)
# Continue if file contains "-Night", keep only light screenshots
if "-Night" in file:
continue
dataForFile = [file[:-4]]
darkFile = computeDarkFileName(file)
if os.path.exists("./tests/uitests/src/test/snapshots/images/" + darkFile):
dataForFile.append(darkFile[:-4])
else:
dataForFile.append("")
for l in languages:
simpleFile = file[:3] + "T" + file[4:-7] + l + file[-5:-4]
translatedFile = "./screenshots/" + l + "/" + simpleFile + ".png"