[Home]

Summary:ASTERISK-09839: In voicemail, the language of the displayed date inside the mail (VM_DATE) doesn't take into account the system's locale.
Reporter:Corentin Le Gall (clegall_proformatique)Labels:
Date Opened:2007-07-09 04:03:23Date Closed:2007-07-13 07:36:20
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Applications/app_voicemail
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:The language of VM_DATE remains in english language whatever the system's locales.

The setting emaildateformat in /etc/asterisk/voicemail.conf allows one to set the order of the fields in the mail, but not its language.

This happens both in asterisk 1.2 and 1.4.


****** ADDITIONAL INFORMATION ******

I would suggest this code change :


$ svn diff app_voicemail.c
Index: app_voicemail.c
===================================================================
--- app_voicemail.c     (revision 74042)
+++ app_voicemail.c     (working copy)
@@ -49,6 +49,7 @@
#include <sys/mman.h>
#include <time.h>
#include <dirent.h>
+#include <locale.h>

#include "asterisk.h"

@@ -1735,7 +1736,9 @@
               fprintf(p, "Date: %s\n", date);

               /* Set date format for voicemail mail */
+               setlocale(LC_ALL, "");
               strftime(date, sizeof(date), emaildateformat, &tm);
+               setlocale(LC_ALL, "C");

               if (*fromstring) {
                       struct ast_channel *ast = ast_channel_alloc(0);
Comments:By: Tilghman Lesher (tilghman) 2007-07-09 10:38:05

The suggested patch is not thread-safe.  I would suggest that you make use of the corresponding environmental variables, prior to starting your process instead.

By: Corentin Le Gall (clegall_proformatique) 2007-07-13 05:56:15

What about using strftime_l() then ?


This would give, for asterisk 1.2 (vs. svn 75031) :


Index: apps/app_voicemail.c
===================================================================
--- apps/app_voicemail.c        (revision 75031)
+++ apps/app_voicemail.c        (working copy)
@@ -49,6 +49,7 @@
#include <sys/mman.h>
#include <time.h>
#include <dirent.h>
+#include <locale.h>

#include "asterisk.h"

@@ -1685,6 +1686,7 @@
       struct vm_zone *the_zone = NULL;
       int len_passdata;
       char *passdata2;
+       locale_t loc;

       if (vmu && ast_strlen_zero(vmu->email)) {
               ast_log(LOG_WARNING, "E-mail address missing for mailbox [%s].  E-mail will not be sent.\n", vmu->mailbox);
@@ -1735,7 +1737,8 @@
               fprintf(p, "Date: %s\n", date);

               /* Set date format for voicemail mail */
-               strftime(date, sizeof(date), emaildateformat, &tm);
+               loc = newlocale (LC_ALL_MASK, "", NULL);
+               strftime_l(date, sizeof(date), emaildateformat, &tm, loc);

               if (*fromstring) {
                       struct ast_channel *ast = ast_channel_alloc(0);


And, for asterisk 1.4 (vs. svn 75031 too) :


Index: apps/app_voicemail.c
===================================================================
--- apps/app_voicemail.c        (revision 75031)
+++ apps/app_voicemail.c        (working copy)
@@ -66,6 +66,7 @@
#include <sys/mman.h>
#include <time.h>
#include <dirent.h>
+#include <locale.h>
#ifdef IMAP_STORAGE
#include <ctype.h>
#include <signal.h>
@@ -1843,6 +1844,7 @@
       struct tm tm;
       char *passdata2;
       size_t len_passdata;
+       locale_t loc;
#ifdef IMAP_STORAGE
#define ENDL "\r\n"
#else
@@ -1860,7 +1862,8 @@
       fprintf(p, "Date: %s" ENDL, date);

       /* Set date format for voicemail mail */
-       strftime(date, sizeof(date), emaildateformat, &tm);
+       loc = newlocale (LC_ALL_MASK, "", NULL);
+       strftime_l(date, sizeof(date), emaildateformat, &tm, loc);

       if (*fromstring) {
               struct ast_channel *ast;


Thanks.

By: Tilghman Lesher (tilghman) 2007-07-13 07:29:09

That function does not exist on either Linux or FreeBSD, which are the main development platforms.

By: Tilghman Lesher (tilghman) 2007-07-13 07:36:20

You're still missing the point, which is that your ENVIRONMENT needs to be set correctly.