Mercurial Hosting > luan
diff website/src/manual.html.luan @ 1929:31f006c64782
translation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 01 May 2025 18:31:05 -0600 |
parents | 4206242c7a13 |
children |
line wrap: on
line diff
--- a/website/src/manual.html.luan Sun Apr 27 04:24:08 2025 -0600 +++ b/website/src/manual.html.luan Thu May 01 18:31:05 2025 -0600 @@ -1,12 +1,26 @@ local Luan = require "luan:Luan.luan" local error = Luan.error +local pairs = Luan.pairs or error() +local String = require "luan:String.luan" +local replace = String.replace or error() +local Table = require "luan:Table.luan" +local concat = Table.concat or error() local Io = require "luan:Io.luan" -local Http = require "luan:http/Http.luan" +local Site_translator = require "luan:gpt/Site_translator.luan" +local get_lang = Site_translator.get_lang or error() +local text_writer = Site_translator.text_writer or error() +local languages = Site_translator.languages or error() +local set_translated = Site_translator.set_translated or error() local Shared = require "site:/lib/Shared.luan" local head = Shared.head or error() local docs_header = Shared.docs_header or error() local show_toc = Shared.show_toc or error() local show_content = Shared.show_content or error() +local show_content_info = Shared.show_content_info or error() +local Translator = require "luan:gpt/Translator.luan" +local translate_html = Translator.translate_html or error() +local Logging = require "luan:logging/Logging.luan" +local logger = Logging.logger "manual.html" local content = { @@ -161,7 +175,7 @@ content = function() %> <p> -The environment of a chunk starts with only one local variable: <code><a href="#require">require</a></code>. This function is used to load and access libraries and other modules. All other variables must be added to the environment using <a href="/manual.html#local_stmt">local declarations</a>. +The environment of a chunk starts with only one local variable: <code><a href="#require">require</a></code>. This function is used to load and access libraries and other modules. All other variables must be added to the environment using <a href="manual.html#local_stmt">local declarations</a>. </p> <p> @@ -2542,7 +2556,7 @@ <code block> function String.digest_message(algorithm,s) - return <a href="/manual.html#Binary.to_hex">Binary.to_hex</a>( <a href="/manual.html#Binary.digest_message">Binary.digest_message</a>( algorithm, <a href="/manual.html#String.to_binary">String.to_binary(s)</a> ) ) + return <a href="manual.html#Binary.to_hex">Binary.to_hex</a>( <a href="manual.html#Binary.digest_message">Binary.digest_message</a>( algorithm, <a href="manual.html#String.to_binary">String.to_binary(s)</a> ) ) end </code> <% @@ -3673,10 +3687,11 @@ return function() - Io.stdout = Http.response.text_writer() + local lang = get_lang() + local html = ` %> <!doctype html> -<html> +<html lang="<%=lang%>"> <head> <% head() %> <title>Luan Reference Manual</title> @@ -3721,9 +3736,25 @@ <% show_toc(content) %> </div> <hr> -<% show_content(content,2) %> +<div placeholder></div> </div> </body> </html> <% + ` + if lang == "en" then + html = replace( html, "<div placeholder></div>", `show_content(content,2)` ) + else + local language = languages[lang] or error(lang) + html = translate_html(html,language) + local parts = {} + for id, info in pairs(content) do + local part = `show_content_info(id,info,2)` + part = translate_html(part,language) + parts[#parts+1] = part + end + html = replace( html, "<div placeholder></div>", concat(parts) ) + set_translated() + end + text_writer().write(html) end