i18n: support RTL in content #357

This commit is contained in:
Sören Weber 2022-11-01 02:00:50 +01:00
parent 7e4e587ad0
commit 0ac97ba47e
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
39 changed files with 189 additions and 37 deletions

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "rtl"
[Search]
other = "البحث"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Suchen"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Search"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Buscar"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Etsi"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Rechercher"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "खोजे"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Telusuri"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Cerca"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "検索"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "검색"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Zoeken"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Searrrch"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Szukaj"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Procurar"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Поиск"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Ara"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "Tìm kiếm"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "搜索"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "搜尋"

View file

@ -1,3 +1,6 @@
[Reading-direction]
other = "ltr"
[Search]
other = "搜索"

View file

@ -1,6 +1,6 @@
{{- partial "page-meta.hugo" . }}
<!DOCTYPE html>
<html lang="{{ .Page.Language | default "en" }}">
<html lang="{{ .Page.Language | default "en" }}" dir="ltr">
<head>
{{- partial "meta.html" . }}
{{- .Scratch.Add "title" "" }}
@ -28,12 +28,14 @@
<div id="sidebar-overlay"></div>
<main id="body-inner" class="chapter" tabindex="-1">
<div class="flex-block-wrapper">
<h1>{{ T "title-404" }}</h1>
<p></p>
<p>{{ T "message-404" }}</p>
<p></p>
<p><a href="{{ "" | relLangURL }}">{{ T "Go-to-homepage" }}</a></p>
<p><img src="{{ "images/gopher-404.jpg" | relURL }}" style="width:50%" alt="Page not found!"></p>
<article class="default" dir="{{ T "Reading-direction" | default "ltr" }}">>
<h1>{{ T "title-404" }}</h1>
<p></p>
<p>{{ T "message-404" }}</p>
<p></p>
<p><a href="{{ "" | relLangURL }}">{{ T "Go-to-homepage" }}</a></p>
<p><img src="{{ "images/gopher-404.jpg" | relURL }}" style="width:50%" alt="Page not found!"></p>
</article>
</div>
</main>
</div>

View file

@ -1,6 +1,6 @@
{{- partial "page-meta.hugo" . }}
{{- partial "header.html" . }}
<article>
<article dir="{{ T "Reading-direction" | default "ltr" }}">
<h1>{{ if eq .Kind "term" }}{{ .Data.Singular | humanize }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Title }}</h1>
<ul>

View file

@ -1,7 +1,7 @@
{{- $page := .page }}
{{- $content := .content }}
{{- with $page }}
<article class="chapter">
<article class="chapter" dir="{{ T "Reading-direction" | default "ltr" }}">
{{ partial "heading-pre.html" . }}<div class="article-subheading">{{ T "Chapter" .Params.Weight }}</div>
<h1>{{ .Title }}</h1>{{ partial "heading-post.html" . }}

View file

@ -1,7 +1,7 @@
{{- $page := .page }}
{{- $content := .content }}
{{- with $page }}
<article class="default">
<article class="default" dir="{{ T "Reading-direction" | default "ltr" }}">
{{ partial "heading-pre.html" . }}<h1>{{ .Title }}</h1>{{ partial "heading-post.html" . }}
{{ $content | safeHTML }}

View file

@ -1,7 +1,7 @@
{{- $page := .page }}
{{- $content := .content }}
{{- with $page }}
<article class="chapter deprecated">
<article class="chapter deprecated" dir="{{ T "Reading-direction" | default "ltr" }}">
{{ $content | safeHTML }}
<footer class="footline">

View file

@ -1,7 +1,7 @@
{{- $page := .page }}
{{- $content := .content }}
{{- with $page }}
<article class="home deprecated">
<article class="home deprecated" dir="{{ T "Reading-direction" | default "ltr" }}">
{{ $content | safeHTML }}
<footer class="footline">

View file

@ -1,7 +1,7 @@
{{- $page := .page }}
{{- $content := .content }}
{{- with $page }}
<article class="home">
<article class="home" dir="{{ T "Reading-direction" | default "ltr" }}">
{{ partial "heading-pre.html" . }}<h1>{{ .Title }}</h1>{{ partial "heading-post.html" . }}
{{ $content | safeHTML }}

View file

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="{{ .Page.Language | default "en" }}">
<html lang="{{ .Page.Language | default "en" }}" dir="ltr">
<head>
{{- partial "meta.html" . }}
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}

View file

