Index: say.c
===================================================================
RCS file: /usr/cvsroot/asterisk/say.c,v
retrieving revision 1.16
diff -u -r1.16 say.c
--- say.c	20 Feb 2004 17:43:46 -0000	1.16
+++ say.c	4 Apr 2004 18:08:30 -0000
@@ -91,8 +91,77 @@
 	char fn[256] = "";
 	if (!num) 
 		return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
-	if (0) {
-	/* XXX Only works for english XXX */
+	if (strcasecmp(language, "da") == 0) {
+		/* The grammer for Danish numbers is the same as for English except
+ 		 * for the following:
+		 * - numbers 20 through 99 are said in reverse order, i.e. 21 is
+		 *   "one-and twenty" and 68 is "eight-and sixty".
+		 * - "million" is different in singular and plural form
+		 * - numbers > 1000 with zero as the third digit from last have an
+		 *   "and" before the last two digits, i.e. 2034 is "two thousand and
+		 *   four-and thirty" and 1000012 is "one million and twelve".
+		 */
+		while(!res && (num || playh || playa)) {
+			if (playh) {
+				snprintf(fn, sizeof(fn), "digits/hundred");
+				playh = 0;
+			} else
+			if (playa) {
+				snprintf(fn, sizeof(fn), "digits/and");
+				playa = 0;
+			} else
+			if (num < 20) {
+				snprintf(fn, sizeof(fn), "digits/%d", num);
+				num = 0;
+			} else
+			if (num < 100) {
+				int ones = num % 10;
+				if (ones) {
+					snprintf(fn, sizeof(fn), "digits/%d-and", ones);
+					num -= ones;
+				} else {
+					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) {
+						res = ast_say_number(chan, num / 1000, ints, language);
+						if (res)
+							return res;
+						num = num % 1000;
+						snprintf(fn, sizeof(fn), "digits/thousand");
+					} else {
+						if (num < 1000000000) {
+							int millions = num / 1000000;
+							res = ast_say_number(chan, millions, ints, language);
+							if (res)
+								return res;
+							if (millions == 1)
+								snprintf(fn, sizeof(fn), "digits/million");
+							else
+								snprintf(fn, sizeof(fn), "digits/millions");
+							num = num % 1000000;
+						} else {
+							ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+							res = -1;
+						}
+					}
+					if (num < 100)
+						playa++;
+				}
+			}
+			if (!res) {
+				res = ast_streamfile(chan, fn, language);
+				if (!res) 
+					res = ast_waitstream(chan, ints);
+				ast_stopstream(chan);
+			}
+		}
 	} else {
 		/* Use english numbers if a given language is supported. */
 		/* As a special case, Norwegian has the same numerical grammar
@@ -154,11 +223,81 @@
 	/* XXX Should I be merged with ast_say_number_full XXX */
 	int res = 0;
 	int playh = 0;
+	int playa = 0;
 	char fn[256] = "";
 	if (!num) 
 		return ast_say_digits(chan, 0,ints, language);
-	if (0) {
-	/* XXX Only works for english XXX */
+	if (strcasecmp(language, "da") == 0) {
+		/* The grammer for Danish numbers is the same as for English except
+ 		 * for the following:
+		 * - numbers 20 through 99 are said in reverse order, i.e. 21 is
+		 *   "one-and twenty" and 68 is "eight-and sixty".
+		 * - "million" is different in singular and plural form
+		 * - numbers > 1000 with zero as the third digit from last have an
+		 *   "and" before the last two digits, i.e. 2034 is "two thousand and
+		 *   four-and thirty" and 1000012 is "one million and twelve".
+		 */
+		while(!res && (num || playh || playa)) {
+			if (playh) {
+				snprintf(fn, sizeof(fn), "digits/hundred");
+				playh = 0;
+			} else
+			if (playa) {
+				snprintf(fn, sizeof(fn), "digits/and");
+				playa = 0;
+			} else
+			if (num < 20) {
+				snprintf(fn, sizeof(fn), "digits/%d", num);
+				num = 0;
+			} else
+			if (num < 100) {
+				int ones = num % 10;
+				if (ones) {
+					snprintf(fn, sizeof(fn), "digits/%d-and", ones);
+					num -= ones;
+				} else {
+					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) {
+						res = ast_say_number(chan, num / 1000, ints, language);
+						if (res)
+							return res;
+						num = num % 1000;
+						snprintf(fn, sizeof(fn), "digits/thousand");
+					} else {
+						if (num < 1000000000) {
+							int millions = num / 1000000;
+							res = ast_say_number(chan, millions, ints, language);
+							if (res)
+								return res;
+							if (millions == 1)
+								snprintf(fn, sizeof(fn), "digits/million");
+							else
+								snprintf(fn, sizeof(fn), "digits/millions");
+							num = num % 1000000;
+						} else {
+							ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+							res = -1;
+						}
+					}
+					if (num < 100)
+						playa++;
+				}
+			}
+			if (!res) {
+				res = ast_streamfile(chan, fn, language);
+				if (!res) 
+					res = ast_waitstream(chan, ints);
+				ast_stopstream(chan);
+			}
+		}
 	} else {
 		/* Use english numbers */
 		language = "en";
