[Asterisk-Dev] say.c Support for Urdu

Atif Rasheed atif at iphonica.com
Wed Jul 13 00:28:26 MST 2005


Hello Russel, Fleming:

I am not a good coder, but just able to change ast_say_number_full_en to 
add support for URDU Digits. specially required if you want to announce 
currency amount and units in URDU. in URDU digits break down starts 
after 100 as compared to 20 in english. so a little change was required, 
if good enough you can add it to CVS.

Regards,
--
Atif


 >    static int ast_say_number_full_urdu(struct ast_channel *chan, int 
num, char *ints, char *language, int audiofd, int ctrlfd);

 >       } else if (!strcasecmp(language, "urdu") ) {    /* Urdu syntax */
 >          return(ast_say_number_full_urdu(chan, num, ints, language, 
audiofd, ctrlfd));


/*---- Urdu sound files needed for Time/Date functions:
minute
second
---- Urdu sound files needed for Currency:
Rupay
Rupia
Paisa
Paisay
/*

/*--- ast_say_number_full_urdu: Urdu syntax */
/*--- Urdu syntax is little different, so we will require alot of extra 
files. from 0 - 99  */
static int ast_say_number_full_urdu(struct ast_channel *chan, int num, 
char *ints, char *language, int audiofd, int ctrlfd)
{
        int res = 0;
        int playh = 0;
        char fn[256] = "";
        if (!num)
                return ast_say_digits_full(chan, 0,ints, language, 
audiofd, ctrlfd);

        while(!res && (num || playh)) {
                        if (playh) {
                                snprintf(fn, sizeof(fn), "digits/hundred");
                                playh = 0;
                        } else  if (num < 100) {
                                snprintf(fn, sizeof(fn), "digits/%d", num);
                                num = 0;
                        } else {
                                if (num < 1000){
                                        snprintf(fn, sizeof(fn), 
"digits/%d", (num/100));
                                        playh++;
                                        num -= ((num / 100) * 100);
                                } else {
                                        if (num < 1000000) { /* 1,000,000 */
                                                res = 
ast_say_number_full_en(chan, num / 1000, ints, language, audiofd, ctrlfd);
                                                if (res)
                                                        return res;
                                                num = num % 1000;
                                                snprintf(fn, sizeof(fn), 
"digits/thousand");
                                        } else {
                                                if (num < 1000000000) { 
/* 1,000,000,000 */
                                                        res = 
ast_say_number_full_en(chan, num / 1000000, ints, language, audiofd, 
ctrlfd);
                                                        if (res)
                                                                return res;
                                                        num = num % 1000000;
                                                        snprintf(fn, 
sizeof(fn), "digits/million");
                                                } else {
                                                        
ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
                                                        res = -1;
                                                }
                                        }
                                }
                        }
                        if (!res) {
                                if(!ast_streamfile(chan, fn, language)) {
                                        if ((audiofd > -1) && (ctrlfd > -1))
                                                res = 
ast_waitstream_full(chan, ints, audiofd, ctrlfd);
                                        else
                                                res = 
ast_waitstream(chan, ints);
                                }
                                ast_stopstream(chan);
                        }
        }
        return res;
}




More information about the asterisk-dev mailing list