Skip to content

Commit 6f52f06

Browse files
authored
feat: Add Hebrew translations and RTL support (#49)
1 parent 7c41fa4 commit 6f52f06

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

Diff for: api/index.py

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def render():
3838
publish_timestamp = validate_int(request, "timestamp", default=0)
3939
duration_seconds = validate_int(request, "duration", default=0)
4040
lang = validate_lang(request, "lang", default="en")
41+
rtl = lang in ["ar", "he"]
4142
video_id = validate_video_id(request, "id")
4243
thumbnail = data_uri_from_url(f"https://i.ytimg.com/vi/{video_id}/mqdefault.jpg")
4344
views = fetch_views(video_id)
@@ -62,6 +63,7 @@ def render():
6263
thumbnail=thumbnail,
6364
duration=duration,
6465
duration_width=duration_width,
66+
rtl=rtl,
6567
),
6668
status=200,
6769
mimetype="image/svg+xml",

Diff for: api/locale/he.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
he:
2+
views: "%{number} צפיות"
3+
seconds-ago:
4+
one: "לפני שניה"
5+
many: "לפני %{count} שניות"
6+
minutes-ago:
7+
one: "לפני דקה"
8+
many: "לפני %{count} דקות"
9+
hours-ago:
10+
one: "לפני שעה"
11+
many: "לפני %{count} שעות"
12+
days-ago:
13+
one: "אתמול"
14+
many: "לפני %{count} ימים"
15+
months-ago:
16+
one: "לפני חודש"
17+
many: "לפני %{count} חודשים"
18+
years-ago:
19+
one: "לפני שנה"
20+
many: "לפני %{count} שנים"

Diff for: api/templates/main.svg

+2-2
Loading

Diff for: tests/test_app.py

+24
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,27 @@ def test_request_valid_params(client):
7171
# test timestamp
7272
timestamp_regex = re.compile(r"\d+ years ago")
7373
assert timestamp_regex.search(data) is not None
74+
75+
# test direction
76+
assert 'style="direction: ltr"' in data
77+
78+
79+
def test_request_right_to_left(client):
80+
params = {
81+
"id": "dQw4w9WgXcQ",
82+
"title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
83+
"timestamp": "1256450400",
84+
"lang": "he",
85+
}
86+
response = client.get(f"/?{urlencode(params)}")
87+
data = response.data.decode("utf-8")
88+
89+
# stats group should be 10 pixels from the right
90+
assert "translate(240, 195.0)" in data
91+
92+
# test direction
93+
assert 'style="direction: rtl"' in data
94+
95+
# test views
96+
views_regex = re.compile(r"\d+(?:\.\d)?[KMBT]? צפיות")
97+
assert views_regex.search(data) is not None

0 commit comments

Comments
 (0)