dect
/
asterisk
Archived
13
0
Fork 0

Add support for French, Danish, Portuguese, Spanish, Italian, and Dutch numbers

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2809 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
markster 2004-04-29 02:30:14 +00:00
parent fefa0442a5
commit ea132fd13c
9 changed files with 907 additions and 99 deletions

View File

@ -621,7 +621,7 @@ static int count_exec(struct ast_channel *chan, void *data)
} else {
if (chan->_state != AST_STATE_UP)
ast_answer(chan);
res = ast_say_number(chan, count, "", chan->language);
res = ast_say_number(chan, count, "", chan->language, (char *) NULL); /* Needs gender */
}
LOCAL_USER_REMOVE(u);
return res;

View File

@ -370,7 +370,7 @@ static int say_position(struct queue_ent *qe)
goto posout;
} else {
res += play_file(qe->chan, qe->parent->sound_thereare);
res += ast_say_number(qe->chan, qe->pos, AST_DIGIT_ANY, qe->chan->language);
res += ast_say_number(qe->chan, qe->pos, AST_DIGIT_ANY, qe->chan->language, (char *) NULL); /* Needs gender */
res += play_file(qe->chan, qe->parent->sound_calls);
}
@ -383,7 +383,7 @@ static int say_position(struct queue_ent *qe)
supposed to be only once and we have already said it, say it */
if (avgholdmins > 1 && (qe->parent->announceholdtime) && (!(qe->parent->announceholdtime==1 && qe->last_pos)) ) {
res += play_file(qe->chan, qe->parent->sound_holdtime);
res += ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, qe->chan->language);
res += ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, qe->chan->language, (char*) NULL);
res += play_file(qe->chan, qe->parent->sound_minutes);
}

View File

@ -1706,7 +1706,7 @@ static int count_messages(char *dir)
static int say_and_wait(struct ast_channel *chan, int num)
{
int d;
d = ast_say_number(chan, num, AST_DIGIT_ANY, chan->language);
d = ast_say_number(chan, num, AST_DIGIT_ANY, chan->language, (char *) NULL);
return d;
}
@ -2270,7 +2270,7 @@ static int get_folder(struct ast_channel *chan, int start)
if (d)
return d;
for (x = start; x< 5; x++) {
if ((d = ast_say_number(chan, x, AST_DIGIT_ANY, chan->language)))
if ((d = ast_say_number(chan, x, AST_DIGIT_ANY, chan->language, (char *) NULL)))
return d;
d = play_and_wait(chan, "vm-for");
if (d)
@ -2634,7 +2634,7 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc
res = wait_file2(chan, vms, "vm-message");
if (msg && (msg != vms->lastmsg)) {
if (!res)
res = ast_say_number(chan, msg + 1, AST_DIGIT_ANY, chan->language);
res = ast_say_number(chan, msg + 1, AST_DIGIT_ANY, chan->language, (char *) NULL);
}
}

View File

@ -322,7 +322,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
}
confno = atoi(strchr(confstr,'/') + 1);
ast_stopstream(chan);
ast_say_number(chan, confno, AST_DIGIT_ANY, chan->language);
ast_say_number(chan, confno, AST_DIGIT_ANY, chan->language, (char *) NULL);
res = conf_run(chan, confno, confflags);
if (res<0) break;
input = res;

View File

