mod_vcard_legacy: Add translation of telephone field
authorKim Alvefur <zash@zash.se>
Sat, 01 Sep 2018 23:46:19 +0200
changeset 9255 292d283c7694
parent 9254 3f31e10e8256
child 9256 dbe3ae6f9746
mod_vcard_legacy: Add translation of telephone field
plugins/mod_vcard_legacy.lua
--- a/plugins/mod_vcard_legacy.lua	Sat Sep 01 23:45:58 2018 +0200
+++ b/plugins/mod_vcard_legacy.lua	Sat Sep 01 23:46:19 2018 +0200
@@ -59,6 +59,20 @@
 					end
 					vcard_temp:up();
 				end
+			elseif tag.name == "tel" then
+				local text = tag:get_child_text("uri");
+				if text then
+					if text:sub(1, 4) == "tel:" then
+						text = text:sub(5)
+					end
+					vcard_temp:tag("TEL"):text_tag("NUMBER", text);
+					if tag:find"parameters/type/text#" == "home" then
+						vcard_temp:tag("HOME"):up();
+					elseif tag:find"parameters/type/text#" == "work" then
+						vcard_temp:tag("WORK"):up();
+					end
+					vcard_temp:up();
+				end
 			end
 		end
 	end