--- asterisk-1.6.2.0-rc6/apps/app_voicemail.c	2009-10-19 07:13:31.000000000 +0700
+++ /home/dinhtrung/Projects/asterisk-vi/asterisk-1.6.2.0~rc2/apps/app_voicemail.c	2009-11-22 02:15:11.965322905 +0700
@@ -6806,6 +6765,8 @@
 		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 (!strncasecmp(chan->language, "zh", 2)) /* CHINESE (Taiwan) syntax */
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "qR 'vm-received'", NULL);		
+	else if (!strcasecmp(chan->language, "vi"))      /* Vietnamese syntax : nhận được thứ 6 ngày 23 tháng 10 năm 2009 lúc 23 giờ 35 phút*/
+		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' A 'digits/day' dB 'digits/year' Y 'digits/at' k 'hours' M 'minutes'", NULL);				
 	else {
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' IMp", NULL);
 	}
@@ -6942,10 +6903,12 @@
 	vms->starting = 0; 
 	make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
 	adsi_message(chan, vms);
+	if (strcasecmp(chan->language, "vi")){
 	if (!vms->curmsg)
 		res = wait_file2(chan, vms, "vm-first");	/* "First" */
 	else if (vms->curmsg == vms->lastmsg)
 		res = wait_file2(chan, vms, "vm-last");		/* "last" */
+	}
 
 	snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
 	RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
@@ -6987,7 +6950,7 @@
 			if (!res)
 				res = wait_file2(chan, vms, "vm-message");
 		/* HEBREW syntax */
-		} else if (!strcasecmp(chan->language, "he")) {
+		} else if (!strcasecmp(chan->language, "he") || !strcasecmp(chan->language, "vi")) {
 			if (!vms->curmsg) {
 				res = wait_file2(chan, vms, "vm-message");
 				res = wait_file2(chan, vms, "vm-first");
@@ -7320,6 +7283,8 @@
 	if (!strcasecmp(chan->language, "it") || !strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "pt") || !strcasecmp(chan->language, "pt_BR")) { /* Italian, Spanish, French or Portuguese syntax */
 		cmd = ast_play_and_wait(chan, "vm-messages"); /* "messages */
 		return cmd ? cmd : ast_play_and_wait(chan, box);
+	} else if (!strcasecmp(chan->language, "vi")){
+		return ast_play_and_wait(chan, box);
 	} else if (!strcasecmp(chan->language, "gr")){
 		return vm_play_folder_name_gr(chan, box);
 	} else if (!strcasecmp(chan->language, "pl")){
@@ -8199,6 +8164,39 @@
 	return res;
 }
 
+/* Vietnamese syntax */
+static int vm_intro_vi(struct ast_channel *chan, struct vm_state *vms)
+{
+	int res;
+
+	/* Introduce messages they have */
+	res = ast_play_and_wait(chan, "vm-youhave");
+	if (!res) {
+		if (vms->newmessages) {
+			res = say_and_wait(chan, vms->newmessages, chan->language);
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-INBOX");
+			if (vms->oldmessages && !res)
+				res = ast_play_and_wait(chan, "vm-and");
+				
+		}
+		if (!res && vms->oldmessages) {
+			res = say_and_wait(chan, vms->oldmessages, chan->language);
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-Old");			
+		}
+		if (!res) {
+			if (!vms->oldmessages && !vms->newmessages) {
+				res = ast_play_and_wait(chan, "vm-no");
+				if (!res)
+					res = ast_play_and_wait(chan, "vm-message");
+			}
+		}
+	}
+	return res;
+}
+
+
 static int vm_intro(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
 {
 	char prefile[256];
@@ -8246,6 +8244,8 @@
 		return vm_intro_multilang(chan, vms, "n");
 	} else if (!strcasecmp(chan->language, "he")) { /* HEBREW syntax */
 		 return vm_intro_he(chan, vms);
+	} else if (!strcasecmp(chan->language, "vi")) { /* VIETNAMESE syntax */
+		 return vm_intro_vi(chan, vms);
 	} else {					/* Default to ENGLISH */
 		return vm_intro_en(chan, vms);
 	}
@@ -8838,6 +8838,24 @@
 	return cmd;
 }
 
+/* Vietnamese Syntax */
+static int vm_browse_messages_vi(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-no");
+		if (!cmd) {
+			snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox);
+			cmd = ast_play_and_wait(chan, vms->fn);
+		}
+	}
+	return cmd;
+}
+
+
 /*!
  * \brief Top level method to invoke the language variant vm_browse_messages_XX function.
  * \param chan The channel for the current user. We read the language property from this.
@@ -8863,6 +8881,8 @@
 		return vm_browse_messages_zh(chan, vms, vmu);   /* CHINESE (Taiwan) */
 	} else if (!strcasecmp(chan->language, "he")) {
 		return vm_browse_messages_he(chan, vms, vmu);   /* HEBREW */
+	} else if (!strcasecmp(chan->language, "vi")) {
+		return vm_browse_messages_vi(chan, vms, vmu);   /* VIETNAMESE */
 	} else {	/* Default to English syntax */
 		return vm_browse_messages_en(chan, vms, vmu);
 	}
