diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-06 16:28:02 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-06 16:28:02 +0000 |
commit | fe8d8008efba984440087adb01f09c402a58c2a7 (patch) | |
tree | eb787fadd4c4e2b234fc638f84d1ccf28eb21986 /main/say.c | |
parent | 7560b5641bfccf7778a4c70c7acacaf6f3c78528 (diff) |
Add numbers in Urdu, the national language of Pakistan
(closes issue #15034)
Reported by: nasirq
Patches:
ast_say_number_full_ur-patch.c uploaded by nasirq (license 772)
urdu.ods uploaded by nasirq (license 772)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@192772 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/say.c')
-rw-r--r-- | main/say.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/main/say.c b/main/say.c index 46b7d058e..ce946f805 100644 --- a/main/say.c +++ b/main/say.c @@ -349,6 +349,7 @@ static int ast_say_number_full_ru(struct ast_channel *chan, int num, const char static int ast_say_number_full_ge(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd); static int ast_say_number_full_hu(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); static int ast_say_number_full_th(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); +static int ast_say_number_full_ur(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd); /* Forward declarations of language specific variants of ast_say_enumeration_full */ static int ast_say_enumeration_full_en(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); @@ -467,6 +468,8 @@ static int say_number_full(struct ast_channel *chan, int num, const char *ints, return(ast_say_number_full_ru(chan, num, ints, language, options, audiofd, ctrlfd)); } else if (!strcasecmp(language, "th") ) { /* Thai syntax */ return(ast_say_number_full_th(chan, num, ints, language, audiofd, ctrlfd)); + } else if (!strcasecmp(language, "ur") ) { /* Urdu syntax */ + return(ast_say_number_full_ur(chan, num, ints, language, options, audiofd, ctrlfd)); } else if (!strcasecmp(language, "ge") ) { /* Georgian syntax */ return(ast_say_number_full_ge(chan, num, ints, language, options, audiofd, ctrlfd)); } @@ -2352,6 +2355,67 @@ static int ast_say_number_full_tw(struct ast_channel *chan, int num, const char return res; } +/*!\internal + * \brief Counting in Urdu, the national language of Pakistan + * \since 1.6.3 + */ +static int ast_say_number_full_ur(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, 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 < 100000) { /* 1,00,000 */ + if ((res = ast_say_number_full_ur(chan, num / 1000, ints, language, options, audiofd, ctrlfd))) { + return res; + } + num = num % 1000; + snprintf(fn, sizeof(fn), "digits/thousand"); + } else if (num < 10000000) { /* 1,00,00,000 */ + if ((res = ast_say_number_full_ur(chan, num / 100000, ints, language, options, audiofd, ctrlfd))) { + return res; + } + num = num % 100000; + snprintf(fn, sizeof(fn), "digits/lac"); + } else if (num < 1000000000) { /* 1,00,00,00,000 */ + if ((res = ast_say_number_full_ur(chan, num / 10000000, ints, language, options, audiofd, ctrlfd))) { + return res; + } + num = num % 10000000; + snprintf(fn, sizeof(fn), "digits/crore"); + } 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; +} /*! \brief determine last digits for thousands/millions (ru) */ static int get_lastdigits_ru(int num) { |