From fca9c09f5930365e535b29e5c338983966725123 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 11 Nov 2022 21:39:41 +0100 Subject: [PATCH 1/4] Updated page --- source/donate.md | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/source/donate.md b/source/donate.md index afed351..8c95cd5 100644 --- a/source/donate.md +++ b/source/donate.md @@ -1,15 +1,20 @@ ## Support Reticulum You can help support the continued development of open, free and private communications systems by donating via one of the following channels: -**Monero** -``` -84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w -``` -**Ethereum** -``` -0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a -``` -**Bitcoin** -``` -3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq -``` +- Monero
+ ``` + 84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w + ``` +

+- Ethereum
+ ``` + 0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a + ``` +

+- Bitcoin
+ ``` + 3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq + ``` +

+- Ko-Fi
+ `https://ko-fi.com/markqvist` \ No newline at end of file From 801a8bb7a4816d39259fdec100c5131370f0c463 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 12 Nov 2022 10:32:05 +0100 Subject: [PATCH 2/4] Added multilingual support to build script --- Makefile | 4 +- build.py | 89 ++++++++++++++++++++++++++++++++++++++++-- source/donate_pt-br.md | 29 ++++++++------ 3 files changed, 105 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 5fe320a..1590f6e 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,8 @@ website: python ./build.py cp assets/css/* build/css/ cp assets/gfx/* build/gfx/ - cp -rv ../../Reticulum/docs/manual/* build/manual/ - cp -rv ../../Reticulum/docs/Reticulum\ Manual.pdf build/manual/ + cp -r ../../Reticulum/docs/manual/* build/manual/ + cp -r ../../Reticulum/docs/Reticulum\ Manual.pdf build/manual/ upload: . ./build.env; \ diff --git a/build.py b/build.py index e897187..1e2b9c2 100644 --- a/build.py +++ b/build.py @@ -23,10 +23,85 @@ document_end = """ """ -menu_md = """ -
[Reticulum](index.html) | [Start](start.html) | [Hardware](hardware.html) | [Testnet](connect.html) | [Manual](docs.html) | [Crypto](crypto.html) | [Credits](credits.html) | [Source](https://github.com/markqvist/reticulum) | [Donate](donate.html)
+langs_md = """ +
{LANGS}
""" +menu_md = """ +
[{RETICULUM}](index{LANG_EXT}.html) | [{START}](start{LANG_EXT}.html) | [{HARDWARE}](hardware{LANG_EXT}.html) | [{TESTNET}](connect{LANG_EXT}.html) | [{MANUAL}](docs{LANG_EXT}.html) | [{CRYPTO}](crypto{LANG_EXT}.html) | [{CREDITS}](credits{LANG_EXT}.html) | [{SOURCE}](https://github.com/markqvist/reticulum) | [{DONATE}](donate{LANG_EXT}.html)
+""" + +primary_lang = "en" +langs = [ + {"name": "English", "ext": "en"}, + {"name": "Português", "ext": "pt-br"}, +] + +menu_translations = { + "en": { + "RETICULUM": "Reticulum", + "START": "Start", + "HARDWARE": "Hardware", + "TESTNET": "Testnet", + "MANUAL": "Manual", + "CRYPTO": "Crypto", + "CREDITS": "Credits", + "SOURCE": "Source", + "DONATE": "Donate", + }, + "pt-br": { + "RETICULUM": "Reticulum", + "START": "Começar", + "HARDWARE": "Hardware", + "TESTNET": "Rede de Teste", + "MANUAL": "Manual", + "CRYPTO": "Cripto", + "CREDITS": "Créditos", + "SOURCE": "Código", + "DONATE": "Ajude", + } +} + +def get_page_lang(page): + page_lang = primary_lang + for lang in langs: + base_name = mdf.replace(".md", "") + if lang["ext"] != primary_lang: + if base_name.endswith(lang["ext"]): + page_lang = lang["ext"] + return page_lang + +def get_languages_md(page): + page = page.replace(SOURCES_PATH, ".") + current_page_lang = get_page_lang(page) + if current_page_lang != primary_lang: + page_base_name = page.replace("_"+current_page_lang+".md", "") + else: + page_base_name = page.replace(".md", "") + + lang_list = "" + for lang_entry in langs: + lang = lang_entry["name"] + lang_ext = lang_entry["ext"] + if lang_ext != primary_lang: + lang_ext_str = "_"+lang_ext + else: + lang_ext_str = "" + + link_target = page_base_name+lang_ext_str+".html" + link_md = "["+lang+"]("+link_target+") |" + lang_list += link_md + + return langs_md.replace("{LANGS}", lang_list[:-2]) + + +def get_menu_md(lang): + local_menu_md = menu_md + for entry in menu_translations[lang]: + local_menu_md = local_menu_md.replace("{"+entry+"}", menu_translations[lang][entry]) + + return local_menu_md + def scan_pages(base_path): files = [file for file in os.listdir(base_path) if os.path.isfile(os.path.join(base_path, file)) and file[:1] != "."] directories = [file for file in os.listdir(base_path) if os.path.isdir(os.path.join(base_path, file)) and file[:1] != "."] @@ -46,8 +121,16 @@ source_files = scan_pages(SOURCES_PATH) for mdf in source_files: with open(mdf, "rb") as f: + page_lang = get_page_lang(mdf) + + if page_lang != primary_lang: + page_lang_ext = "_"+page_lang + else: + page_lang_ext = "" + md = f.read().decode(INPUT_ENCODING) - html = markdown.markdown(menu_md + md, extensions=["markdown.extensions.fenced_code"]) + page_md = get_languages_md(mdf)+get_menu_md(page_lang).replace("{LANG_EXT}", page_lang_ext) + md + html = markdown.markdown(page_md, extensions=["markdown.extensions.fenced_code"]) html = document_start + html + document_end of = BUILD_PATH+mdf.replace(SOURCES_PATH, "").replace(".md", ".html") diff --git a/source/donate_pt-br.md b/source/donate_pt-br.md index 98f6cd0..9ff9710 100644 --- a/source/donate_pt-br.md +++ b/source/donate_pt-br.md @@ -1,15 +1,20 @@ ## Ajude o Reticulum Você pode ajudar na continuação do desenvolvimento de sistemas de comunicação abertos, livres e privados, doando através de um dos seguintes canais: -**Monero** -``` -84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w -``` -**Ethereum** -``` -0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a -``` -**Bitcoin** -``` -3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq -``` +- Monero
+ ``` + 84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w + ``` +

+- Ethereum
+ ``` + 0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a + ``` +

+- Bitcoin
+ ``` + 3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq + ``` +

+- Ko-Fi
+ `https://ko-fi.com/markqvist` \ No newline at end of file From ad914d351505e55e7a630a309d4b9b4ac5dd6c66 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 12 Nov 2022 18:20:10 +0100 Subject: [PATCH 3/4] Fixed missing space --- build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.py b/build.py index 1e2b9c2..1129afc 100644 --- a/build.py +++ b/build.py @@ -89,10 +89,10 @@ def get_languages_md(page): lang_ext_str = "" link_target = page_base_name+lang_ext_str+".html" - link_md = "["+lang+"]("+link_target+") |" + link_md = "["+lang+"]("+link_target+") | " lang_list += link_md - return langs_md.replace("{LANGS}", lang_list[:-2]) + return langs_md.replace("{LANGS}", lang_list[:-3]) def get_menu_md(lang): From 706ec2161bee6068dccbc089dba06abccd8aeebf Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 14 Nov 2022 11:26:59 +0100 Subject: [PATCH 4/4] Updated CSS --- assets/css/water.css | 8 ++++++++ build.py | 13 ++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/assets/css/water.css b/assets/css/water.css index 61e3488..7ff7133 100644 --- a/assets/css/water.css +++ b/assets/css/water.css @@ -28,6 +28,14 @@ --select-arrow: url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23161f27'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E"); } +div.top_menu { + font-size: 1.1em; +} + +div.lang_menu { + margin-bottom: 0.35em; +} + @media (prefers-color-scheme: dark) { :root { --background-body: #202b38; diff --git a/build.py b/build.py index 1129afc..9c9d495 100644 --- a/build.py +++ b/build.py @@ -10,7 +10,7 @@ document_start = """ - + Reticulum Network @@ -23,13 +23,8 @@ document_end = """ """ -langs_md = """ -
{LANGS}
-""" - -menu_md = """ -
[{RETICULUM}](index{LANG_EXT}.html) | [{START}](start{LANG_EXT}.html) | [{HARDWARE}](hardware{LANG_EXT}.html) | [{TESTNET}](connect{LANG_EXT}.html) | [{MANUAL}](docs{LANG_EXT}.html) | [{CRYPTO}](crypto{LANG_EXT}.html) | [{CREDITS}](credits{LANG_EXT}.html) | [{SOURCE}](https://github.com/markqvist/reticulum) | [{DONATE}](donate{LANG_EXT}.html)
-""" +langs_md = """
{LANGS}
""" +menu_md = """
[{RETICULUM}](index{LANG_EXT}.html) | [{START}](start{LANG_EXT}.html) | [{HARDWARE}](hardware{LANG_EXT}.html) | [{TESTNET}](connect{LANG_EXT}.html) | [{MANUAL}](docs{LANG_EXT}.html) | [{CRYPTO}](crypto{LANG_EXT}.html) | [{CREDITS}](credits{LANG_EXT}.html) | [{SOURCE}](https://github.com/markqvist/reticulum) | [{DONATE}](donate{LANG_EXT}.html)
""" primary_lang = "en" langs = [ @@ -129,7 +124,7 @@ for mdf in source_files: page_lang_ext = "" md = f.read().decode(INPUT_ENCODING) - page_md = get_languages_md(mdf)+get_menu_md(page_lang).replace("{LANG_EXT}", page_lang_ext) + md + page_md = "
"+get_languages_md(mdf)+""+get_menu_md(page_lang).replace("{LANG_EXT}", page_lang_ext) + "
\n\n" + md html = markdown.markdown(page_md, extensions=["markdown.extensions.fenced_code"]) html = document_start + html + document_end