Add Czech digit/voicemail support
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3731 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
93ab11ea61
commit
2184e52764
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Meet me conference bridge
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
* Copyright (C) 1999-2004, Digium, Inc.
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
*
|
||||
|
|
|
@ -3318,6 +3318,82 @@ static int vm_intro_pt(struct ast_channel *chan,struct vm_state *vms)
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* CZECH syntax */
|
||||
/* in czech there must be declension of word new and message
|
||||
* czech : english : czech : english
|
||||
* --------------------------------------------------------
|
||||
* vm-youhave : you have
|
||||
* vm-novou : one new : vm-zpravu : message
|
||||
* vm-nove : 2-4 new : vm-zpravy : messages
|
||||
* vm-novych : 5-infinite new : vm-zprav : messages
|
||||
* vm-starou : one old
|
||||
* vm-stare : 2-4 old
|
||||
* vm-starych : 5-infinite old
|
||||
* jednu : one - falling 4.
|
||||
* vm-no : no ( no messages )
|
||||
*/
|
||||
|
||||
static int vm_intro_cz(struct ast_channel *chan,struct vm_state *vms)
|
||||
{
|
||||
int res;
|
||||
res = play_and_wait(chan, "vm-youhave");
|
||||
if (!res) {
|
||||
if (vms->newmessages) {
|
||||
if (vms->newmessages == 1) {
|
||||
res = play_and_wait(chan, "digits/jednu");
|
||||
} else {
|
||||
res = say_and_wait(chan, vms->newmessages, chan->language);
|
||||
}
|
||||
if (!res) {
|
||||
if ((vms->newmessages == 1))
|
||||
res = play_and_wait(chan, "vm-novou");
|
||||
if ((vms->newmessages) > 1 && (vms->newmessages < 5))
|
||||
res = play_and_wait(chan, "vm-nove");
|
||||
if (vms->newmessages > 4)
|
||||
res = play_and_wait(chan, "vm-novych");
|
||||
}
|
||||
if (vms->oldmessages && !res)
|
||||
res = play_and_wait(chan, "vm-and");
|
||||
else if (!res) {
|
||||
if ((vms->newmessages == 1))
|
||||
res = play_and_wait(chan, "vm-zpravu");
|
||||
if ((vms->newmessages) > 1 && (vms->newmessages < 5))
|
||||
res = play_and_wait(chan, "vm-zpravy");
|
||||
if (vms->newmessages > 4)
|
||||
res = play_and_wait(chan, "vm-zprav");
|
||||
}
|
||||
}
|
||||
if (!res && vms->oldmessages) {
|
||||
res = say_and_wait(chan, vms->oldmessages, chan->language);
|
||||
if (!res) {
|
||||
if ((vms->oldmessages == 1))
|
||||
res = play_and_wait(chan, "vm-starou");
|
||||
if ((vms->oldmessages) > 1 && (vms->oldmessages < 5))
|
||||
res = play_and_wait(chan, "vm-stare");
|
||||
if (vms->oldmessages > 4)
|
||||
res = play_and_wait(chan, "vm-starych");
|
||||
}
|
||||
if (!res) {
|
||||
if ((vms->oldmessages == 1))
|
||||
res = play_and_wait(chan, "vm-zpravu");
|
||||
if ((vms->oldmessages) > 1 && (vms->oldmessages < 5))
|
||||
res = play_and_wait(chan, "vm-zpravy");
|
||||
if (vms->oldmessages > 4)
|
||||
res = play_and_wait(chan, "vm-zprav");
|
||||
}
|
||||
}
|
||||
if (!res) {
|
||||
if (!vms->oldmessages && !vms->newmessages) {
|
||||
res = play_and_wait(chan, "vm-no");
|
||||
if (!res)
|
||||
res = play_and_wait(chan, "vm-zpravy");
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static int vm_instructions(struct ast_channel *chan, struct vm_state *vms, int skipadvanced)
|
||||
{
|
||||
int res = 0;
|
||||
|
@ -3712,6 +3788,8 @@ static int vm_execmain(struct ast_channel *chan, void *data)
|
|||
cmd = vm_intro_nl(chan, &vms);
|
||||
} else if (!strcasecmp(chan->language, "pt")) { /* PORTUGUESE syntax */
|
||||
cmd = vm_intro_pt(chan, &vms);
|
||||
} else if (!strcasecmp(chan->language, "cz")) { /* CZECH syntax */
|
||||
cmd = vm_intro_cz(chan, &vms);
|
||||
} else { /* Default to ENGLISH */
|
||||
cmd = vm_intro(chan, &vms);
|
||||
}
|
||||
|
|
115
say.c
115
say.c
|
@ -17,6 +17,7 @@
|
|||
#include <netinet/in.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <asterisk/file.h>
|
||||
#include <asterisk/channel.h>
|
||||
#include <asterisk/logger.h>
|
||||
|
@ -453,6 +454,7 @@ static int ast_say_number_full_pl(struct ast_channel *chan, int num, char *ints,
|
|||
static int ast_say_number_full_pt(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd);
|
||||
static int ast_say_number_full_se(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd);
|
||||
static int ast_say_number_full_tw(struct ast_channel *chan, int num, char *ints, char *language, int audiofd, int ctrlfd);
|
||||
static int ast_say_number_full_cz(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd);
|
||||
|
||||
/* Forward declarations of ast_say_date, ast_say_datetime and ast_say_time functions */
|
||||
static int ast_say_date_en(struct ast_channel *chan, time_t t, char *ints, char *lang);
|
||||
|
@ -514,7 +516,9 @@ int ast_say_number_full(struct ast_channel *chan, int num, char *ints, char *lan
|
|||
} else if (!strcasecmp(language, "se") ) { /* Swedish syntax */
|
||||
return(ast_say_number_full_se(chan, num, ints, language, options, audiofd, ctrlfd));
|
||||
} else if (!strcasecmp(language, "tw")) { /* Taiwanese syntax */
|
||||
return(ast_say_number_full_tw(chan, num, ints, language, audiofd, ctrlfd));
|
||||
return(ast_say_number_full_tw(chan, num, ints, language, audiofd, ctrlfd));
|
||||
} else if (!strcasecmp(language, "cz") ) { /* Czech syntax */
|
||||
return(ast_say_number_full_cz(chan, num, ints, language, options, audiofd, ctrlfd));
|
||||
}
|
||||
|
||||
/* Default to english */
|
||||
|
@ -1699,6 +1703,115 @@ static int ast_say_number_full_tw(struct ast_channel *chan, int num, char *ints,
|
|||
return res;
|
||||
}
|
||||
|
||||
/*--- ast_say_number_full_cz: Czech syntax */
|
||||
/* files needed:
|
||||
* 1m,2m - gender male
|
||||
* 1w,2w - gender female
|
||||
* 3,4,...,20
|
||||
* 30,40,...,90
|
||||
*
|
||||
* hundereds - 100 - sto, 200 - 2ste, 300,400 3,4sta, 500,600,...,900 5,6,...9set
|
||||
*
|
||||
* for each number 10^(3n + 3) exist 3 files represented as:
|
||||
* 1 tousand = jeden tisic = 1_E3
|
||||
* 2,3,4 tousands = dva,tri,ctyri tisice = 2-3_E3
|
||||
* 5,6,... tousands = pet,sest,... tisic = 5_E3
|
||||
*
|
||||
* million = _E6
|
||||
* miliard = _E9
|
||||
* etc...
|
||||
*
|
||||
* tousand, milion are gender male, so 1 and 2 is 1m 2m
|
||||
* miliard is gender female, so 1 and 2 is 1w 2w
|
||||
*/
|
||||
|
||||
static int ast_say_number_full_cz(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd)
|
||||
{
|
||||
int res = 0;
|
||||
int playh = 0;
|
||||
char fn[256] = "";
|
||||
|
||||
int hundered = 0;
|
||||
int left = 0;
|
||||
int length = 0;
|
||||
|
||||
/* options - w = woman, m = man, n = neutral. Defaultl is woman */
|
||||
if (!options)
|
||||
options = "w";
|
||||
|
||||
if (!num)
|
||||
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
|
||||
|
||||
while(!res && (num || playh)) {
|
||||
if (num < 3 ) {
|
||||
snprintf(fn, sizeof(fn), "digits/%d%c",num,options[0]);
|
||||
playh = 0;
|
||||
num = 0;
|
||||
} else if (num < 20) {
|
||||
snprintf(fn, sizeof(fn), "digits/%d",num);
|
||||
playh = 0;
|
||||
num = 0;
|
||||
} else if (num < 100) {
|
||||
snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
|
||||
num -= ((num / 10) * 10);
|
||||
} else if (num < 1000) {
|
||||
hundered = num / 100;
|
||||
if ( hundered == 1 ) {
|
||||
snprintf(fn, sizeof(fn), "digits/1sto");
|
||||
} else if ( hundered == 2 ) {
|
||||
snprintf(fn, sizeof(fn), "digits/2ste");
|
||||
} else {
|
||||
res = ast_say_number_full_cz(chan,hundered,ints,language,options,audiofd,ctrlfd);
|
||||
if (res)
|
||||
return res;
|
||||
if ( hundered == 3 || hundered == 4) {
|
||||
snprintf(fn, sizeof(fn), "digits/sta");
|
||||
} else if ( hundered > 4 ) {
|
||||
snprintf(fn, sizeof(fn), "digits/set");
|
||||
}
|
||||
}
|
||||
num -= (hundered * 100);
|
||||
} else { /* num > 1000 */
|
||||
length = (int)log10(num)+1;
|
||||
while ( (length % 3 ) != 1 ) {
|
||||
length--;
|
||||
}
|
||||
left = num / (exp10(length-1));
|
||||
if ( left == 2 ) {
|
||||
switch (length-1) {
|
||||
case 9: options = "w"; /* 1,000,000,000 gender female */
|
||||
break;
|
||||
default : options = "m"; /* others are male */
|
||||
}
|
||||
}
|
||||
if ( left > 1 ) { /* we dont say "one thousand" but only thousand */
|
||||
res = ast_say_number_full_cz(chan,left,ints,language,options,audiofd,ctrlfd);
|
||||
if (res)
|
||||
return res;
|
||||
}
|
||||
if ( left >= 5 ) { /* >= 5 have the same declesion */
|
||||
snprintf(fn, sizeof(fn), "digits/5_E%d",length-1);
|
||||
} else if ( left >= 2 && left <= 4 ) {
|
||||
snprintf(fn, sizeof(fn), "digits/2-4_E%d",length-1);
|
||||
} else { /* left == 1 */
|
||||
snprintf(fn, sizeof(fn), "digits/1_E%d",length-1);
|
||||
}
|
||||
num -= left * (exp10(length-1));
|
||||
}
|
||||
if (!res) {
|
||||
if(!ast_streamfile(chan, fn, language)) {
|
||||
if (audiofd && ctrlfd) {
|
||||
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
|
||||
} else {
|
||||
res = ast_waitstream(chan, ints);
|
||||
}
|
||||
}
|
||||
ast_stopstream(chan);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int ast_say_date(struct ast_channel *chan, time_t t, char *ints, char *lang)
|
||||
{
|
||||
|
|
Reference in New Issue