Browse code

New multi-lang setup, README

Jaidyn Lev authored on 2019-01-08 01:15:40
Showing 6 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,58 @@
1
+===============================================================================
2
+LIBERTYBSD-WEBSITE                                      Pretty self-explanatory
3
+===============================================================================
4
+
5
+The LBSD site is written as simple HTML-- no fancy Markdown or whatever.
6
+You can find the raw HTML in base/*.shtml
7
+
8
+----------------------------------------
9
+USAGE
10
+----------------------------------------
11
+To generate the full HTML for every version (in their own directories) run
12
+	`sh gen.sh`
13
+with the repo as your CWD.
14
+
15
+
16
+----------------------------------------
17
+EDITING
18
+----------------------------------------
19
+When editing the HTML, make sure to edit the file in "base/*.shtml".
20
+When (if) you are adding a new string that can possibly be translated, make
21
+sure to add a variable for it in "res/lang/en.sh" (at least), and to add
22
+the string properly:
23
+
24
+	<!--ml.sh LL your_strings_variable_name"-->
25
+
26
+Of course, replace "your_strings_variable_name" with whatever variable-name
27
+you wrote it as in "res/lang/en.sh".
28
+
29
+
30
+----------------------------------------
31
+MULTI-LANG
32
+----------------------------------------
33
+Multi-lang is handled by embedded server-side includes in the HTML-- every
34
+place a string would ordinarily go is replaced by a call to the script
35
+"res/bin/ml.sh" with two arguments:
36
+	* lang-code
37
+	* string-name
38
+
39
+That call, in the HTML, looks like mentioned above in EDITING.
40
+
41
+All strings are stored as shell variables in "res/lang/" under their
42
+respective langcode.
43
+
44
+
45
+----------------------------------------
46
+CREDITS
47
+----------------------------------------
48
+Spanish translation by jorgesumle,
49
+Esperanto translation mainly by Tirifto,
50
+various contributions by Jimmybot.
51
+
52
+
53
+----------------------------------------
54
+BORING STUFF
55
+----------------------------------------
56
+Maintainer is Jaidyn Levesque <jadedctrl@teknik.io>,
57
+license is CC 0,
58
+and sauce is at https://git.eunichx.us/libertybsd-website
... ...
@@ -1,54 +1,54 @@
1 1
 <!--#include file="res/header.html" -->
2 2
 
3
-<title><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_downloads" --> - LibertyBSD</title>
3
+<title><!--ml.sh LL download_downloads" --> - LibertyBSD</title>
4 4
 
5
-<h2><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_downloads" --></h2>
5
+<h2><!--ml.sh LL download_downloads" --></h2>
6 6
 
7
-<h2><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_current_mirrors" --></h2>
7
+<h2><!--ml.sh LL download_current_mirrors" --></h2>
8 8
 
9 9
 <center>
10 10
 <table border=2>
11 11
 	<tr>
12
-		<td><b><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_host" --> </b></td>
13
-		<td><b><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_type" --> </b></td>
14
-		<td><b><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_location" --> </b></td>
15
-		<td><b><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_protocols" --> </b></td>
12
+		<td><b><!--ml.sh LL download_host" --> </b></td>
13
+		<td><b><!--ml.sh LL download_type" --> </b></td>
14
+		<td><b><!--ml.sh LL download_location" --> </b></td>
15
+		<td><b><!--ml.sh LL download_protocols" --> </b></td>
16 16
 	</tr>
17 17
 	<tr>
18 18
 		<td><a href="https://www.allbsd.org/">AllBSD</a></td>
19
-		<td><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_full" --></td>
20
-		<td><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en location_chiba_japan" --></td>
19
+		<td><!--ml.sh LL download_full" --></td>
20
+		<td><!--ml.sh LL location_chiba_japan" --></td>
21 21
 		<td><a href="https://pub.allbsd.org/LibertyBSD/">HTTP(S)</a>,
22 22
 			<a href="ftp://ftp.allbsd.org/pub/LibertyBSD/">FTP</a>,
23 23
 			<a href="rsync://rsync.allbsd.org">rsync</a></td>
24 24
 	</tr>
25 25
 	<tr>
26 26
 		<td><a href="https://delwink.com/">Delwink Software</a></td>
27
-		<td><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_install_only" --></td>
28
-		<td><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en location_usa" --></td>
27
+		<td><!--ml.sh LL download_install_only" --></td>
28
+		<td><!--ml.sh LL location_usa" --></td>
29 29
 		<td><a href="https://delwink.com/pub/LibertyBSD">HTTP(S)</a></td>
30 30
 	</tr>
31 31
 	<tr>
32 32
 		<td><a href="https://libertybsd.net/">LibertyBSD</a></td>
33
-		<td><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_full" --></td>
34
-		<td><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en location_texas_usa" --></td>
33
+		<td><!--ml.sh LL download_full" --></td>
34
+		<td><!--ml.sh LL location_texas_usa" --></td>
35 35
 		<td><a href="https://ftp.libertybsd.net/pub/LibertyBSD">HTTP(S)</a>,
36 36
 			<a href="ftp://ftp.libertybsd.net/pub/LibertyBSD">FTP</a></td>
37 37
 	</tr>
38 38
 </table>
39 39
 </center>
40 40
 
41
-<!-- <h2><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_old_mirrors" --></h2>
41
+<!-- <h2><!--ml.sh LL download_old_mirrors" --></h2>
42 42
 
43
-<p><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_old_mirrors_info" --></h2>
43
+<p><!--ml.sh LL download_old_mirrors_info" --></h2>
44 44
 
45 45
 <center>
46 46
 <table border=2>
47 47
 	<tr>
48
-		<td><b><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_host" --> </b></td>
49
-		<td><b><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_last_version" --> </b></td>
50
-		<td><b><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_location" --> </b></td>
51
-		<td><b><!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en download_protocols" --> </b></td>
48
+		<td><b><!--ml.sh LL download_host" --> </b></td>
49
+		<td><b><!--ml.sh LL download_last_version" --> </b></td>
50
+		<td><b><!--ml.sh LL download_location" --> </b></td>
51
+		<td><b><!--ml.sh LL download_protocols" --> </b></td>
52 52
 	</tr>
53 53
 </table>
54 54
 </center> -->
... ...
@@ -4,41 +4,41 @@
4 4
 
5 5
 <a id="logo" href="res/img/art/logo.png">
6 6
 	<img src="res/img/art/logo.png"
7
-		width=400px alt="<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en art-logo" -->
8
-ibertyBSD's logo">
7
+		width=400px alt="<!--ml.sh LL art-logo" -->
8
+LibertyBSD's logo">
9 9
 
10 10
 
11 11
 <div id="screens">
12 12
 	<a href="res/img/screens/xdm.png">
13 13
 		<img src="res/img/screens/xdm.png"
14
-			width=300px alt="<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en art_xenodm" -->">
14
+			width=300px alt="<!--ml.sh LL art_xenodm" -->">
15 15
 	<a href="res/img/screens/x11.png">
16 16
 		<img src="res/img/screens/x11.png"
17
-			width=300px alt="<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en art_x11" -->">
17
+			width=300px alt="<!--ml.sh LL art_x11" -->">
18 18
 </div>
19 19
 
20 20
 <p id="contact">
21
-	<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en index_raddle" --> <br />
22
-	<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en index_reddit" --> <br />
23
-	<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en index_freenode" -->
21
+	<!--ml.sh LL index_raddle" --> <br />
22
+	<!--ml.sh LL index_reddit" --> <br />
23
+	<!--ml.sh LL index_freenode" -->
24 24
 </p>
25 25
 
26 26
 
27 27
 <div id="description">
28 28
 <p>
29
-<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en index_p1" -->
29
+<!--ml.sh LL index_p1" -->
30 30
 </p>
31 31
 
32 32
 <p>
33
-<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en index_p2" -->
33
+<!--ml.sh LL index_p2" -->
34 34
 </p>
35 35
 
36 36
 <p>
37
-<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en index_p3" -->
37
+<!--ml.sh LL index_p3" -->
38 38
 </p>
39 39
 
40 40
 <p>
41
-<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/lang/ml.sh en index_p4" -->
41
+<!--ml.sh LL index_p4" -->
42 42
 </p>
43 43
 </div>
44 44
 
45 45
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+#!/bin/sh
2
+
3
+# STRING STRING --> NIL
4
+# Replaces the `ml.sh` shorthand w real thing, replace LL with langcode
5
+function process_file
6
+{
7
+	local file="$1"
8
+	local lang="$2"
9
+
10
+	sed -i 's%<!--ml.sh LL%<!--#exec cmd="bash /var/www/htdocs/libertybsd.net/res/bin/ml.sh LL%g' $file
11
+	sed -i 's% LL % '"$lang"' %g' $file
12
+}
13
+
14
+# STRING --> NIL
15
+# Generate a language's SHTML in public/$LANG
16
+function gen_lang_ver
17
+{
18
+	local lang="$1"
19
+	mkdir public 2>/dev/null
20
+	mkdir public/$lang
21
+	cp -r base/* public/$lang/
22
+
23
+	for file in ./public/$lang/*.shtml
24
+	do
25
+		process_file "$file" "$lang"
26
+	done
27
+}
28
+
29
+# NIL --> NIL
30
+# Generate all langauages' SHTML
31
+function gen_all_langs
32
+{
33
+	for file in ./res/lang/*.sh
34
+	do
35
+		local lang_script="$file"
36
+		local lang="$(basename "$lang_script" ".sh")"
37
+
38
+		gen_lang_ver "$lang"
39
+	done
40
+}
41
+
42
+
43
+gen_all_langs
0 44
similarity index 70%
1 45
rename from res/lang/ml.sh
2 46
rename to res/bin/ml.sh
... ...
@@ -8,11 +8,10 @@
8 8
 #	websites, especially in combination with server-side-includes.
9 9
 
10 10
 
11
-if [ $1 == "en" ]
12
-then
13
-	. /var/www/htdocs/libertybsd.net/res/lang/en.sh
14
-fi
15
-
11
+case "$1" in
12
+	"en") . /var/www/htdocs/libertybsd.net/res/lang/en.sh ;;
13
+	"eo") . /var/www/htdocs/libertybsd.net/res/lang/eo.sh ;;
14
+esac
16 15
 
17 16
 var=$2
18 17
 
19 18
deleted file mode 100644
... ...
@@ -1,11 +0,0 @@
1
-#!/bin/sh
2
-
3
-# name: multilang (ml.sh)
4
-# main: jaidyn <jadedctrl@teknik.io>
5
-# lisc: public domain
6
-# desc: prints a specified variable in the specified language (from
7
-#	user-defined language-files, etc). Useful for multi-lang
8
-#	websites, especially in combination with server-side-includes.
9
-
10
-
11
-env