Skip to content

Commit 2563fca

Browse files
authored
feat: RTL support (#388)
1 parent f884c97 commit 2563fca

File tree

16 files changed

+41
-34
lines changed

16 files changed

+41
-34
lines changed

internal/api/v1.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ type LobbyData struct {
474474
game.SettingBounds
475475
game.EditableLobbySettings
476476
*GameConstants
477+
IsWordpackRtl bool
477478
}
478479

479480
// CreateLobbyData creates a ready to use LobbyData object containing data
@@ -483,6 +484,7 @@ func CreateLobbyData(cfg *config.Config, lobby *game.Lobby) *LobbyData {
483484
SettingBounds: cfg.LobbySettingBounds,
484485
EditableLobbySettings: lobby.EditableLobbySettings,
485486
GameConstants: GameConstantsData,
487+
IsWordpackRtl: lobby.IsWordpackRtl,
486488
}
487489
}
488490

internal/frontend/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ type errorPageData struct {
162162
// ErrorMessage displayed on the page.
163163
ErrorMessage string
164164

165-
Translation translations.Translation
165+
Translation *translations.Translation
166166
Locale string
167167
}
168168

internal/frontend/index.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var indexJsRaw string
3030
type indexJsData struct {
3131
*BasePageConfig
3232

33-
Translation translations.Translation
33+
Translation *translations.Translation
3434
Locale string
3535
}
3636

@@ -168,7 +168,7 @@ type IndexPageData struct {
168168
config.LobbySettingDefaults
169169
game.SettingBounds
170170

171-
Translation translations.Translation
171+
Translation *translations.Translation
172172
Locale string
173173
Errors []string
174174
Languages map[string]string

internal/frontend/lobby.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ type lobbyPageData struct {
1616
*BasePageConfig
1717
*api.LobbyData
1818

19-
Translation translations.Translation
19+
Translation *translations.Translation
2020
Locale string
2121
}
2222

2323
type lobbyJsData struct {
2424
*BasePageConfig
2525
*api.GameConstants
2626

27-
Translation translations.Translation
27+
Translation *translations.Translation
2828
Locale string
2929
}
3030

@@ -132,7 +132,7 @@ func (handler *SSRHandler) ssrEnterLobbyNoChecks(
132132
}
133133
}
134134

135-
func determineTranslation(r *http.Request) (translations.Translation, string) {
135+
func determineTranslation(r *http.Request) (*translations.Translation, string) {
136136
languageTags, _, err := language.ParseAcceptLanguage(r.Header.Get("Accept-Language"))
137137
if err == nil {
138138
for _, languageTag := range languageTags {

internal/frontend/templates/error.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{template "favicon-decl" .}}
1212
</head>
1313

14-
<body>
14+
<body {{if eq .Translation.IsRtl true}} dir="rtl" {{end}}>
1515
<div id="app">
1616
<div class="error-pane-wrapper">
1717
<div class="error-pane">

internal/frontend/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<link rel="prefetch" href='{{.RootPath}}/resources/{{.WithCacheBust "clock.svg"}}' />
3232
</head>
3333

34-
<body>
34+
<body {{if eq .Translation.IsRtl true}} dir="rtl" {{end}}>
3535
<div id="app">
3636
<div class="home">
3737
<img id="logo" src='{{.RootPath}}/resources/{{.WithCacheBust "logo.svg"}}' alt="Scribble.rs logo">

internal/frontend/templates/lobby.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<link rel="prefetch" href='{{.RootPath}}/resources/{{.WithCacheBust "no-sound.svg"}}' />
2020
</head>
2121

22-
<body>
22+
<body {{if eq .Translation.IsRtl true}} dir="rtl" {{end}}>
2323
<div id="app">
2424
<noscript><span class="noscript">{{.Translation.Get "requires-js"}}</span></noscript>
2525

@@ -103,9 +103,8 @@
103103
</div>
104104
</div>
105105
</div>
106-
<div id="word-container"></div>
106+
<div id="word-container" {{if eq .IsWordpackRtl true}} dir="rtl" {{else}} dir="ltr" {{end}}></div>
107107
</div>
108-
109108
<div id="time-left">
110109
<img src='{{.RootPath}}/resources/{{.WithCacheBust "clock.svg"}}' class="header-button-image" />
111110
<div id="time-left-value"></div>

internal/frontend/templates/robot.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<link rel="icon" type="image/png" href='{{.RootPath}}/resources/{{.WithCacheBust "favicon_96.png"}}' />
2424
</head>
2525

26-
<body>
26+
<body {{if eq .Translation.IsRtl true}} dir="rtl" {{end}}>
2727
<div id="app">
2828
<h1 class="error-title">(◕︿◕✿)</h1>
2929
<h2 class="error-message">You can NOT join the lobby with this browser.</h2>

internal/game/data.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ type Lobby struct {
9191

9292
mutex sync.Mutex
9393

94+
IsWordpackRtl bool
95+
9496
WriteObject func(*Player, any) error
9597
WritePreparedMessage func(*Player, *gws.Broadcaster) error
9698
}

internal/game/lobby.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,8 @@ func CreateLobby(
972972
// will most likely be faulty.
973973
lobby.lowercaser = WordlistData[chosenLanguage].Lowercaser()
974974

975+
lobby.IsWordpackRtl = WordlistData[chosenLanguage].IsRtl
976+
975977
// customWords are lowercased afterwards, as they are direct user input.
976978
if len(customWords) > 0 {
977979
for customWordIndex, customWord := range customWords {

0 commit comments

Comments
 (0)