Nuovi progetti, Agg. script traduzione

This commit is contained in:
2025-02-15 17:50:42 +01:00
parent 3a7cdfb3e2
commit 41c4d3716c
14 changed files with 129 additions and 14 deletions

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
ModificationMetadataKey = "lastmod" ModificationMetadataKey = "lastmod"
KeepOriginalMetadata = ["draft", "date", "lastmod"] KeepOriginalMetadata = ["draft", "date", "lastmod", "slug"]
DestinationLanguages = ["it", "en", "es", "fr"] # "de", "eo" DestinationLanguages = ["it", "en", "es", "fr"] # "de", "eo"
IncludePaths = ["/"] IncludePaths = ["/"]
ExcludePaths = ["/miscellanea/Devlogs.md", "/admin.md"] # "/miscellanea/PicoBlog.md" ExcludePaths = ["/miscellanea/Devlogs.md", "/miscellanea/Percent-Encoding.md", "/admin.md"] # "/miscellanea/PicoBlog.md"
TranslationFixes = { TranslationFixes = {
"{{<assetsRoot>}}_/": "{{< assetsRoot>}}/", "{{<assetsRoot>}}_/": "{{< assetsRoot>}}/",
"{{< assetsRoot >}}_/": "{{< assetsRoot >}}/", "{{< assetsRoot >}}_/": "{{< assetsRoot >}}/",
@@ -108,6 +108,7 @@ def number_to_ascii(number:int) -> str:
# TODO handle .notranslate HTML elements # TODO handle .notranslate HTML elements
# TODO fix strange bugs, including bug of autoinserted trailing underscores '_', and HTML closing tags breaking # TODO fix strange bugs, including bug of autoinserted trailing underscores '_', and HTML closing tags breaking
def wrap_for_translation(original_text): def wrap_for_translation(original_text):
external_tokens = []
original_text = (original_text original_text = (original_text
.replace("{{%", "{{@%").replace("%}}", "%@}}") # Hugo shortcodes .replace("{{%", "{{@%").replace("%}}", "%@}}") # Hugo shortcodes
.replace("{{<", "{{@<").replace(">}}", ">@}}") .replace("{{<", "{{@<").replace(">}}", ">@}}")
@@ -116,15 +117,18 @@ def wrap_for_translation(original_text):
original_tokens = original_text.split("{{@") original_tokens = original_text.split("{{@")
for i in range(1, len(original_tokens)): for i in range(1, len(original_tokens)):
token_tokens = original_tokens[i].split("@}}") token_tokens = original_tokens[i].split("@}}")
external_tokens.append("{{@" + token_tokens[0] + "@}}")
token_tokens[0] = (f"{TranslationMagic}__" + str(ascii_to_number("{{@" + token_tokens[0] + "@}}")).replace("1", "1_").replace("9", "9_") + "__") token_tokens[0] = (f"{TranslationMagic}__" + str(ascii_to_number("{{@" + token_tokens[0] + "@}}")).replace("1", "1_").replace("9", "9_") + "__")
original_tokens[i] = ''.join(token_tokens) original_tokens[i] = ''.join(token_tokens)
return ''.join(original_tokens) return (''.join(original_tokens), external_tokens)
def unwrap_from_translation(translated_text): def unwrap_from_translation(translated_text, external_tokens):
translated_tokens = translated_text.split(f"{TranslationMagic}__") translated_tokens = translated_text.split(f"{TranslationMagic}__")
for i in range(1, len(translated_tokens)): for i in range(1, len(translated_tokens)):
token_tokens = translated_tokens[i].split("__") token_tokens = translated_tokens[i].split("__")
token_tokens[0] = number_to_ascii(token_tokens[0].replace(' ', '').replace('_', '')) token_tokens[0] = external_tokens.pop(0) #number_to_ascii(token_tokens[0].replace(' ', '').replace('_', ''))
if (token_tokens[1].startswith('_')):
token_tokens[1] = token_tokens[1][1:] # Extra underscore insertion workaround
translated_tokens[i] = (token_tokens[0] + "__".join(token_tokens[1:])) translated_tokens[i] = (token_tokens[0] + "__".join(token_tokens[1:]))
return (''.join(translated_tokens) return (''.join(translated_tokens)
.replace("{{@%", "{{%").replace("%@}}", "%}}") # Hugo shortcodes .replace("{{@%", "{{%").replace("%@}}", "%}}") # Hugo shortcodes
@@ -139,7 +143,7 @@ def translate_document(document_path, documents):
printf(f"* {document_path} ->") printf(f"* {document_path} ->")
for destination_language in documents[document_path]: for destination_language in documents[document_path]:
source_language = get_source_language(document_path) source_language = get_source_language(document_path)
original_text = wrap_for_translation(read_original_document(document_path)) original_text, external_tokens = wrap_for_translation(read_original_document(document_path))
printf('', destination_language) printf('', destination_language)
try: try:
is_python_translator = True is_python_translator = True
@@ -175,7 +179,7 @@ def translate_document(document_path, documents):
translated_text = ''.join(translated_tokens) translated_text = ''.join(translated_tokens)
elif translated_text.strip(): elif translated_text.strip():
translated_text = (translated_preamble + translated_text) translated_text = (translated_preamble + translated_text)
translated_text = unwrap_from_translation(translated_text) translated_text = unwrap_from_translation(translated_text, external_tokens)
for replacement in TranslationFixes: for replacement in TranslationFixes:
translated_text = translated_text.replace(replacement, TranslationFixes[replacement]) translated_text = translated_text.replace(replacement, TranslationFixes[replacement])
destination_path = make_destination_path(document_path, destination_language) destination_path = make_destination_path(document_path, destination_language)
@@ -198,7 +202,7 @@ def main():
def read_from_scripts(relative_path:str): def read_from_scripts(relative_path:str):
return open((dirname(realpath(__file__)) + "/../" + relative_path), 'r').read() return open((dirname(realpath(__file__)) + "/../" + relative_path), 'r').read()
TranslationMagic = ("__" + str(ascii_to_number("sitoctt"))) TranslationMagic = ("__" + str(ascii_to_number("sito.octt")))
if __name__ == "__main__": if __name__ == "__main__":
globals_text = read_from_scripts("Lib/Globals.sh") globals_text = read_from_scripts("Lib/Globals.sh")

View File

@@ -0,0 +1,21 @@
+++
Title = "BloccSpacc"
Slug = "BloccSpacc"
canonicalUrl = "https://github.com/octospacc/BloccSpacc"
+++
{{< embed "https://hlb0.octt.eu.org/Misc/BloccSpacc/" app "width: 540px; height: 560px;" >}}
Tutte le informazioni e il codice sorgente sono disponibili su Git:
* https://gitlab.com/octospacc/BloccSpacc
* https://github.com/octospacc/BloccSpacc
* https://gitea.it/octospacc/BloccSpacc
## LEGGIMI originale
<blockquote>
{{< GetRemote "https://gitlab.com/octospacc/BloccSpacc/-/raw/main/README.md" markdown >}}
</blockquote>

View File

@@ -0,0 +1,11 @@
+++
Title = "MultiSpaccSDK"
Slug = "MultiSpaccSDK"
canonicalUrl = "https://github.com/octospacc/MultiSpaccSDK"
+++
Tutte le informazioni e il codice sorgente sono disponibili su Git:
* https://gitlab.com/octospacc/MultiSpaccSDK
* https://github.com/octospacc/MultiSpaccSDK
* https://gitea.it/octospacc/MultiSpaccSDK

View File

@@ -0,0 +1,11 @@
+++
Title = "Naples NDS"
Slug = "Naples-NDS"
+++
{{< embed "https://gamingshitposting.github.io/naplesnds/" window >}}
Tutte le informazioni e il codice sorgente sono disponibili su Git:
* https://github.com/GamingShitposting/naplesnds
* https://gitea.it/octospacc/naplesnds

View File

@@ -7,3 +7,11 @@ canonicalUrl = "https://addons.mozilla.org/firefox/addon/offline-caching/"
Tutte le informazioni e il codice sorgente sono disponibili su: Tutte le informazioni e il codice sorgente sono disponibili su:
* https://addons.mozilla.org/firefox/addon/offline-caching/ * https://addons.mozilla.org/firefox/addon/offline-caching/
## LEGGIMI originale
<blockquote>
{{< GetRemote "https://addons.mozilla.org/firefox/addon/offline-caching/" html split `<div class="Addon-main-content">` 1 `</div><section ` 0 >}}
</blockquote>

View File

@@ -0,0 +1,11 @@
+++
Title = "Sala Museo Games"
Slug = "Sala-Museo-Games"
+++
{{< embed "https://gamingshitposting.github.io/SalaMuseoGames/" window >}}
Tutte le informazioni e il codice sorgente sono disponibili su Git:
* https://github.com/GamingShitposting/SalaMuseoGames
* https://gitea.it/octospacc/SalaMuseoGames

View File

@@ -0,0 +1,6 @@
+++
Title = "Spacc BBS"
Slug = "Spacc-BBS"
+++
{{< embed "https://bbs.spacc.eu.org/" window >}}

View File

@@ -0,0 +1,6 @@
+++
Title = "SpaccCraft"
Slug = "SpaccCraft"
+++
{{< embed "https://SpaccCraft.altervista.org/" window >}}

View File

@@ -0,0 +1,14 @@
+++
Title = "Spaccogram (Web)"
Slug = "Spaccogram"
+++
{{< embed "https://1.tgweb.octt.eu.org/" window >}}
Tutte le informazioni sono disponibili sul canale Telegram:
* https://t.me/+ujaob63Vy705Mzgx
Il codice sorgente è disponibile su Git:
* https://gitea.it/octospacc/Spaccogram

View File

@@ -3,4 +3,4 @@ Title = "🕷️ SpiderADB"
Slug = "SpiderADB" Slug = "SpiderADB"
+++ +++
{{< embed "https://hub.octt.eu.org/SpiderADB/" app >}} {{< embed "https://hub.octt.eu.org/SpiderADB/#/about" app >}}

View File

@@ -0,0 +1,22 @@
+++
Title = "WebPinBoard / Bachecoctt"
Slug = "WebPinBoard-Bachecoctt"
canonicalUrl = "https://github.com/octospacc/WebPinBoard"
+++
{{< embed "https://octtspacc.gitlab.io/bachecoctt/" window >}}
Tutte le informazioni e il codice sorgente sono disponibili su Git:
* https://gitlab.com/octospacc/WebPinBoard
* https://github.com/octospacc/WebPinBoard
* https://gitea.it/octospacc/WebPinBoard
* https://codeberg.org/octt-mirror/WebPinBoard
## LEGGIMI originale
<blockquote>
{{< GetRemote "https://gitlab.com/octospacc/WebPinBoard/-/raw/main/README.md" markdown >}}
</blockquote>

View File

@@ -3,4 +3,4 @@ Title = "Progetti⚒"
Lastmod = 2025-02-15 Lastmod = 2025-02-15
+++ +++
Questa sezione raccoglie (quasi) tutti i miei progetti (di cui uno è il sitoctt stesso). Per informazioni aggiuntive, leggi il post di presentazione: https://octospacc.altervista.org/2025/02/14/definitivo-progettocto-di-progettazioctt/ Questa sezione raccoglie (quasi) tutti i miei progetti (di cui uno è il sitoctt stesso). Per informazioni aggiuntive, leggi il post di presentazione: <https://octospacc.altervista.org/2025/02/14/definitivo-progettocto-di-progettazioctt/>.

View File

@@ -6,6 +6,7 @@ title = "✨sitoctt✨"
canonifyURLs = true canonifyURLs = true
disablePathToLower = true disablePathToLower = true
sectionPagesMenu = "main" sectionPagesMenu = "main"
summaryLength = 40
defaultContentLanguage = "it" defaultContentLanguage = "it"
defaultContentLanguageInSubdir = true defaultContentLanguageInSubdir = true
theme = [ "hugo-notice", "ananke" ] theme = [ "hugo-notice", "ananke" ]

View File

@@ -6,18 +6,18 @@
{{- $type = "embed" -}} {{- $type = "embed" -}}
{{- end -}} {{- end -}}
{{- $iswindow := (in (slice "app" "window") $type) -}} {{- $iswindow := (in (slice "app" "window") $type) -}}
<figure class="w-100" style="margin: auto;"> <figure class="w-100" style="margin: auto; {{ $data | safeCSS }} height: auto;">
{{- if (eq $type "embed") -}} {{- if (eq $type "embed") -}}
{{- $link = $href -}} {{- $link = $href -}}
<iframe class="w-100 vh-75 {{ $data }}" src="{{ $href }}" allowfullscreen="allowfullscreen"></iframe> <iframe class="w-100 vh-75" src="{{ $href }}" allowfullscreen="allowfullscreen"></iframe>
{{- else if $iswindow -}} {{- else if $iswindow -}}
<figcaption style="background: #330066; padding: 0.25em; border: 4px solid #330066;">{{ partial "anchor.html" (dict "Params" (dict <figcaption style="background: #330066; padding: 0.25em; border: 4px solid #330066;">{{ partial "anchor.html" (dict "Params" (dict
"style" "color: rgba(255,255,255,.9); text-decoration: none;" "style" "color: rgba(255,255,255,.9); text-decoration: none;"
"target" "_blank" "target" "_blank"
"rel" "noopener" "rel" "noopener"
"href" $href)) }}</figcaption> "href" $href)) }}</figcaption>
<div class="vh-75" style="resize: vertical; overflow: hidden; border: 4px solid #330066;"> <div class="vh-75" style="resize: vertical; overflow: hidden; border: 4px solid #330066; {{ $data | safeCSS }}">
<iframe class="w-100 h-100 bn" src="{{ $href }}" allowfullscreen="allowfullscreen"></iframe> <iframe class="w-100 h-100 bn" src="{{ $href }}" allowfullscreen="allowfullscreen" onload="this.focus()"></iframe>
</div> </div>
{{- else if in (slice "youtube" "yt") $type -}} {{- else if in (slice "youtube" "yt") $type -}}
{{- $link = (printf "https://youtu.be/%s" $href) -}} {{- $link = (printf "https://youtu.be/%s" $href) -}}