From 086f1e98c193943010f7e3b7889b8f2d0ac4e57b Mon Sep 17 00:00:00 2001 From: Rami Sabbagh Date: Wed, 26 Jan 2022 04:15:02 +0200 Subject: feat: add RTL layout support and Arabic localization (#159) * Add direction attribute to the tag So rtl layout can be activated * Add `tailwindcss-rtl` Which brings very handy RTL support to Tailwind CSS * Load the `tailwindcss-rtl` plugin * Find and replace many classes into RTL capable ones * Find and replace many classes into RTL capable ones * Update the prebuilt css * Add Arabic localization * Fix code blocks, force their layout to LTR * Update the prebuilt css * Minor improvement to the Arabic localization * Add singular/plural support for `readingTime` By following [hugo docs](https://gohugo.io/content-management/multilingual/#query-a-singularplural-translation) * Add a singular form of `readingTime` for Arabic * Add a singular form of `readingTime` for English * Add an additional variant for `readingTime` in the Arabic localization In Arabic we have a plural for dual, and a plural for 3+. * Fix left and right arrows not being flipped in RTL I had to manually flip them in each place * Revert "Add a singular form of `readingTime` for English" This reverts commit 73482b600ed7da5fb37b2b5f7d88384a32de18b1. * Add singular variant for `readingTime` in EN localization --- assets/css/base.css | 4 ++++ assets/css/markdown.css | 6 ++--- assets/css/site.css | 4 ++-- assets/css/tailwind.config.js | 4 +++- i18n/ar.yaml | 28 ++++++++++++++++++++++ i18n/de.yaml | 2 +- i18n/en.yaml | 3 ++- i18n/es.yaml | 2 +- i18n/fr.yaml | 2 +- i18n/it.yaml | 2 +- i18n/jp.yaml | 2 +- i18n/ko.yaml | 2 +- i18n/pl.yaml | 2 +- i18n/ru.yaml | 2 +- i18n/zh-Hant.yaml | 2 +- i18n/zh.yaml | 2 +- layouts/_default/baseof.html | 8 +++---- layouts/authors/list.html | 4 ++-- layouts/index.html | 10 ++++---- layouts/partials/components/doc-layout.html | 24 +++++++++---------- layouts/partials/components/post-author.html | 4 ++-- layouts/partials/components/post-edit.html | 4 ++-- layouts/partials/components/post-metadata.html | 18 +++++++------- layouts/partials/components/post-tags.html | 2 +- layouts/partials/components/post-toc.html | 2 +- layouts/partials/components/summary-plain.html | 2 +- layouts/partials/header.html | 12 +++++----- layouts/partials/utils/get-summary.html | 2 +- layouts/partials/widgets/about.html | 10 ++++---- layouts/partials/widgets/experience.html | 2 +- layouts/partials/widgets/pages.html | 2 +- package-lock.json | 15 +++++++++++- package.json | 3 ++- ...ka.css_fc3f76d7bee2760c3a903059afc3d9b2.content | 2 +- 34 files changed, 122 insertions(+), 73 deletions(-) create mode 100644 i18n/ar.yaml diff --git a/assets/css/base.css b/assets/css/base.css index 84d1d16..a27af2b 100644 --- a/assets/css/base.css +++ b/assets/css/base.css @@ -21,4 +21,8 @@ a:hover { @apply text-eureka transition duration-300 ease-in-out; +} + +code { + direction: ltr; } \ No newline at end of file diff --git a/assets/css/markdown.css b/assets/css/markdown.css index da467bf..0bae72e 100644 --- a/assets/css/markdown.css +++ b/assets/css/markdown.css @@ -55,7 +55,7 @@ } .content blockquote { - @apply text-base border-l-4 border-tertiary-text pl-4 pr-4 text-secondary-text; + @apply text-base border-s-4 border-tertiary-text ps-4 pe-4 text-secondary-text; } .content code { @@ -71,11 +71,11 @@ } .content ul { - @apply text-base pl-8 list-disc; + @apply text-base ps-8 list-disc; } .content ol { - @apply text-base pl-8 list-decimal; + @apply text-base ps-8 list-decimal; } .content kbd { diff --git a/assets/css/site.css b/assets/css/site.css index 0a8e083..d4732f5 100644 --- a/assets/css/site.css +++ b/assets/css/site.css @@ -11,11 +11,11 @@ } .sticky-toc ul { - @apply text-base pl-8 list-disc; + @apply text-base ps-8 list-disc; } .sticky-toc ol { - @apply text-base pl-8 list-decimal; + @apply text-base ps-8 list-decimal; } .sticky-toc li + li { diff --git a/assets/css/tailwind.config.js b/assets/css/tailwind.config.js index 88b2d42..405b7b0 100644 --- a/assets/css/tailwind.config.js +++ b/assets/css/tailwind.config.js @@ -53,5 +53,7 @@ module.exports = { } }, variants: {}, - plugins: [] + plugins: [ + require('tailwindcss-rtl') + ] } diff --git a/i18n/ar.yaml b/i18n/ar.yaml new file mode 100644 index 0000000..806d246 --- /dev/null +++ b/i18n/ar.yaml @@ -0,0 +1,28 @@ +readMore: + other: اقرأ المزيد +readingTime: + one: دقيقة من القراءة + two: دقيقتان من القراءة + other: '{{ .Count }} دقائق من القراءة' +toc: + other: لائحة المحتوى +seriesOfPosts: + other: سلسلة من المنشورات +previous: + other: السابق +next: + other: التالي +seeAlso: + other: انظر أيضاً +recent: + other: جديد +onThisPage: + other: على هذه الصفحة +editThisPage: + other: عدّل هذه الصفحة +light: + other: مضيئ +dark: + other: مظلم +auto: + other: تلقائي diff --git a/i18n/de.yaml b/i18n/de.yaml index a4de6e0..59c28f1 100644 --- a/i18n/de.yaml +++ b/i18n/de.yaml @@ -1,7 +1,7 @@ readMore: other: Mehr erfahren readingTime: - other: 'Lesezeit: {{ .ReadingTime }} min' + other: 'Lesezeit: {{ .Count }} min' toc: other: Inhaltsverzeichnis seriesOfPosts: diff --git a/i18n/en.yaml b/i18n/en.yaml index 5046dc7..16037ba 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -1,7 +1,8 @@ readMore: other: Read More readingTime: - other: '{{ .ReadingTime }} min read' + other: '{{ .Count }} mins read' + one: '1 min read' toc: other: Table of Contents seriesOfPosts: diff --git a/i18n/es.yaml b/i18n/es.yaml index 7e305c8..109c7d1 100644 --- a/i18n/es.yaml +++ b/i18n/es.yaml @@ -1,7 +1,7 @@ readMore: other: Leer más readingTime: - other: '{{ .ReadingTime }} minutos de lectura' + other: '{{ .Count }} minutos de lectura' toc: other: Tabla de Contenidos seriesOfPosts: diff --git a/i18n/fr.yaml b/i18n/fr.yaml index 0c0a7aa..1958b3d 100644 --- a/i18n/fr.yaml +++ b/i18n/fr.yaml @@ -1,7 +1,7 @@ readMore: other: En savoir plus readingTime: - other: '{{ .ReadingTime }} min de lecture' + other: '{{ .Count }} min de lecture' toc: other: Table des matières seriesOfPosts: diff --git a/i18n/it.yaml b/i18n/it.yaml index 56ad801..1aaea1c 100644 --- a/i18n/it.yaml +++ b/i18n/it.yaml @@ -1,7 +1,7 @@ readMore: other: Leggi di più readingTime: - other: '{{ .ReadingTime }} min' + other: '{{ .Count }} min' toc: other: Indice dei Contenuti seriesOfPosts: diff --git a/i18n/jp.yaml b/i18n/jp.yaml index 74a11b7..f7a3640 100644 --- a/i18n/jp.yaml +++ b/i18n/jp.yaml @@ -1,7 +1,7 @@ readMore: other: 続きを読む readingTime: - other: '{{ .ReadingTime }}分読む' + other: '{{ .Count }}分読む' toc: other: 目次 seriesOfPosts: diff --git a/i18n/ko.yaml b/i18n/ko.yaml index 25fd479..96a0b68 100644 --- a/i18n/ko.yaml +++ b/i18n/ko.yaml @@ -1,7 +1,7 @@ readMore: other: 더 보기 readingTime: - other: "{{ .ReadingTime }} min 읽음" + other: "{{ .Count }} min 읽음" toc: other: 목차 seriesOfPosts: diff --git a/i18n/pl.yaml b/i18n/pl.yaml index 94e74e1..8d6b76e 100644 --- a/i18n/pl.yaml +++ b/i18n/pl.yaml @@ -1,7 +1,7 @@ readMore: other: Czytaj więcej readingTime: - other: '{{ .ReadingTime }} min czytania' + other: '{{ .Count }} min czytania' toc: other: Spis treści seriesOfPosts: diff --git a/i18n/ru.yaml b/i18n/ru.yaml index 6c7cdc7..d23d16e 100644 --- a/i18n/ru.yaml +++ b/i18n/ru.yaml @@ -1,7 +1,7 @@ readMore: other: Читать далее readingTime: - other: '{{ .ReadingTime }} мин. чтения' + other: '{{ .Count }} мин. чтения' toc: other: Содержание seriesOfPosts: diff --git a/i18n/zh-Hant.yaml b/i18n/zh-Hant.yaml index 12d63f0..10908f8 100644 --- a/i18n/zh-Hant.yaml +++ b/i18n/zh-Hant.yaml @@ -1,7 +1,7 @@ readMore: other: 閱讀更多 readingTime: - other: '{{ .ReadingTime }}分鐘閱讀' + other: '{{ .Count }}分鐘閱讀' toc: other: 目錄 seriesOfPosts: diff --git a/i18n/zh.yaml b/i18n/zh.yaml index dd87eb8..c92d67c 100644 --- a/i18n/zh.yaml +++ b/i18n/zh.yaml @@ -1,7 +1,7 @@ readMore: other: 阅读更多 readingTime: - other: '{{ .ReadingTime }}分钟阅读时长' + other: '{{ .Count }}分钟阅读时长' toc: other: 目录 seriesOfPosts: diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 38fd1e1..71691f1 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,9 +1,9 @@ - + {{- partial "head" . }} -
+
{{- partial "header" . -}}
@@ -12,14 +12,14 @@ {{- if or .IsHome (and (eq .Type "authors") (eq .Kind "term")) }} {{- block "main" . }}{{- end }} {{- else }} -
+
{{- block "main" . }}{{- end }}
{{ end }} -