Introduce multi-lingual docs

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-10-20 18:44:13 +02:00
parent ef29894227
commit f3566430a3
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
7 changed files with 86 additions and 2 deletions

View file

@ -108,6 +108,7 @@ pages:
script: script:
- mkdir public - mkdir public
- mkdocs build - mkdocs build
- cd docs/fr && mkdocs build
- mv site/* public/ - mv site/* public/
# Mix docs disabled because of https://github.com/elixir-lang/ex_doc/issues/1172 # Mix docs disabled because of https://github.com/elixir-lang/ex_doc/issues/1172
# - mix deps.get # - mix deps.get

View file

@ -1,11 +1,11 @@
FROM elixir:latest FROM elixir:latest
LABEL maintainer="Thomas Citharel <tcit@tcit.fr>" LABEL maintainer="Thomas Citharel <tcit@tcit.fr>"
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 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 curl -sL https://deb.nodesource.com/setup_12.x | bash && apt-get install nodejs -yq
RUN npm install -g yarn wait-on RUN npm install -g yarn wait-on
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN mix local.hex --force && mix local.rebar --force 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/ 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/

10
docs/fr/docs/index.md Normal file
View file

@ -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)

42
docs/fr/mkdocs.yml Normal file
View file

@ -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

View file

@ -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);
}

7
docs/theme/main.html vendored Normal file
View file

@ -0,0 +1,7 @@
{% extends "base.html" %}
{% block site_meta %}
{% if page.is_homepage %}
<link rel="alternate" hreflang="fr" href="{{ config.site_url }}fr/" />
{% endif %}
{% endblock %}

View file

@ -1,4 +1,5 @@
site_name: Mobilizon site_name: Mobilizon
site_url: "https://docs.joinmobilizon.org/"
repo_name: "framasoft/mobilizon" repo_name: "framasoft/mobilizon"
repo_url: "https://framagit.org/framasoft/mobilizon" repo_url: "https://framagit.org/framasoft/mobilizon"
extra: extra:
@ -23,6 +24,9 @@ plugins:
- git-revision-date-localized - git-revision-date-localized
- minify: - minify:
minify_html: true minify_html: true
- exclude:
glob:
- fr/*
theme: theme:
name: "material" name: "material"
features: features:
@ -37,3 +41,5 @@ theme:
icon: icon:
logo: material/calendar logo: material/calendar
repo: fontawesome/brands/gitlab repo: fontawesome/brands/gitlab
extra_javascript:
- javascripts/redirect.js