aboutsummaryrefslogtreecommitdiff
path: root/doc/ikiwiki/directive/meta/discussion.mdwn
blob: 428f454ab2a3706395f5a633ced8aff1805950fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Is there any reason the [language attribute](https://en.wikipedia.org/wiki/Meta_element#The_language_attribute) is not supported?
--[[LucaCapello]]

> Attached a patch against the Git repository, working on Debian ikiwiki_3.20100815.9. --[[LucaCapello]]

[[patch]]

-----

<pre>
From 680e57fd384b65e289d92054835687f3d6f3a19d Mon Sep 17 00:00:00 2001
From: Luca Capello <luca@pca.it>
Date: Sat, 6 Oct 2012 14:11:19 +0200
Subject: [PATCH] IkiWiki/Plugin/meta.pm: support the language attribute

---
 IkiWiki/Plugin/meta.pm          |    9 +++++++++
 doc/ikiwiki/directive/meta.mdwn |    4 ++++
 2 files changed, 13 insertions(+)

diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index 421f1dc..1a49f0c 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -102,6 +102,10 @@ sub preprocess (@) {
 		$pagestate{$page}{meta}{description}=$value;
 		# fallthrough
 	}
+	elsif ($key eq 'language') {
+		$pagestate{$page}{meta}{language}=$value;
+		# fallthrough
+	}
 	elsif ($key eq 'guid') {
 		$pagestate{$page}{meta}{guid}=$value;
 		# fallthrough
@@ -279,6 +283,11 @@ sub preprocess (@) {
 		push @{$metaheaders{$page}}, '<meta name="'.$key.
 			'" content="'.encode_entities($value).'" />';
 	}
+	elsif ($key eq 'language') {
+		push @{$metaheaders{$page}},
+			'<meta http-equiv="Content-Language" content="'.
+			encode_entities($value).'" />';
+	}
 	elsif ($key eq 'name') {
 		push @{$metaheaders{$page}}, scrub('<meta name="'.
 			encode_entities($value).
diff --git a/doc/ikiwiki/directive/meta.mdwn b/doc/ikiwiki/directive/meta.mdwn
index 984f685..b82fa58 100644
--- a/doc/ikiwiki/directive/meta.mdwn
+++ b/doc/ikiwiki/directive/meta.mdwn
@@ -59,6 +59,10 @@ Supported fields:
   Specifies a short description for the page. This will be put in
   the html header, and can also be displayed by eg, the [[map]] directive.
 
+* language
+
+  Specifies the natural language for the page, for example, "en".
+
 * keywords
 
   Specifies keywords summarizing the contents of the page. This
-- 
1.7.10.4
</pre>

----

I guess patching [[/ikiwiki/directive/meta]] to document the fact this attribute is supported would be good. — [[Jon]]


----

+1 the language attribute works, I see:

     <meta name="language" content="en" />

The problem is that it does not generate the lang attribute in `<html>` and that's what's required for [hyphenation](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens) so this would be welcome too!

Also, being able to use the language variable in templates would be very useful for various css tweaks. — [Hugo](https://hroy.eu)