@ -2350,12 +2350,12 @@ static void bridge_playfile(struct ast_channel *chan,char *sound,int remain) {
res=ast_streamfile(chan,"vm-youhave",chan->language);
res = ast_waitstream(chan, "");
if(min) {
res = ast_say_number(chan,min, AST_DIGIT_ANY, chan->language);
res = ast_say_number(chan,min, AST_DIGIT_ANY, chan->language, (char *) NULL);
res=ast_streamfile(chan,"minutes",chan->language);
res = ast_waitstream(chan, "");
}
if(sec) {
res = ast_say_number(chan,sec, AST_DIGIT_ANY, chan->language);
res = ast_say_number(chan,sec, AST_DIGIT_ANY, chan->language, (char *) NULL);
res=ast_streamfile(chan,"seconds",chan->language);
res = ast_waitstream(chan, "");
}

66
contrib/i18n.testsuite.conf Executable file
View File

@ -0,0 +1,66 @@
; Test Internationalisation of SayNumber()
; #include this into a suitable context
; English
exten => 841,1,Answer
exten => 841,2,Wait,1 ; Allow VoIP sessions time to initialise
exten => 841,3,SetLanguage(en)
exten => 841,4,SayNumber(183) ; one hundred eighty three (NB This sounds wrong to me!)
; French
exten => 842,1,Answer
exten => 842,2,Wait,1 ; Allow VoIP sessions time to initialise
exten => 842,3,SetLanguage(fr)
exten => 842,4,SayNumber(183) ; hundred eighty three
exten => 842,5,SayNumber(283) ; two hundred eighty three
exten => 842,6,SayNumber(1063) ; thousand sixty three
exten => 842,7,SayNumber(2063) ; two thousand sixty three
; Spanish
exten => 843,1,Answer
exten => 843,2,Wait,1 ; Allow VoIP sessions time to initialise
exten => 843,3,SetLanguage(es)
exten => 843,4,SayNumber(21) ; "twentyone"
exten => 843,5,SayNumber(200) ; "twohundred"
exten => 843,6,SayNumber(1000000) ; one million
exten => 843,7,SayNumber(2000000) ; two millions
; Portuguese
exten => 844,1,Answer
exten => 844,2,Wait,1 ; Allow VoIP sessions time to initialise
exten => 844,3,SetLanguage(pt)
exten => 844,4,SayNumber(1) ; one
exten => 844,5,SayNumber(1,f) ; one (feminine)
exten => 844,6,SayNumber(2) ; two
exten => 844,7,SayNumber(2,f) ; two (feminine)
exten => 844,8,SayNumber(183) ; hundred& eighty three
; Italian
exten => 845,1,Answer
exten => 845,2,Wait,1 ; Allow VoIP sessions time to initialise
exten => 845,3,SetLanguage(it)
exten => 845,4,SayNumber(21) ; "twentyone"
exten => 845,5,SayNumber(183) ; hundred eighty three
exten => 845,6,SayNumber(283) ; two hundred eighty three
exten => 845,7,SayNumber(1063) ; thousand sixty three
exten => 845,8,SayNumber(2063) ; two thousands sixty three
; Dutch
exten => 846,1,Answer
exten => 846,2,Wait,1 ; Allow VoIP sessions time to initialise
exten => 846,3,SetLanguage(nl)
; Danish
exten => 847,1,Answer
exten => 847,2,Wait,1 ; Allow VoIP sessions time to initialise
exten => 847,3,SetLanguage(da)
exten => 847,4,SayNumber(68) ; eight-& sixty
exten => 847,5,SayNumber(2034) ; two thousand & four-& thirty
exten => 847,6,SayNumber(1000000) ; one million
exten => 847,7,SayNumber(2000000) ; two millions
; German (not yet implemented)
exten => 848,1,Answer
exten => 848,2,Wait,1 ; Allow VoIP sessions time to initialise
exten => 848,3,SetLanguage(de)
exten => 848,4,SayNumber(68) ; eight-& sixty
exten => 848,5,SayNumber(2034) ; two thousand & four-& thirty
exten => 848,6,SayNumber(1000000) ; one million
exten => 848,7,SayNumber(2000000) ; two millions
; Swedish
exten => 849,1,Answer
exten => 849,2,Wait,1 ; Allow VoIP sessions time to initialise
exten => 849,3,SetLanguage(se)

View File

@ -29,10 +29,11 @@ extern "C" {
* \param num number to say on the channel
* \param ints which dtmf to interrupt on
* \param lang language to speak the number
* \param options set to 'f' for female, 'm' for masculine (used in portuguese)
* Vocally says a number on a given channel
* Returns 0 on success, DTMF digit on interrupt, -1 on failure
*/
int ast_say_number(struct ast_channel *chan, int num, char *ints, char *lang);
int ast_say_number(struct ast_channel *chan, int num, char *ints, char *lang, char *options);
/* Same as above with audiofd for received audio and returns 1 on ctrlfd being readable */
int ast_say_number_full(struct ast_channel *chan, int num, char *ints, char *lang, int audiofd, int ctrlfd);

28
pbx.c
View File

@ -287,7 +287,7 @@ static struct pbx_builtin {
{ "SayNumber", pbx_builtin_saynumber,
"Say Number",
" SayNumber(digits): Says the passed number\n" },
" SayNumber(digits[,gender]): Says the passed number\n" },
{ "SayDigits", pbx_builtin_saydigits,
"Say Digits",
@ -4568,9 +4568,29 @@ static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
static int pbx_builtin_saynumber(struct ast_channel *chan, void *data)
{
int res = 0;
if (data && atoi((char *)data) )
res = ast_say_number(chan, atoi((char *)data), "", chan->language);
return res;
char tmp[256];
char *number = (char *) NULL;
char *options = (char *) NULL;
if (!data || !strlen((char *)data)) {
ast_log(LOG_WARNING, "SayNumber requires an argument (number)\n");
return -1;
}
strncpy(tmp, (char *)data, sizeof(tmp)-1);
number=tmp;
strsep(&number, "|");
options = strsep(&number, "|");
if (options) {
if ( strcasecmp(options, "f") && strcasecmp(options,"m") &&
strcasecmp(options, "c") && strcasecmp(options, "n") ) {
ast_log(LOG_WARNING, "SayNumber gender option is either 'f', 'm', 'c' or 'n'\n");
return -1;
}
}
return res = ast_say_number(chan, atoi((char *) tmp), "", chan->language, options);
}
static int pbx_builtin_saydigits(struct ast_channel *chan, void *data)

891
say.c

File diff suppressed because it is too large Load Diff