[asterisk-commits] murf: branch 1.4 r52535 - in /branches/1.4: apps/app_voicemail.c main/say.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jan 29 10:57:09 MST 2007


Author: murf
Date: Mon Jan 29 11:57:08 2007
New Revision: 52535

URL: http://svn.digium.com/view/asterisk?view=rev&rev=52535
Log:
this is for 8778 (pt_BR backport to 1.4). It was committed to trunk via 7663. But it wasn't so much an enhancement as a fix for the bad language output for portuguese in Brazil, so, after a lot of prodding from patient Brazilians, here is the same fix for 1.4

Modified:
    branches/1.4/apps/app_voicemail.c
    branches/1.4/main/say.c

Modified: branches/1.4/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_voicemail.c?view=diff&rev=52535&r1=52534&r2=52535
==============================================================================
--- branches/1.4/apps/app_voicemail.c (original)
+++ branches/1.4/apps/app_voicemail.c Mon Jan 29 11:57:08 2007
@@ -223,6 +223,7 @@
 	\arg \b nl - Dutch
 	\arg \b pt - Polish
 	\arg \b pt - Portuguese
+	\arg \b pt_BR - Portuguese (Brazil)
 	\arg \b gr - Greek
 	\arg \b no - Norwegian
 	\arg \b se - Swedish
@@ -4241,6 +4242,8 @@
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' 'digits/hours' k 'digits/e' M 'digits/minutes'", NULL);
 	else if (!strcasecmp(chan->language,"gr"))
 		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
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' IMp", NULL);
 #if 0
@@ -4870,7 +4873,7 @@
 {
 	int cmd;
 
-	if (!strcasecmp(chan->language, "it") || !strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "fr") || !strcasecmp(chan->language, "pt")) { /* Italian, Spanish, French or Portuguese syntax */
+	if (!strcasecmp(chan->language, "it") || !strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "fr") || !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, mbox);
 	} else if (!strcasecmp(chan->language, "gr")){
@@ -5272,6 +5275,54 @@
 return res;
 }
 