@ -5,6 +5,7 @@
{{- if eq (printf "%T" $expanded) "string" }}
{{- $expanded = (eq $expanded "true") }}
{{- end }}
{{- $direction := T "Reading-direction" | default "ltr" }}
{{- with $context }}
<div class="expand
{{- if $expanded }} expand-expanded{{ end -}}
@ -12,7 +13,8 @@
{{/* things are getting complicated when search tries to open the expand box while jquery sets the display CSS on the element */}}{{ "" -}}
<a class="expand-label" onclick="$t=$(this); if($t.parent('.expand-expanded.expand-marked').length){ $t.next().css('display','none') }else if($t.parent('.expand-marked').length){ $t.next().css('display','block') }else{ $t.next('.expand-content').slideToggle(100); } $t.parent().toggleClass('expand-expanded');">
<i class="fas fa-chevron-down"></i>
<i class="fas fa-chevron-right"></i>
<i class="fas fa-chevron-left expand-rtl direction-{{ $direction }}"></i>
<i class="fas fa-chevron-right expand-ltr direction-{{ $direction }}"></i>
{{ $title }}
</a>
<div class="expand-content" style="display:

View file

@ -1,6 +1,7 @@
{{- $context := .context }}
{{- $tabs := .tabs | default slice }}
{{- $groupid := .groupid | default "default" }}
{{- $direction := T "Reading-direction" | default "ltr" }}
{{- with $context }}
<div class="tab-panel">
<div class="tab-nav">
@ -8,7 +9,7 @@
<button
data-tab-item="{{ .name }}"
data-tab-group="{{ $groupid }}"
class="tab-nav-button {{ cond (eq $idx 0) "active" ""}}"
class="tab-nav-button direction-{{ $direction }} {{ cond (eq $idx 0) "active" ""}}"
onclick="switchTab('{{ $groupid }}','{{ .name }}')"
><span>{{ .name }}</span></button>
{{- end }}

View file

@ -1,6 +1,6 @@
{{- if .Params.tags }}
<div class="tags">
<div class="tags" dir="{{ T "Reading-direction" | default "ltr" }}">
{{- range sort .Params.tags }}
<a class="tag-link" href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a>
{{- end }}

View file

@ -1,6 +1,6 @@
<div class="default-animation progress">
<div class="wrapper">
<div class="toc-wrapper" dir="{{ T "Reading-direction" | default "ltr" }}">
{{ .TableOfContents }}
</div>
</div>

View file

@ -27,6 +27,11 @@ code.copy-to-clipboard-code {
border-top-right-radius: 2px;
border-right-width: 1px;
}
span > code.copy-to-clipboard-code {
border-end-end-radius: 2px;
border-start-end-radius: 2px;
border-inline-end-width: 1px;
}
pre {
border: 1px solid #ccc;
}

View file

