summaryrefslogtreecommitdiff
path: root/main/say.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2009-05-06 16:28:02 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2009-05-06 16:28:02 +0000
commit829807cd2c6ccb68fa8cd4304b04d333226d0e80 (patch)
treeeb787fadd4c4e2b234fc638f84d1ccf28eb21986 /main/say.c
parent4d840c93b684daffa171eeca6a02fa1fb5daeed4 (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: https://origsvn.digium.com/svn/asterisk/trunk@192772 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/say.c')
-rw-r--r--main/say.c64
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) {