+/* BRAZILIAN PORTUGUESE syntax */
+static int vm_intro_pt_BR(struct ast_channel *chan,struct vm_state *vms) {
+	/* Introduce messages they have */
+	int res;
+	if (!vms->oldmessages && !vms->newmessages) {
+		res = ast_play_and_wait(chan, "vm-nomessages");
+		return res;
+	}
+	else {
+		res = ast_play_and_wait(chan, "vm-youhave");
+	}
+	if (vms->newmessages) {
+		if (!res)
+			res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, "f");
+		if ((vms->newmessages == 1)) {
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-message");
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-INBOXs");
+		}
+		else {
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-messages");
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-INBOX");
+		}
+		if (vms->oldmessages && !res)
+			res = ast_play_and_wait(chan, "vm-and");
+	}
+	if (vms->oldmessages) {
+		if (!res)
+			res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, "f");
+		if (vms->oldmessages == 1) {
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-message");
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-Olds");
+		}
+		else {
+			if (!res)
+		res = ast_play_and_wait(chan, "vm-messages");
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-Old");
+		}
+	}
+	return res;
+}
+
 /* FRENCH syntax */
 static int vm_intro_fr(struct ast_channel *chan,struct vm_state *vms)
 {
@@ -5587,6 +5638,8 @@
 		return vm_intro_nl(chan, vms);
 	} else if (!strcasecmp(chan->language, "pt")) {	/* PORTUGUESE syntax */
 		return vm_intro_pt(chan, vms);
+	} else if (!strcasecmp(chan->language, "pt_BR")) {	/* BRAZILIAN PORTUGUESE syntax */
+		return vm_intro_pt_BR(chan, vms);		
 	} else if (!strcasecmp(chan->language, "cz")) {	/* CZECH syntax */
 		return vm_intro_cz(chan, vms);
 	} else if (!strcasecmp(chan->language, "gr")) {	/* GREEK syntax */
@@ -6005,7 +6058,7 @@
 		return vm_browse_messages_es(chan, vms, vmu);
 	} else if (!strcasecmp(chan->language, "it")) { /* ITALIAN */
 		return vm_browse_messages_it(chan, vms, vmu);
-	} else if (!strcasecmp(chan->language, "pt")) {	/* PORTUGUESE */
+	} else if (!strcasecmp(chan->language, "pt") || !strcasecmp(chan->language, "pt_BR")) {	/* PORTUGUESE */
 		return vm_browse_messages_pt(chan, vms, vmu);
 	} else if (!strcasecmp(chan->language, "gr")){
 		return vm_browse_messages_gr(chan, vms, vmu);   /* GREEK */

Modified: branches/1.4/main/say.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/say.c?view=diff&rev=52535&r1=52534&r2=52535
==============================================================================
--- branches/1.4/main/say.c (original)
+++ branches/1.4/main/say.c Mon Jan 29 11:57:08 2007
@@ -270,6 +270,7 @@
       \arg \b no    - Norwegian
       \arg \b pl    - Polish       
       \arg \b pt    - Portuguese
+      \arg \b pt_BR - Portuguese (Brazil)
       \arg \b se    - Swedish
       \arg \b tw    - Taiwanese / Chinese
       \arg \b ru    - Russian
@@ -360,6 +361,7 @@
 static int ast_say_time_fr(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 static int ast_say_time_nl(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 static int ast_say_time_pt(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
+static int ast_say_time_pt_BR(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 static int ast_say_time_tw(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 static int ast_say_time_gr(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 
@@ -368,6 +370,7 @@
 static int ast_say_datetime_fr(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 static int ast_say_datetime_nl(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 static int ast_say_datetime_pt(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
+static int ast_say_datetime_pt_BR(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 static int ast_say_datetime_tw(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 static int ast_say_datetime_gr(struct ast_channel *chan, time_t t, const char *ints, const char *lang);
 
@@ -413,7 +416,7 @@
 	   return(ast_say_number_full_nl(chan, num, ints, language, audiofd, ctrlfd));
 	} else if (!strcasecmp(language, "pl") ) {	/* Polish syntax */
 	   return(ast_say_number_full_pl(chan, num, ints, language, options, audiofd, ctrlfd));
-	} else if (!strcasecmp(language, "pt") ) {	/* Portuguese syntax */
+	} else if (!strcasecmp(language, "pt") || !strcasecmp(language, "pt_BR")) {	/* Portuguese syntax */
 	   return(ast_say_number_full_pt(chan, num, ints, language, options, audiofd, ctrlfd));
 	} else if (!strcasecmp(language, "se") ) {	/* Swedish syntax */
 	   return(ast_say_number_full_se(chan, num, ints, language, options, audiofd, ctrlfd));
@@ -1980,6 +1983,10 @@
 				(!(num % 1000) && (((num / 1000) % 1000) < 100 || !((num / 1000) % 100))) ) )
 				playh = 1;
 			num = num % 1000000;
+		} else {
+			/* number is too big */
+			ast_log(LOG_WARNING, "Number '%d' is too big to say.", num);
+			res = -1;			
 		}
 		if (!res) {
 			if (!ast_streamfile(chan, fn, language)) {
@@ -2696,7 +2703,7 @@
 		return(ast_say_date_fr(chan, t, ints, lang));
 	} else if (!strcasecmp(lang, "nl") ) {	/* Dutch syntax */
 		return(ast_say_date_nl(chan, t, ints, lang));
-	} else if (!strcasecmp(lang, "pt") ) {	/* Portuguese syntax */
+	} else if (!strcasecmp(lang, "pt") || !strcasecmp(lang, "pt_BR")) {	/* Portuguese syntax */
 		return(ast_say_date_pt(chan, t, ints, lang));
 	} else if (!strcasecmp(lang, "gr") ) {  			/* Greek syntax */
 		return(ast_say_date_gr(chan, t, ints, lang));
@@ -2933,7 +2940,7 @@
 		return(ast_say_date_with_format_nl(chan, time, ints, lang, format, timezone));
 	} else if (!strcasecmp(lang, "pl") ) {	/* Polish syntax */
 		return(ast_say_date_with_format_pl(chan, time, ints, lang, format, timezone));
-	} else if (!strcasecmp(lang, "pt") ) {	/* Portuguese syntax */
+	} else if (!strcasecmp(lang, "pt") || !strcasecmp(lang, "pt_BR")) {	/* Portuguese syntax */
 		return(ast_say_date_with_format_pt(chan, time, ints, lang, format, timezone));
 	} else if (!strcasecmp(lang, "tw") || !strcasecmp(lang, "zh") ) {	/* Taiwanese / Chinese syntax */
 		return(ast_say_date_with_format_tw(chan, time, ints, lang, format, timezone));
@@ -4916,8 +4923,12 @@
 				break;
 			case 'm':
 				/* First - Twelfth */
-				snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
-				res = wait_file(chan,ints,nextmsg,lang);
+				if (!strcasecmp(lang, "pt_BR")) {
+					res = ast_say_number(chan, tm.tm_mon+1, ints, lang, (char *) NULL);
+				} else {
+					snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mon +1);
+					res = wait_file(chan,ints,nextmsg,lang);
+				}
 				break;
 			case 'd':
 			case 'e':
@@ -4931,66 +4942,126 @@
 			case 'I':
 			case 'l':
 				/* 12-Hour */
-				if (tm.tm_hour == 0) {
-					if (format[offset] == 'I')
-						res = wait_file(chan, ints, "digits/pt-ah", lang);
-					if (!res)
-						res = wait_file(chan, ints, "digits/pt-meianoite", lang);
-				}
-				else if (tm.tm_hour == 12) {
-					if (format[offset] == 'I')
-						res = wait_file(chan, ints, "digits/pt-ao", lang);
-					if (!res)
-						res = wait_file(chan, ints, "digits/pt-meiodia", lang);
-				}
-				else {
-					if (format[offset] == 'I') {
-						res = wait_file(chan, ints, "digits/pt-ah", lang);
-						if ((tm.tm_hour % 12) != 1)
-							if (!res)
-								res = wait_file(chan, ints, "digits/pt-sss", lang);
-					}
-					if (!res)
-						res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f");
+				if (!strcasecmp(lang, "pt_BR")) {
+					if (tm.tm_hour == 0) {
+						if (format[offset] == 'I')
+							res = wait_file(chan, ints, "digits/pt-a", lang);
+						if (!res)
+							res = wait_file(chan, ints, "digits/pt-meianoite", lang);
+					} else if (tm.tm_hour == 12) {
+						if (format[offset] == 'I')
+							res = wait_file(chan, ints, "digits/pt-ao", lang);
+						if (!res)
+							res = wait_file(chan, ints, "digits/pt-meiodia", lang);
+						} else {
+						if (format[offset] == 'I') {
+							if ((tm.tm_hour % 12) != 1)
+								res = wait_file(chan, ints, "digits/pt-as", lang);
+							else
+								res = wait_file(chan, ints, "digits/pt-a", lang);
+						}
+						if (!res)
+							res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f");
+						if ((!res) && (format[offset] == 'I'))
+						res = ast_say_date_with_format(chan, time, ints, lang, "P", timezone);
+					}
+				} else {
+					if (tm.tm_hour == 0) {
+						if (format[offset] == 'I')
+							res = wait_file(chan, ints, "digits/pt-ah", lang);
+						if (!res)
+							res = wait_file(chan, ints, "digits/pt-meianoite", lang);
+						}
+					else if (tm.tm_hour == 12) {
+						if (format[offset] == 'I')
+							res = wait_file(chan, ints, "digits/pt-ao", lang);
+						if (!res)
+							res = wait_file(chan, ints, "digits/pt-meiodia", lang);
+					}
+					else {
+						if (format[offset] == 'I') {
+							res = wait_file(chan, ints, "digits/pt-ah", lang);
+							if ((tm.tm_hour % 12) != 1)
+								if (!res)
+									res = wait_file(chan, ints, "digits/pt-sss", lang);
+						}
+						if (!res)
+							res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f");
+					}
 				}
 				break;
 			case 'H':
 			case 'k':
 				/* 24-Hour */
-				res = ast_say_number(chan, -tm.tm_hour, ints, lang, NULL);
-				if (!res) {
-					if (tm.tm_hour != 0) {
-						int remainder = tm.tm_hour;
-						if (tm.tm_hour > 20) {
-							res = wait_file(chan,ints, "digits/20",lang);
-							remainder -= 20;
+				if (!strcasecmp(lang, "pt_BR")) {
+					res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
+					if ((!res) && (format[offset] == 'H')) {
+						if (tm.tm_hour > 1) {
+							res = wait_file(chan,ints,"digits/hours",lang);
+						} else {
+							res = wait_file(chan,ints,"digits/hour",lang);
 						}
-						if (!res) {
-							snprintf(nextmsg,sizeof(nextmsg), "digits/%d", remainder);
-							res = wait_file(chan,ints,nextmsg,lang);
+					}
+				} else {
+					res = ast_say_number(chan, -tm.tm_hour, ints, lang, NULL);
+					if (!res) {
+						if (tm.tm_hour != 0) {
+							int remainder = tm.tm_hour;
+							if (tm.tm_hour > 20) {
+								res = wait_file(chan,ints, "digits/20",lang);
+								remainder -= 20;
+							}
+							if (!res) {
+								snprintf(nextmsg,sizeof(nextmsg), "digits/%d", remainder);
+								res = wait_file(chan,ints,nextmsg,lang);
+							}						
 						}
 					}
 				}
 				break;
 			case 'M':
 				/* Minute */
-				if (tm.tm_min == 0) {
-					res = wait_file(chan, ints, "digits/pt-hora", lang);
-					if (tm.tm_hour != 1)
+				if (!strcasecmp(lang, "pt_BR")) {
+					res = ast_say_number(chan, tm.tm_min, ints, lang, NULL);
+					if (!res) {
+						if (tm.tm_min > 1) {
+							res = wait_file(chan,ints,"digits/minutes",lang);
+						} else {
+							res = wait_file(chan,ints,"digits/minute",lang);
+						}
+					}
+				} else {
+					if (tm.tm_min == 0) {
+						res = wait_file(chan, ints, "digits/pt-hora", lang);
+						if (tm.tm_hour != 1)
+							if (!res)
+								res = wait_file(chan, ints, "digits/pt-sss", lang);			} else {
+						res = wait_file(chan,ints,"digits/pt-e",lang);
 						if (!res)
-							res = wait_file(chan, ints, "digits/pt-sss", lang);			} else {
-					res = wait_file(chan,ints,"digits/pt-e",lang);
-					if (!res)
-						res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);	
+							res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);	
+					}
 				}
 				break;
 			case 'P':
 			case 'p':
 				/* AM/PM */
-				if (tm.tm_hour > 12)
-					res = wait_file(chan, ints, "digits/p-m", lang);
-				else if (tm.tm_hour  && tm.tm_hour < 12)
-					res = wait_file(chan, ints, "digits/a-m", lang);
+				if (!strcasecmp(lang, "pt_BR")) {
+					if ((tm.tm_hour != 0) && (tm.tm_hour != 12)) {
+						res = wait_file(chan, ints, "digits/pt-da", lang);
+						if (!res) {
+							if ((tm.tm_hour >= 0) && (tm.tm_hour < 12))
+								res = wait_file(chan, ints, "digits/morning", lang);
+							else if ((tm.tm_hour >= 12) && (tm.tm_hour < 18))
+								res = wait_file(chan, ints, "digits/afternoon", lang);
+							else res = wait_file(chan, ints, "digits/night", lang);
+						}
+					}
+				} else {
+					if (tm.tm_hour > 12)
+						res = wait_file(chan, ints, "digits/p-m", lang);
+					else if (tm.tm_hour  && tm.tm_hour < 12)
+						res = wait_file(chan, ints, "digits/a-m", lang);
+				}
 				break;
 			case 'Q':
 				/* Shorthand for "Today", "Yesterday", or ABdY */
@@ -5053,30 +5124,36 @@
 				break;
 			case 'S':
 				/* Seconds */
-				if (tm.tm_sec == 0) {
-					snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
-					res = wait_file(chan,ints,nextmsg,lang);
-				} else if (tm.tm_sec < 10) {
-					res = wait_file(chan,ints, "digits/oh",lang);
+				if (!strcasecmp(lang, "pt_BR")) {
+					res = ast_say_number(chan, tm.tm_sec, ints, lang, NULL);
 					if (!res) {
+						if (tm.tm_sec > 1) {
+							res = wait_file(chan,ints,"digits/seconds",lang);
+						} else {
+							res = wait_file(chan,ints,"digits/second",lang);
+						}
+					} else if (tm.tm_sec < 10) {
+						res = wait_file(chan,ints, "digits/oh",lang);
+						if (!res) {
+							snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
+							res = wait_file(chan,ints,nextmsg,lang);
+						}
+					} else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
 						snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
 						res = wait_file(chan,ints,nextmsg,lang);
-					}
-				} else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
-					snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
-					res = wait_file(chan,ints,nextmsg,lang);
-				} else {
-					int ten, one;
-					ten = (tm.tm_sec / 10) * 10;
-					one = (tm.tm_sec % 10);
-					snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten);
-					res = wait_file(chan,ints,nextmsg,lang);
-					if (!res) {
-						/* Fifty, not fifty-zero */
-						if (one != 0) {
-							snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
-							res = wait_file(chan,ints,nextmsg,lang);
-						}
+					} else {
+						int ten, one;
+						ten = (tm.tm_sec / 10) * 10;
+						one = (tm.tm_sec % 10);
+						snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten);
+						res = wait_file(chan,ints,nextmsg,lang);
+						if (!res) {
+							/* Fifty, not fifty-zero */
+							if (one != 0) {
+								snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
+								res = wait_file(chan,ints,nextmsg,lang);
+							}
+						}						
 					}
 				}
 				break;
@@ -5383,6 +5460,8 @@
 		return(ast_say_time_nl(chan, t, ints, lang));
 	} else if (!strcasecmp(lang, "pt") ) {	/* Portuguese syntax */
 		return(ast_say_time_pt(chan, t, ints, lang));
+	} else if (!strcasecmp(lang, "pt_BR") ) {	/* Brazilian Portuguese syntax */
+		return(ast_say_time_pt_BR(chan, t, ints, lang));		
 	} else if (!strcasecmp(lang, "tw") || !strcasecmp(lang, "zh") ) {	/* Taiwanese / Chinese syntax */
 		return(ast_say_time_tw(chan, t, ints, lang));
 	} else if (!strcasecmp(lang, "gr") ) {  			/* Greek syntax */
@@ -5520,6 +5599,34 @@
 	return res;
 }
 
+/* Brazilian Portuguese syntax */
+int ast_say_time_pt_BR(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
+{
+	struct tm tm;
+	int res = 0;
+	localtime_r(&t,&tm);
+
+	res = ast_say_number(chan, tm.tm_hour, ints, lang, "f");
+	if (!res) {
+		if (tm.tm_hour > 1)
+			res = wait_file(chan, ints, "digits/hours", lang);
+		else
+			res = wait_file(chan, ints, "digits/hour", lang);
+	}
+	if ((!res) && (tm.tm_min)) {
+		res = wait_file(chan, ints, "digits/pt-e", lang);
+		if (!res)
+			res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
+		if (!res) {
+			if (tm.tm_min > 1)
+				res = wait_file(chan, ints, "digits/minutes", lang);
+			else
+				res = wait_file(chan, ints, "digits/minute", lang);
+		}
+	}
+	return res;
+}
+
 /* Taiwanese / Chinese  syntax */
 int ast_say_time_tw(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 {
@@ -5572,6 +5679,8 @@
 		return(ast_say_datetime_nl(chan, t, ints, lang));
 	} else if (!strcasecmp(lang, "pt") ) {	/* Portuguese syntax */
 		return(ast_say_datetime_pt(chan, t, ints, lang));
+	} else if (!strcasecmp(lang, "pt_BR") ) {	/* Brazilian Portuguese syntax */
+		return(ast_say_datetime_pt_BR(chan, t, ints, lang));		
 	} else if (!strcasecmp(lang, "tw") || !strcasecmp(lang, "zh") ) {	/* Taiwanese / Chinese syntax */
 		return(ast_say_datetime_tw(chan, t, ints, lang));
 	} else if (!strcasecmp(lang, "gr") ) {  			/* Greek syntax */
@@ -5781,6 +5890,18 @@
 	return res;
 }
 
+/* Brazilian Portuguese syntax */
+int ast_say_datetime_pt_BR(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
+{
+	struct tm tm;
+	int res = 0;
+	localtime_r(&t,&tm);
+	res = ast_say_date(chan, t, ints, lang);
+	if (!res)
+		res = ast_say_time(chan, t, ints, lang);
+	return res;
+}
+
 /* Taiwanese / Chinese syntax */
 int ast_say_datetime_tw(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
 {
@@ -5845,7 +5966,7 @@
 		return(ast_say_datetime_from_now_en(chan, t, ints, lang));
 	} else if (!strcasecmp(lang, "fr") ) {	/* French syntax */
 		return(ast_say_datetime_from_now_fr(chan, t, ints, lang));
-	} else if (!strcasecmp(lang, "pt") ) {	/* Portuguese syntax */
+	} else if (!strcasecmp(lang, "pt") || !strcasecmp(lang, "pt_BR")) {	/* Portuguese syntax */
 		return(ast_say_datetime_from_now_pt(chan, t, ints, lang));
 	}
 
@@ -5964,14 +6085,24 @@
 		if (!res)
 			res = wait_file(chan, ints, fn, lang);
 	}	/* Otherwise, it was today */
-	snprintf(fn, sizeof(fn), "digits/pt-ah");
-	if (!res)
-		res = wait_file(chan, ints, fn, lang);
-	if (tm.tm_hour != 1)
-	if (!res)
-		res = wait_file(chan, ints, "digits/pt-sss", lang);
-	if (!res)
-		res = ast_say_time(chan, t, ints, lang);
+	if (!strcasecmp(lang, "pt_BR")) {
+		if (tm.tm_hour > 1) {
+			snprintf(fn, sizeof(fn), "digits/pt-as");
+		} else {
+			snprintf(fn, sizeof(fn), "digits/pt-a");
+		}
+		if (!res)
+			res = wait_file(chan, ints, fn, lang);
+	} else {
+		snprintf(fn, sizeof(fn), "digits/pt-ah");
+		if (!res)
+			res = wait_file(chan, ints, fn, lang);
+		if (tm.tm_hour != 1)
+		if (!res)
+			res = wait_file(chan, ints, "digits/pt-sss", lang);
+		if (!res)
+			res = ast_say_time(chan, t, ints, lang);
+	}
 	return res;
 }
 



More information about the asterisk-commits mailing list