[svn-commits] murf: trunk r46773 - in /trunk: apps/app_voicemail.c main/say.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Nov 1 11:14:17 MST 2006


Author: murf
Date: Wed Nov  1 12:14:17 2006
New Revision: 46773

URL: http://svn.digium.com/view/asterisk?rev=46773&view=rev
Log:
This introduces Brazilian Portuguese via 7663

Modified:
    trunk/apps/app_voicemail.c
    trunk/main/say.c

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?rev=46773&r1=46772&r2=46773&view=diff
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Wed Nov  1 12:14:17 2006
@@ -210,17 +210,17 @@
 /*! \page vmlang Voicemail Language Syntaxes Supported
 
 	\par Syntaxes supported, not really language codes.
-	\arg \b en - English
-	\arg \b de - German
-	\arg \b es - Spanish
-	\arg \b fr - French
-	\arg \b it = Italian
-	\arg \b nl - Dutch
-	\arg \b pt - Polish
-	\arg \b pt - Portuguese
-	\arg \b gr - Greek
-	\arg \b no - Norwegian
-	\arg \b se - Swedish
+	\arg \b en    - English
+	\arg \b de    - German
+	\arg \b es    - Spanish
+	\arg \b fr    - French
+	\arg \b it    - Italian
+	\arg \b nl    - Dutch
+	\arg \b pt    - Portuguese
+	\arg \b pt_BR - Portuguese (Brazil)
+	\arg \b gr    - Greek
+	\arg \b no    - Norwegian
+	\arg \b se    - Swedish
 
 German requires the following additional soundfile:
 \arg \b 1F	einE (feminine)
@@ -4116,6 +4116,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
@@ -4674,7 +4676,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")){
@@ -5076,6 +5078,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)
 {
@@ -5391,6 +5441,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 */
@@ -5802,7 +5854,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: trunk/main/say.c
URL: http://svn.digium.com/view/asterisk/trunk/main/say.c?rev=46773&r1=46772&r2=46773&view=diff
==============================================================================
--- trunk/main/say.c (original)
+++ trunk/main/say.c Wed Nov  1 12:14:17 2006
@@ -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));
@@ -1988,6 +1991,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)) {
@@ -2710,7 +2717,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));
@@ -2947,7 +2954,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));
@@ -4940,8 +4947,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':
@@ -4955,66 +4966,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 */
@@ -5077,29 +5148,40 @@
 				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 == 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);
+					} 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 {
+						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);
+							}
 						}
 					}
 				}
@@ -5408,6 +5490,9 @@
 		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") ) {	/* Taiwanese syntax */
 	} 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 */
@@ -5545,6 +5630,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)
 {
@@ -5597,6 +5710,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 */
@@ -5806,6 +5921,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)
 {
@@ -5870,7 +5997,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));
 	}
 
@@ -5989,14 +6116,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 svn-commits mailing list