Skip to content

Commit

Permalink
i18n: support for languageDirection #733
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Nov 28, 2023
1 parent 42b604b commit 9227dfd
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions exampleSite/config/_default/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ title = "Hugo Relearn Theme"
title = "Cap'n Hugo Relearrrn Theme"
weight = 2
languageCode = "art-pir"
languageDirection = "rtl"
languageName = "Arrr! ☠ Pirrrates ☠"
# Language dependend settings:
# Use case https://gohugo.io/content-management/multilingual/#translation-by-content-directory
Expand Down
2 changes: 1 addition & 1 deletion i18n/pir.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Reading-direction]
other = "rtl"
other = "ltr"

[Search]
other = "Searrrch"
Expand Down
2 changes: 1 addition & 1 deletion layouts/404.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- $outputFormat := partial "output-format.hugo" . }}
<html lang="{{ .Page.Language.LanguageCode | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
<html lang="{{ .Page.Language.LanguageCode | default "en" }}" dir="{{ .Page.Language.LanguageDirection | default (T "Reading-direction") | default "ltr" }}">
<head>
{{- partial "meta.html" . }}
{{- $title := .Title }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{- errorf "The Relearn theme requires Hugo %s or later" $hugoVersion }}
{{- end }}
{{- end }}
<html lang="{{ .Page.Language.LanguageCode | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
<html lang="{{ .Page.Language.LanguageCode | default "en" }}" dir="{{ .Page.Language.LanguageDirection | default (T "Reading-direction") | default "ltr" }}">
<head>
{{- partial "meta.html" . }}
{{- $page := . }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/topbar/button/next.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
{{- if and (or (eq $outputFormat "html") (eq $outputFormat "searchpage")) $showPrevNext }}
{{- $endarrow := "🡒" }}
{{- if eq (T "Reading-direction" | default "ltr") "rtl" }}
{{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }}
{{- $endarrow = "🡐" }}
{{- end }}
{{- $next := "" }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/topbar/button/prev.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{- $showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
{{- if and (or (eq $outputFormat "html") (eq $outputFormat "searchpage")) $showPrevNext }}
{{- $startarrow := "🡐" }}
{{- if eq (T "Reading-direction" | default "ltr") "rtl" }}
{{- if eq (.Language.LanguageDirection | default (T "Reading-direction") | default "ltr") "rtl" }}
{{- $startarrow = "🡒" }}
{{- end }}
{{- $prev := "" }}
Expand Down

0 comments on commit 9227dfd

Please sign in to comment.