Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ node_modules/
/playwright/.auth/

# eslint
.eslintcache
.eslintcache
.pytest_cache/
__pycache__/
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "granda-front",
"version": "0.3.16",
"version": "0.3.17",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
Expand Down
1 change: 1 addition & 0 deletions scripts/i18ndiffer/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
6 changes: 6 additions & 0 deletions scripts/i18ndiffer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This utility can be used to add missing lines to i18n files while preserving their line-by-line structure.

Usage:
```bash
diff -y [file1] [file2] | uv run src/main.py [file1] [file2]
```
9 changes: 9 additions & 0 deletions scripts/i18ndiffer/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "i18ndiffer"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"pytest>=9.0.3",
]
Empty file.
47 changes: 47 additions & 0 deletions scripts/i18ndiffer/src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import re
import sys


def main():
path1, path2 = sys.argv[1], sys.argv[2]
diff_file: str = sys.stdin.read()
diff_lines = diff_file.split("\n")
lines1, lines2 = read_lines_from_files(path1, path2)
file1, file2 = insert_missing_lines(lines1, lines2, diff_lines)

with open(path1, "w") as f:
f.writelines(file1)
with open(path2, "w") as f:
f.writelines(file2)


def insert_missing_lines(lines1: list[str], lines2: list[str], diff_lines: list[str]):
for i in range(len(diff_lines)):
if diff_lines[i].endswith("<"):
lines2.insert(i, prepare_placeholder_from(lines1[i]))
elif diff_lines[i].lstrip().startswith(">"):
lines1.insert(i, prepare_placeholder_from(lines2[i]))

return lines1, lines2


def read_lines_from_files(path1, path2):
lines1 = []
lines2 = []

with open(path1, "r") as f1:
lines1 = f1.readlines()
f1.close()
with open(path2, "r") as f2:
lines2 = f2.readlines()
f2.close()
return lines1, lines2


def prepare_placeholder_from(line: str) -> str:
capture_key_without_value_pattern = r'(\s*".+":\s*")(.+".*)'
return re.sub(capture_key_without_value_pattern, r"\1[CHANGE ME!] \2", line)


if __name__ == "__main__":
main()
Empty file.
98 changes: 98 additions & 0 deletions scripts/i18ndiffer/test/test_diffing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import re

from src.main import insert_missing_lines, prepare_placeholder_from


def test_preparing_placeholders_basic():
assert (
prepare_placeholder_from(' "msg_handle_empty": "Handle must not be empty.",')
== ' "msg_handle_empty": "[CHANGE ME!] Handle must not be empty.",'
)


def test_preparing_placeholders_with_curly_braces():
assert (
prepare_placeholder_from(' "error_message": "Details: {message}"')
== ' "error_message": "[CHANGE ME!] Details: {message}"'
)


def test_instert_lines_right_to_left():
diff_file = [
' "debate_details": { "debate_details": {',
' "unconfigured_debate": "Debata bez tezy" | "unconfigured_debate": "Debate without a motion",',
' > "proceed_to_debate": "Proceed to Debate!",',
' > "marshal_panel": "Marshal Panel"',
" > },",
' > "create_tournament": {',
' > "title": "Create Tournament",',
' > "full_name": "Full name",',
]

file1 = [
' "debate_details": {',
' "unconfigured_debate": "Debata bez tezy"',
" }",
"}",
]
file2 = [
' "debate_details": {',
' "unconfigured_debate": "Debate without a motion",',
' "proceed_to_debate": "Proceed to Debate!",',
' "marshal_panel": "Marshal Panel"',
" },",
' "create_tournament": {',
' "title": "Create Tournament",',
' "full_name": "Full name",',
' "short_name": "Short name",',
' "close": "Close",',
' "full_name_placeholder": "(Required)"',
" },",
]

file1, file2 = insert_missing_lines(file1, file2, diff_file)

empty_value_pattern = r'(\s*".+":\s*"".*)'

value_to_change_pattern = r'(\s*".+":\s*"\[CHANGE ME!\].+".*)'
for line in file1:
if not re.findall(r"debate|{|}", line):
assert re.match(value_to_change_pattern, line)


def test_insert_lines_left_to_right():
diff_file = [
' "metadata": { "metadata": {',
' "title": "granda: Debate Tournament Planner", | "title": "granda: Zaplanuj swój turniej debat",',
' "description": "Computer aided debate tournament organizi | "description": "Komputerowo wspomagane planowanie turniej',
" }, <",
' "generic": { <',
' "error": "Error", <',
' "error_loading_content": "An error occurred while loading <',
' "error_message": "Details: {message}" <',
" }, },",
]
file1 = [
' "metadata": {',
' "title": "granda: Debate Tournament Planner",',
' "description": "Computer aided debate tournament organizing experience enrichment."',
" },",
' "generic": {',
' "error": "Error",',
' "error_loading_content": "An error occurred while loading the content.",',
' "error_message": "Details: {message}"',
" },",
]
file2 = [
' "metadata": {',
' "title": "granda: Zaplanuj swój turniej debat",',
' "description": "Komputerowo wspomagane planowanie turniejów debat."',
" },",
]

file1, file2 = insert_missing_lines(file1, file2, diff_file)

value_to_change_pattern = r'(\s*".+":\s*"\[CHANGE ME!\].+".*)'
for line in file2:
if line.__contains__("error"):
assert re.match(value_to_change_pattern, line)
75 changes: 75 additions & 0 deletions scripts/i18ndiffer/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 12 additions & 24 deletions src/app/[locale]/t/[path]/debates/[debate_id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,41 +118,29 @@ export default async function DebateDetailsPage({
<div className="mx-auto max-w-[1252px] min-h-[746px] bg-[#070707] p-6 text-white overflow-hidden">
<header className="flex justify-between items-center py-4">
<h1 className="text-2xl font-semibold opacity-75 max-w-[686px]">
{" "}
{motion}{" "}
{motion}
</h1>
<div className="size-[26px] opacity-50 italic">ret</div>
</header>

<div className="py-2 mb-6">
<div className="text-[22px] font-semibold text-white/50 opacity-75">
{" "}
{/*{phaseName} | {roundName}{" "}*/}
</div>
</div>
<div className="py-2 mb-6"></div>

<div className="grid grid-cols-2 gap-[20px]">
<div className="flex flex-col items-center gap-[20px]">
<GenericComponent title="Marshal">
<div>
{" "}
Information about assigned Marshal will be presented here.{" "}
</div>
<GenericComponent title={t("time_and_place_info.title")}>
<div>{t("time_and_place_info.placeholder_text")}</div>
</GenericComponent>

<GenericComponent title={t("teams_info.title")}>
<div>{t("teams_info.placeholder_text")}</div>
</GenericComponent>

<GenericComponent title="Judges">
<div>
{" "}
Information about assigned Judges will be presented here.{" "}
</div>
<GenericComponent title={t("marshal_info.title")}>
<div>{t("marshal_info.placeholder_text")}</div>
</GenericComponent>

<GenericComponent title="Teams">
<div>
{" "}
Information about time and place of the debate will be presented
here.{" "}
</div>
<GenericComponent title={t("judges_info.title")}>
<div>{t("judges_info.placeholder_text")}</div>
</GenericComponent>
</div>

Expand Down
1 change: 0 additions & 1 deletion src/components/tournament/MarshalPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function MarshalPanel({ motion }: MarshalPanelProps) {
return (
<GenericComponent
title={t("marshal_panel")}
showActions
className="w-full max-w-[760px]"
>
<a
Expand Down
Loading
Loading