--- app_voicemail.c.orig	2007-06-13 21:45:17.000000000 +0800
+++ app_voicemail.c	2007-06-13 21:42:57.000000000 +0800
@@ -233,6 +233,7 @@
 	\arg \b gr - Greek
 	\arg \b no - Norwegian
 	\arg \b se - Swedish
+	\arg \b tw - Chinese (Taiwan)
 
 German requires the following additional soundfile:
 \arg \b 1F	einE (feminine)
@@ -285,6 +286,15 @@
 \arg \b vm-vecchio	old
 \arg \b vm-vecchi	old plural
 
+Chinese (Taiwan) requires the following additional soundfile:
+\arg \b vm-tong		A class-word for call (tong1)
+\arg \b vm-ri		A class-word for day (ri4)
+\arg \b vm-you		You (ni3)
+\arg \b vm-haveno   Have no (mei2 you3)
+\arg \b vm-have	    Have (you3)
+\arg \b vm-listen   To listen (yao4 ting1)
+
+
 \note Don't use vm-INBOX or vm-Old, because they are the name of the INBOX and Old folders,
 spelled among others when you have to change folder. For the above reasons, vm-INBOX
 and vm-Old are spelled plural, to make them sound more as folder name than an adjective.
@@ -4258,6 +4268,8 @@
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q  H 'digits/kai' M ", NULL);
 	else if (!strcasecmp(chan->language,"pt_BR"))
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Ad 'digits/pt-de' B 'digits/pt-de' Y 'digits/pt-as' HM ", NULL);		
+	else if (!strcasecmp(chan->language,"tw"))      /* CHINESE (Taiwan) syntax */
+		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "qR 'vm-received'", NULL);		
 	else
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' IMp", NULL);
 #if 0
@@ -5627,6 +5639,48 @@
 	return res;
 }
 
+/* CHINESE (Taiwan) syntax */
+static int vm_intro_tw(struct ast_channel *chan, struct vm_state *vms)
+{
+	int res;
+
+	/* Introduce messages they have */
+	res = ast_play_and_wait(chan, "vm-you");
+
+    if (!res && vms->newmessages) {
+        res = ast_play_and_wait(chan, "vm-have");
+        if (!res)
+            res = say_and_wait(chan, vms->newmessages, chan->language);
+        if (!res)
+            res = ast_play_and_wait(chan, "vm-tong");
+        if (!res)
+            res = ast_play_and_wait(chan, "vm-INBOX");
+        if (vms->oldmessages && !res)
+            res = ast_play_and_wait(chan, "vm-and");
+        else if (!res) 
+            res = ast_play_and_wait(chan, "vm-messages");
+
+    }
+    if (!res && vms->oldmessages) {
+        res = ast_play_and_wait(chan, "vm-have");
+        if (!res)
+            res = say_and_wait(chan, vms->oldmessages, chan->language);
+        if (!res)
+            res = ast_play_and_wait(chan, "vm-tong");
+        if (!res)
+            res = ast_play_and_wait(chan, "vm-Old");
+        if (!res)
+            res = ast_play_and_wait(chan, "vm-messages");
+    }
+    if (!res && !vms->oldmessages && !vms->newmessages) {
+        res = ast_play_and_wait(chan, "vm-haveno");
+        if (!res)
+            res = ast_play_and_wait(chan, "vm-messages");
+    }
+    return res;
+}
+
+
 
 static int vm_intro(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
 {
@@ -5666,12 +5720,14 @@
 		return vm_intro_no(chan, vms);
 	} else if (!strcasecmp(chan->language, "ru")) { /* RUSSIAN syntax */
 		return vm_intro_ru(chan, vms);
+	} else if (!strcasecmp(chan->language, "tw")) { /* CHINESE (Taiwan) syntax */
+		return vm_intro_tw(chan, vms);
 	} else {					/* Default to ENGLISH */
 		return vm_intro_en(chan, vms);
 	}
 }
 
-static int vm_instructions(struct ast_channel *chan, struct vm_state *vms, int skipadvanced)
+static int vm_instructions_en(struct ast_channel *chan, struct vm_state *vms, int skipadvanced)
 {
 	int res = 0;
 	/* Play instructions and wait for new command */
@@ -5718,6 +5774,40 @@
 	return res;
 }
 
+static int vm_instructions_tw(struct ast_channel *chan, struct vm_state *vms, int skipadvanced)
+{
+	int res = 0;
+	/* Play instructions and wait for new command */
+	while (!res) {
+        if (vms->lastmsg > -1) {
+            res = ast_play_and_wait(chan, "vm-listen");
+            if (!res)
+                res = vm_play_folder_name(chan, vms->vmbox);
+            if (!res)
+                res = ast_play_and_wait(chan, "press");
+            if (!res)
+                res = ast_play_and_wait(chan, "digits/1");
+        }
+        if (!res)
+            res = ast_play_and_wait(chan, "vm-opts");
+        if (!res) {
+            vms->starting = 0;
+            return vm_instructions_en(chan,vms,skipadvanced);
+        }
+    }
+	return res;
+}
+
+static int vm_instructions(struct ast_channel *chan, struct vm_state *vms, int skipadvanced)
+{
+	if (vms->starting && !strcasecmp(chan->language, "tw")) { /* CHINESE (Taiwan) syntax */
+		return vm_instructions_tw(chan, vms, skipadvanced);
+	} else {					/* Default to ENGLISH */
+		return vm_instructions_en(chan, vms, skipadvanced);
+	}
+}
+
+
 static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain)
 {
 	int cmd = 0;
@@ -6073,6 +6163,27 @@
 	return cmd;
 }
 
+/* Chinese (Taiwan)syntax */
+static int vm_browse_messages_tw(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
+{
+	int cmd=0;
+
+	if (vms->lastmsg > -1) {
+		cmd = play_message(chan, vmu, vms);
+	} else {
+		cmd = ast_play_and_wait(chan, "vm-you");
+		if (!cmd) 
+			cmd = ast_play_and_wait(chan, "vm-haveno");
+		if (!cmd)
+			cmd = ast_play_and_wait(chan, "vm-messages");
+		if (!cmd) {
+			snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox);
+			cmd = ast_play_and_wait(chan, vms->fn);
+		}
+	}
+	return cmd;
+}
+
 static int vm_browse_messages(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
 {
 	if (!strcasecmp(chan->language, "es")) {	/* SPANISH */
@@ -6083,6 +6194,8 @@
 		return vm_browse_messages_pt(chan, vms, vmu);
 	} else if (!strcasecmp(chan->language, "gr")){
 		return vm_browse_messages_gr(chan, vms, vmu);   /* GREEK */
+	} else if (!strcasecmp(chan->language, "tw")){
+		return vm_browse_messages_tw(chan, vms, vmu);   /* CHINESE (Taiwan) */
 	} else {	/* Default to English syntax */
 		return vm_browse_messages_en(chan, vms, vmu);
 	}
