From 870066ef799ae6c5fc33c136ab0a0ff02791269c Mon Sep 17 00:00:00 2001 From: sejo Date: Sun, 27 Mar 2022 19:19:32 -0600 Subject: [PATCH] translations and language specific templates implementation --- generasitio.lua | 48 ++++++++++++++++++++++++++++++---- src/about.gmo | 4 +-- src/acerca.gmo | 4 +-- src/ahora.gmo | 2 +- src/apoyo.gmo | 4 +-- src/contact.gmo | 4 +-- src/contacto.gmo | 4 +-- src/danzas_compuertas.gmo | 2 +- src/now.gmo | 2 +- src/support.gmo | 4 +-- src/tutorial_de_uxn.gmo | 2 +- src/uxn_tutorial.gmo | 4 +-- templates/estilo.css | 7 +++++ templates/pagefooter_es.gmi | 5 ++++ templates/pagefooter_es.html | 15 +++++++++++ templates/pageheader.gmi | 2 +- templates/pageheader.html | 3 ++- templates/pageincoming_es.gmi | 3 +++ templates/pageincoming_es.html | 4 +++ 19 files changed, 91 insertions(+), 32 deletions(-) create mode 100644 templates/pagefooter_es.gmi create mode 100644 templates/pagefooter_es.html create mode 100644 templates/pageincoming_es.gmi create mode 100644 templates/pageincoming_es.html diff --git a/generasitio.lua b/generasitio.lua index 445d138..4b0e611 100644 --- a/generasitio.lua +++ b/generasitio.lua @@ -14,11 +14,21 @@ templates = { footer = { path = "pagefooter.html", template = ""}, incoming = { path = "pageincoming.html", template = ""} }, + webEs = { + header = { path = "pageheader.html", template = ""}, + footer = { path = "pagefooter_es.html", template = ""}, + incoming = { path = "pageincoming_es.html", template = ""} + }, gemEn = { header = { path = "pageheader.gmi", template = ""}, footer = { path = "pagefooter.gmi", template = ""}, incoming = { path = "pageincoming.gmi", template = ""} }, + gemEs = { + header = { path = "pageheader.gmi", template = ""}, + footer = { path = "pagefooter_es.gmi", template = ""}, + incoming = { path = "pageincoming_es.gmi", template = ""} + }, } pages = {} @@ -127,7 +137,27 @@ function firstPass() if line == "" then pagemeta.lang = "en,es-MX" -- default else - pagemeta.lang, pagemeta.trlang, pagemeta.trname = string.match("^lang=(.-)%s(.-)->(.-)$") + local langformat = "^lang=(%a+)" + local tradformat = "%s(%a+)->(.-)$" + pagemeta.lang = string.match(line,langformat) + local trlang, trname = string.match(line, tradformat) + if trlang ~= nil then + local ttext = "in english:" + if string.match( trlang, "^es" ) then + ttext = "en español:" + end + local weblink = string.format( + "%s", + pages[ trname ].slug, trname ) + local gemlink = string.format( + "=> ./%s.gmi %s", + pages[ trname ].slug, trname ) + pagemeta.webtranslation = string.format( + "

%s %s

", + ttext, weblink ) + pagemeta.gemtranslation = string.format( + "%s\n%s\n", ttext, gemlink) + end end elseif count == 3 then -- obtain page description pagemeta.pdescription,n = string.gsub(line,"[{}]","") @@ -170,7 +200,7 @@ function firstPass() end local close = closeTags() - out.web = string.format("%s%s",close,level,title,level) + out.web = string.format("%s%s",close,level,title,title,level) elseif string.match( line, "^>") then -- BLOCKQUOTE local close = closeTags() @@ -189,9 +219,10 @@ function firstPass() local dest, text = getLink( line ) if string.match( dest, "^%./") then --local links local t = string.match( text, "^{(.-)}$" ) + local htmldest = string.gsub( dest, "gmi", "html" ) if t ~= nil then -- wikilink local close = closeTags() - out.web = string.format("%s

%s

",close,dest,t) + out.web = string.format("%s

%s

",close,htmldest,t) elseif isImagePath( dest ) then -- images local img = string.format('%s',dest,text) @@ -271,8 +302,14 @@ function firstPass() pagemeta.navcontent = table.concat( navlines, "\n" ) -- set templates - pagemeta.outs.web.templates = templates.webEn - pagemeta.outs.gem.templates = templates.gemEn + if string.match( pagemeta.lang, "^en" ) then + pagemeta.outs.web.templates = templates.webEn + pagemeta.outs.gem.templates = templates.gemEn + else + pagemeta.outs.web.templates = templates.webEs + pagemeta.outs.gem.templates = templates.gemEs + end + -- fill templates and write results for key, out in pairs(pagemeta.outs) do @@ -336,6 +373,7 @@ function initPageMetadata( name ) -- return a table with metadata updatedate = "", navcontent = "", gemincoming = "", webincoming = "", + gemtranslation = "", webtranslation = "" } meta.outs = { web = { path = string.format("%s/%s.html", webdir, meta.slug) }, diff --git a/src/about.gmo b/src/about.gmo index 3835a38..96bf581 100644 --- a/src/about.gmo +++ b/src/about.gmo @@ -1,9 +1,7 @@ # about - +lang=en es->acerca compudanzas is a research project exploring alternative modes of learning and creating computation. -en español: {acerca} - we attempt to transition from a logic of productivity and efficiency, and circuits that destroy life, to dances, rituals, and other types of seemingly useless computers! we move calmly, patiently, and with curiosity. diff --git a/src/acerca.gmo b/src/acerca.gmo index 2ea138d..e67fe47 100644 --- a/src/acerca.gmo +++ b/src/acerca.gmo @@ -1,9 +1,7 @@ # acerca - +lang=es en->about compudanzas es un proyecto creativo de investigación que explora formas alternativas de aprender y hacer cómputo. -in english: {about} - reimaginamos la computación y sus implicaciones. tratamos de transicionar desde una lógica de productividad y eficiencia, y circuitos que destruyen vida, hacia danzas, rituales, y otros tipos de computadoras aparentemente inútiles. diff --git a/src/ahora.gmo b/src/ahora.gmo index d739e7b..93ab861 100644 --- a/src/ahora.gmo +++ b/src/ahora.gmo @@ -1,5 +1,5 @@ # compudanzas ahora - +lang=es en->now en qué andamos aproximadamente en estos momentos: presentamos {alive computing dance} en el 10 aniversario de algorave, nuestro primer performance que utiliza a la {qiudanz technique}. diff --git a/src/apoyo.gmo b/src/apoyo.gmo index c697325..c568c4e 100644 --- a/src/apoyo.gmo +++ b/src/apoyo.gmo @@ -1,9 +1,7 @@ # apoyo - +lang=es en->support compudanzas como la práctica de hacer tangible a la computación ha sido un proyecto de ensueño por ya varios años. -in english: {support} - => ./img/foto_laconsagracion_04.jpg foto de piezas de madera en el suelo manipuladas por algunas manos ¡contribuye a hacerlo posible con tu apoyo económico! diff --git a/src/contact.gmo b/src/contact.gmo index dbb7f02..b1c9d89 100644 --- a/src/contact.gmo +++ b/src/contact.gmo @@ -1,5 +1,5 @@ # contact - +lang=en es->contacto let's connect! our e-mail address: compudanzas at posteo dot net @@ -17,5 +17,3 @@ and in the ssb network, thanks to {la sala}: see the {log} for non-interactive ways of following our updates. (in some contexts you can find me as {sejo}) - -en español: {contacto} diff --git a/src/contacto.gmo b/src/contacto.gmo index 3ab8fa7..aa5dca2 100644 --- a/src/contacto.gmo +++ b/src/contacto.gmo @@ -1,5 +1,5 @@ # contacto - +lang=es en->contact ¡conectemos! nuestra dirección de correo-e: compudanzas en posteo dot net @@ -17,5 +17,3 @@ y en la red ssb, gracias a {la sala}: además, en el {log} hay más opciones no interactivas para seguir nuestras actualizaciones. (en algunos contextos me puedes encontrar como {sejo}) - -in english: {contact} diff --git a/src/danzas_compuertas.gmo b/src/danzas_compuertas.gmo index 227ff06..2814caf 100644 --- a/src/danzas_compuertas.gmo +++ b/src/danzas_compuertas.gmo @@ -1,5 +1,5 @@ # danzas compuertas - +lang=es antiguas historias hablaban de computar en conjunto, en comunidad. tareas sencillas y divertidas que requieren atención y presencia y que combinadas dan paso a complejidad, a olas, a cambios. diff --git a/src/now.gmo b/src/now.gmo index 7b9304d..cde4f6f 100644 --- a/src/now.gmo +++ b/src/now.gmo @@ -1,5 +1,5 @@ # now - +lang=en es->ahora what are we up to approximately now. we just performed {alive computing dance} on the 10th anniversay of algorave, a livecoding performance using the {qiudanz technique}. diff --git a/src/support.gmo b/src/support.gmo index e50c99e..76f2d7b 100644 --- a/src/support.gmo +++ b/src/support.gmo @@ -1,9 +1,7 @@ # support - +lang=en es->apoyo compudanzas as the practice of making computation tangible in dance and paper has been a dream project for many years now. -en español: {apoyo} - => ./img/foto_laconsagracion_04.jpg photo of pieces of wood in the floor, with some hands manipulating them i have decided to transition towards giving the project my full attention and energy. diff --git a/src/tutorial_de_uxn.gmo b/src/tutorial_de_uxn.gmo index 43ba412..da33116 100644 --- a/src/tutorial_de_uxn.gmo +++ b/src/tutorial_de_uxn.gmo @@ -1,5 +1,5 @@ # tutorial de uxn - +lang=es en->uxn tutorial una guía introductoria y pausada para programar la computadora varvara basada en el núcleo {uxn}. > El ecosistema de Uxn es un espacio de juego y exploración de computación personal, creado para desarrollar y utilizar pequeñas herramientas y juegos y programable en su propio lenguaje ensamblador. diff --git a/src/uxn_tutorial.gmo b/src/uxn_tutorial.gmo index 45ca155..1937345 100644 --- a/src/uxn_tutorial.gmo +++ b/src/uxn_tutorial.gmo @@ -1,13 +1,11 @@ # uxn tutorial - +lang=en es->tutorial de uxn welcome to this beginner's, slow-paced and comprehensive guide for programming the varvara computer based on the {uxn} core. you can get an offline version of this guide as the {introduction to uxn programming book}! if you prefer video, you can watch a short {intro to uxn programming} workshop that we taught as an introduction. -there's a translation to spanish: {tutorial de uxn} - # day 1 in this first section of the tutorial we talk about the basics of the uxn computer called varvara, its programming paradigm in a language called uxntal, its architecture, and why you would want to learn to program it. diff --git a/templates/estilo.css b/templates/estilo.css index c1f54bb..87bb4cc 100644 --- a/templates/estilo.css +++ b/templates/estilo.css @@ -90,6 +90,13 @@ table td { td.num{ text-align:right; } +#translation{ + font-size: smaller; + font-style: italic; +} +#incoming{ + font-size: smaller; +} /* desktop */ @media screen and (min-width: 600px) { diff --git a/templates/pagefooter_es.gmi b/templates/pagefooter_es.gmi new file mode 100644 index 0000000..c2ace83 --- /dev/null +++ b/templates/pagefooter_es.gmi @@ -0,0 +1,5 @@ + +# meta +=> ./home.gmi {title} +=> ./contacto.gmi contacto +=> https://endefensadelsl.org/ppl_deed_es.html textos, imágenes y código compartidos bajo la licencia de producción de pares diff --git a/templates/pagefooter_es.html b/templates/pagefooter_es.html new file mode 100644 index 0000000..84f31bf --- /dev/null +++ b/templates/pagefooter_es.html @@ -0,0 +1,15 @@ + + + diff --git a/templates/pageheader.gmi b/templates/pageheader.gmi index 00b41b0..f776961 100644 --- a/templates/pageheader.gmi +++ b/templates/pageheader.gmi @@ -1,2 +1,2 @@ # {ptitle} - +{gemtranslation} diff --git a/templates/pageheader.html b/templates/pageheader.html index 0cc7c10..074293e 100644 --- a/templates/pageheader.html +++ b/templates/pageheader.html @@ -20,8 +20,9 @@
-

icono de compudanzas

+

{title}

{ptitle}

+ {webtranslation}