@ -1,4 +1,50 @@
@media all and (-ms-high-contrast:none) {
/* turn off LTR support as it is dependend on CSS properties that aren't supported by IE11 */
article,
.toc-wrapper,
.tags {
direction: ltr;
}
blockquote {
border-left: 10px solid rgba( 134, 134, 134, .4 );
padding-left: 0.85rem;
}
blockquote cite {
text-align: right;
}
th {
text-align: left;
}
.disableInlineCopyToClipboard span > code.copy-to-clipboard-code {
border-bottom-right-radius: 2px;
border-top-right-radius: 2px;
border-right-width: 1px;
}
.anchor {
margin-left: .66em;
}
div.attachments .box-content {
padding-left: 1.75rem;
}
.expand > .expand-label > .expand-rtl.direction-rtl {
display: none;
}
.expand > .expand-label > .expand-ltr.direction-rtl {
display: inline-block;
}
.expand.expand-expanded > .expand-label > .fa-chevron-right {
display: none;
}
#body .tab-nav-button {
margin-left: 4px;
}
#body .tab-nav-button.direction-rtl {
float: left;
}
#body .tab-nav-button:first-child {
margin-left: 9px;
}
/* set default colors as in variant.css for IE11 */
body {
background-color: #ffffff; /* var(--MAIN-BG-color) */
@ -416,9 +462,7 @@
background-color: #ffffff !important; /* var(--MAIN-BG-color) */
border-bottom-color: #ffffff !important; /* var(--MAIN-BG-color) */
}
}
@media all and (-ms-high-contrast:none) {
/* set further styles to fix broken stuff in IE11 */
/* turn off animiation in IE because this causes the menu

View file

@ -174,7 +174,7 @@ th, td {
padding: 0.425rem 0; }
th {
text-align: left; }
text-align: start; }
body {
font-size: 1rem;
@ -214,7 +214,7 @@ ul, ol {
blockquote {
margin: 1.5rem 0;
padding-left: 0.85rem; }
padding-inline-start: 0.85rem; }
cite {
display: block;

View file

@ -12,12 +12,16 @@
font-size: .9rem;
font-weight: 500;
line-height: 1.42857143;
margin-left: 4px;
margin-inline-start: 4px;
padding: 6px 12px;
position: relative;
}
#body .tab-nav-button.direction-rtl {
float: right;
}
#body .tab-nav-button:first-child {
margin-left: 9px;
margin-inline-start: 9px;
}
#body .tab-nav-button:not(.active) {
border-bottom-color: rgba( 134, 134, 134, .1 );

View file

@ -406,7 +406,7 @@ h2, h3, .article-subheading, h4, h5, h6 {
}
blockquote {
border-left: 10px solid rgba( 134, 134, 134, .4 );
border-inline-start: 10px solid rgba( 134, 134, 134, .4 );
}
blockquote p {
@ -421,7 +421,7 @@ blockquote cite {
font-weight: bold;
opacity: .5;
padding-top: .5em;
text-align: right;
text-align: end;
}
/* colored boxes */
@ -461,7 +461,7 @@ div.box > .box-content {
div.attachments .box-content {
display: block;
margin: 0;
padding-left: 1.75rem;
padding-inline-start: 1.75rem;
}
/* Children shortcode */
@ -536,6 +536,15 @@ code.copy-to-clipboard-code {
border-right-width: 0;
}
span > code.copy-to-clipboard-code {
border-bottom-right-radius: 2px;
border-top-right-radius: 2px;
border-right-width: 1px;
border-end-end-radius: 0;
border-start-end-radius: 0;
border-inline-end-width: 0;
}
pre {
border-radius: 2px;
border-style: solid;
@ -546,12 +555,18 @@ pre {
padding: 1rem;
}
pre.pre-code,
pre:has( code ){
/* the :has() operator isn't available in FF yet, so we patch this by JS */
direction: ltr;
}
pre code {
background-color: inherit;
border: 0;
color: inherit;
-webkit-print-color-adjust: economy;
color-adjust: economy;
border: 0;
font-size: 15px;
margin: 0;
padding: 0;
@ -924,6 +939,13 @@ span.nav i{
padding-left: 22px;
}
span > .copy-to-clipboard-button {
border-start-start-radius: 0;
border-start-end-radius: 2px;
border-end-end-radius: 2px;
border-end-start-radius: 0;
}
.copy-to-clipboard-button > i {
font-size: 92%;
font-weight: 500;
@ -935,7 +957,7 @@ span.nav i{
padding-right: 5px;
}
pre .copy-to-clipboard-button {
pre > .copy-to-clipboard-button {
background-color: rgba( 160, 160, 160, .2 );
border-radius: 2px;
border-style: solid;
@ -946,14 +968,14 @@ pre .copy-to-clipboard-button {
top: 4px;
}
.disableInlineCopyToClipboard :not(pre) > code.copy-to-clipboard-code + span.copy-to-clipboard-button {
.disableInlineCopyToClipboard span > code.copy-to-clipboard-code + span.copy-to-clipboard-button {
display: none;
}
.disableInlineCopyToClipboard :not(pre) > code.copy-to-clipboard-code {
border-bottom-right-radius: 2px;
border-top-right-radius: 2px;
border-right-width: 1px;
.disableInlineCopyToClipboard span > code.copy-to-clipboard-code {
border-end-end-radius: 2px;
border-start-end-radius: 2px;
border-inline-end-width: 1px;
}
#homelinks {
@ -988,6 +1010,7 @@ option {
.expand > .expand-label > .fa-chevron-down {
display: none;
}
.expand > .expand-label > .fa-chevron-left,
.expand > .expand-label > .fa-chevron-right {
display: inline-block;
}
@ -996,6 +1019,7 @@ option {
.expand.expand-expanded > .expand-label > .fa-chevron-down {
display: inline-block;
}
.expand.expand-expanded > .expand-label > .fa-chevron-left,
.expand.expand-expanded > .expand-label > .fa-chevron-right {
display: none;
}
@ -1004,6 +1028,7 @@ option {
.expand:not(.expand-expanded).expand-marked > .expand-label > .fa-chevron-down {
display: inline-block;
}
.expand:not(.expand-expanded).expand-marked > .expand-label > .fa-chevron-left,
.expand:not(.expand-expanded).expand-marked > .expand-label > .fa-chevron-right {
display: none;
}
@ -1012,6 +1037,12 @@ option {
display: block !important;
}
/* turn off unsuitable expander for this reading direction */
.expand > .expand-label > .expand-rtl.direction-ltr,
.expand > .expand-label > .expand-ltr.direction-rtl {
display: none;
}
#body footer.footline{
margin-top: 2rem;
}
@ -1132,7 +1163,7 @@ option {
width: auto;
}
.progress .wrapper {
.progress .toc-wrapper {
background-color: rgba( 134, 134, 134, .066 );
}
@ -1205,7 +1236,7 @@ option {
.anchor {
cursor: pointer;
font-size: .5em;
margin-left: .66em;
margin-inline-start: .66em;
margin-top: .9em;
position: absolute;
visibility: hidden;

View file

@ -313,7 +313,7 @@ function initCodeClipboard(){
code.addClass('copy-to-clipboard-code');
if( inPre ){
parent.addClass( 'copy-to-clipboard' );
parent.addClass( 'copy-to-clipboard' ).addClass( 'pre-code' );
}
else{
code.replaceWith($('<span/>', {'class': 'copy-to-clipboard'}).append(code.clone() ));