From f3566430a3adf571441c4a90bfe3fbd98eca1dc3 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Oct 2020 18:44:13 +0200 Subject: [PATCH] Introduce multi-lingual docs Signed-off-by: Thomas Citharel --- .gitlab-ci.yml | 1 + docker/tests/Dockerfile | 4 ++-- docs/fr/docs/index.md | 10 +++++++++ docs/fr/mkdocs.yml | 42 ++++++++++++++++++++++++++++++++++++ docs/javascripts/redirect.js | 18 ++++++++++++++++ docs/theme/main.html | 7 ++++++ mkdocs.yml | 6 ++++++ 7 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 docs/fr/docs/index.md create mode 100644 docs/fr/mkdocs.yml create mode 100644 docs/javascripts/redirect.js create mode 100644 docs/theme/main.html diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ed149513..ee8f714a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,6 +108,7 @@ pages: script: - mkdir public - mkdocs build + - cd docs/fr && mkdocs build - mv site/* public/ # Mix docs disabled because of https://github.com/elixir-lang/ex_doc/issues/1172 # - mix deps.get diff --git a/docker/tests/Dockerfile b/docker/tests/Dockerfile index caed5022..2e23c395 100644 --- a/docker/tests/Dockerfile +++ b/docker/tests/Dockerfile @@ -1,11 +1,11 @@ FROM elixir:latest LABEL maintainer="Thomas Citharel " -ENV REFRESHED_AT=2020-08-10 +ENV REFRESHED_AT=2020-10-20 RUN apt-get update -yq && apt-get install -yq build-essential inotify-tools postgresql-client git curl gnupg xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 python3-pip cmake RUN curl -sL https://deb.nodesource.com/setup_12.x | bash && apt-get install nodejs -yq RUN npm install -g yarn wait-on RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN mix local.hex --force && mix local.rebar --force -RUN pip3 install mkdocs mkdocs-material pymdown-extensions pygments mkdocs-git-revision-date-localized-plugin mkdocs-minify-plugin +RUN pip3 install mkdocs mkdocs-material pymdown-extensions pygments mkdocs-git-revision-date-localized-plugin mkdocs-minify-plugin mkdocs-exclude RUN curl https://dbip.mirror.framasoft.org/files/dbip-city-lite-latest.mmdb --output GeoLite2-City.mmdb -s && mkdir -p /usr/share/GeoIP && mv GeoLite2-City.mmdb /usr/share/GeoIP/ diff --git a/docs/fr/docs/index.md b/docs/fr/docs/index.md new file mode 100644 index 00000000..09258dfc --- /dev/null +++ b/docs/fr/docs/index.md @@ -0,0 +1,10 @@ +--- +title: Documentation de Mobilizon +--- + +Bienvenue sur la documentation de Mobilizon + +* [En apprendre plus à propos de Mobilizon](/about) (en anglais) +* Apprendre comment utiliser Mobilizon (pas encore écrit) +* [Apprendre à installer Mobilizon](/administration) (en anglais) +* [Apprendre à contribuer à Mobilizon](/contribute) (en anglais) diff --git a/docs/fr/mkdocs.yml b/docs/fr/mkdocs.yml new file mode 100644 index 00000000..a6bc3841 --- /dev/null +++ b/docs/fr/mkdocs.yml @@ -0,0 +1,42 @@ +site_name: Mobilizon +repo_name: "framasoft/mobilizon" +repo_url: "https://framagit.org/framasoft/mobilizon" +site_dir: "../../site/fr" +extra: + social: + - icon: "fontawesome/brands/twitter" + link: "https://twitter.com/joinmobilizon" +markdown_extensions: + - admonition + - codehilite + - footnotes + - meta + - toc: + permalink: true + - pymdownx.superfences + - pymdownx.magiclink + - pymdownx.smartsymbols + - pymdownx.tabbed + - pymdownx.tilde + - pymdownx.mark +plugins: + - search: + lang: ["fr"] + - git-revision-date-localized + - minify: + minify_html: true +theme: + name: "material" + language: "fr" + features: + - instant + - tabs + custom_dir: "../theme/" + palette: + primary: "amber" + accent: "deep purple" + scheme: slate + font: false + icon: + logo: material/calendar + repo: fontawesome/brands/gitlab diff --git a/docs/javascripts/redirect.js b/docs/javascripts/redirect.js new file mode 100644 index 00000000..6142dda3 --- /dev/null +++ b/docs/javascripts/redirect.js @@ -0,0 +1,18 @@ +const languages = ["fr"]; + +const navigatorLanguage = + window.navigator.userLanguage || window.navigator.language; + +let language; +if (languages.includes(navigatorLanguage)) { + language = navigatorLanguage; +} +const split = navigatorLanguage.split("-")[0]; +if (languages.includes(split)) { + language = split; +} +const url = new URL(window.location.href); +if (language && (url.pathname === "/" || url.pathname.startsWith("/use/"))) { + url.pathname = `/${language}${url.pathname}`; + window.location.replace(url); +} diff --git a/docs/theme/main.html b/docs/theme/main.html new file mode 100644 index 00000000..3aea8be2 --- /dev/null +++ b/docs/theme/main.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block site_meta %} + {% if page.is_homepage %} + + {% endif %} +{% endblock %} diff --git a/mkdocs.yml b/mkdocs.yml index 604f35be..7a2f3275 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,4 +1,5 @@ site_name: Mobilizon +site_url: "https://docs.joinmobilizon.org/" repo_name: "framasoft/mobilizon" repo_url: "https://framagit.org/framasoft/mobilizon" extra: @@ -23,6 +24,9 @@ plugins: - git-revision-date-localized - minify: minify_html: true + - exclude: + glob: + - fr/* theme: name: "material" features: @@ -37,3 +41,5 @@ theme: icon: logo: material/calendar repo: fontawesome/brands/gitlab +extra_javascript: + - javascripts/redirect.js