* Add basic NLS support, so clients can display localized strings during browsing if it's properly enabled.

This commit is contained in:
Justin Maggard 2010-07-17 00:47:48 +00:00
parent c5b2f2171f
commit 291b31f98a
4 changed files with 57 additions and 29 deletions

View File

@ -168,6 +168,14 @@ echo "/*#define HAVE_ICONV_H*/" >> ${CONFIGFILE}
fi fi
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "/* Enable if the system libintl.h exists for NLS support. */" >> ${CONFIGFILE}
if [ -f /usr/include/libintl.h ]; then
echo "#define ENABLE_NLS" >> ${CONFIGFILE}
else
echo "/*#define ENABLE_NLS*/" >> ${CONFIGFILE}
fi
echo "" >> ${CONFIGFILE}
echo "/* Enable NETGEAR-specific tweaks. */" >> ${CONFIGFILE} echo "/* Enable NETGEAR-specific tweaks. */" >> ${CONFIGFILE}
echo "${NETGEAR}" >> ${CONFIGFILE} echo "${NETGEAR}" >> ${CONFIGFILE}
echo "/* Enable ReadyNAS-specific tweaks. */" >> ${CONFIGFILE} echo "/* Enable ReadyNAS-specific tweaks. */" >> ${CONFIGFILE}

View File

@ -27,9 +27,12 @@
#include <pthread.h> #include <pthread.h>
#include <pwd.h> #include <pwd.h>
/* unix sockets */
#include "config.h" #include "config.h"
#ifdef ENABLE_NLS
#include <libintl.h>
#endif
#include "upnpglobalvars.h" #include "upnpglobalvars.h"
#include "sql.h" #include "sql.h"
#include "upnphttp.h" #include "upnphttp.h"
@ -701,6 +704,12 @@ main(int argc, char * * argv)
struct timeval lastbeacontime = {0, 0}; struct timeval lastbeacontime = {0, 0};
#endif #endif
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
setlocale(LC_CTYPE, "en_US.utf8");
textdomain("minidlna");
#endif
if(init(argc, argv) != 0) if(init(argc, argv) != 0)
return 1; return 1;

View File

@ -26,6 +26,11 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include "config.h"
#ifdef ENABLE_NLS
#include <libintl.h>
#endif
#include <sqlite3.h> #include <sqlite3.h>
#include "upnpglobalvars.h" #include "upnpglobalvars.h"
@ -155,7 +160,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
} }
else else
{ {
strcpy(date_taken, "Unknown Date"); strcpy(date_taken, _("Unknown Date"));
} }
if( valid_cache && strcmp(last_date.name, date_taken) == 0 ) if( valid_cache && strcmp(last_date.name, date_taken) == 0 )
{ {
@ -183,7 +188,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
} }
else else
{ {
strcpy(camera, "Unknown Camera"); strcpy(camera, _("Unknown Camera"));
} }
if( !valid_cache || strcmp(camera, last_cam.name) != 0 ) if( !valid_cache || strcmp(camera, last_cam.name) != 0 )
{ {
@ -274,7 +279,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
strcpy(last_artist.name, artist); strcpy(last_artist.name, artist);
last_artistAlbum.name[0] = '\0'; last_artistAlbum.name[0] = '\0';
/* Add this file to the "- All Albums -" container as well */ /* Add this file to the "- All Albums -" container as well */
container = insert_container("- All Albums -", last_artist.parentID, NULL, "storageFolder", artist, genre, NULL); container = insert_container(_("- All Albums -"), last_artist.parentID, NULL, "storageFolder", artist, genre, NULL);
sprintf(last_artistAlbumAll.parentID, "%s$%llX", last_artist.parentID, container>>32); sprintf(last_artistAlbumAll.parentID, "%s$%llX", last_artist.parentID, container>>32);
last_artistAlbumAll.objectID = (int)container; last_artistAlbumAll.objectID = (int)container;
} }
@ -282,17 +287,17 @@ insert_containers(const char * name, const char *path, const char * refID, const
{ {
last_artistAlbumAll.objectID++; last_artistAlbumAll.objectID++;
} }
if( valid_cache && strcmp(album?album:"Unknown Album", last_artistAlbum.name) == 0 ) if( valid_cache && strcmp(album?album:_("Unknown Album"), last_artistAlbum.name) == 0 )
{ {
last_artistAlbum.objectID++; last_artistAlbum.objectID++;
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Using last artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_artist.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Using last artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_artist.objectID);
} }
else else
{ {
container = insert_container(album?album:"Unknown Album", last_artist.parentID, album?last_album.parentID:NULL, "album.musicAlbum", artist, genre, album_art); container = insert_container(album?album:_("Unknown Album"), last_artist.parentID, album?last_album.parentID:NULL, "album.musicAlbum", artist, genre, album_art);
sprintf(last_artistAlbum.parentID, "%s$%llX", last_artist.parentID, container>>32); sprintf(last_artistAlbum.parentID, "%s$%llX", last_artist.parentID, container>>32);
last_artistAlbum.objectID = (int)container; last_artistAlbum.objectID = (int)container;
strcpy(last_artistAlbum.name, album?album:"Unknown Album"); strcpy(last_artistAlbum.name, album?album:_("Unknown Album"));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_artist.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_artist.objectID);
} }
sql_exec(db, "INSERT into OBJECTS" sql_exec(db, "INSERT into OBJECTS"
@ -315,7 +320,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
strcpy(last_genre.name, genre); strcpy(last_genre.name, genre);
last_genreArtist.name[0] = '\0'; last_genreArtist.name[0] = '\0';
/* Add this file to the "- All Artists -" container as well */ /* Add this file to the "- All Artists -" container as well */
container = insert_container("- All Artists -", last_genre.parentID, NULL, "storageFolder", NULL, genre, NULL); container = insert_container(_("- All Artists -"), last_genre.parentID, NULL, "storageFolder", NULL, genre, NULL);
sprintf(last_genreArtistAll.parentID, "%s$%llX", last_genre.parentID, container>>32); sprintf(last_genreArtistAll.parentID, "%s$%llX", last_genre.parentID, container>>32);
last_genreArtistAll.objectID = (int)container; last_genreArtistAll.objectID = (int)container;
} }
@ -323,16 +328,16 @@ insert_containers(const char * name, const char *path, const char * refID, const
{ {
last_genreArtistAll.objectID++; last_genreArtistAll.objectID++;
} }
if( valid_cache && strcmp(artist?artist:"Unknown Artist", last_genreArtist.name) == 0 ) if( valid_cache && strcmp(artist?artist:_("Unknown Artist"), last_genreArtist.name) == 0 )
{ {
last_genreArtist.objectID++; last_genreArtist.objectID++;
} }
else else
{ {
container = insert_container(artist?artist:"Unknown Artist", last_genre.parentID, artist?last_artist.parentID:NULL, "person.musicArtist", NULL, genre, NULL); container = insert_container(artist?artist:_("Unknown Artist"), last_genre.parentID, artist?last_artist.parentID:NULL, "person.musicArtist", NULL, genre, NULL);
sprintf(last_genreArtist.parentID, "%s$%llX", last_genre.parentID, container>>32); sprintf(last_genreArtist.parentID, "%s$%llX", last_genre.parentID, container>>32);
last_genreArtist.objectID = (int)container; last_genreArtist.objectID = (int)container;
strcpy(last_genreArtist.name, artist?artist:"Unknown Artist"); strcpy(last_genreArtist.name, artist?artist:_("Unknown Artist"));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached genre/artist item: %s/%s/%X\n", last_genreArtist.name, last_genreArtist.parentID, last_genreArtist.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached genre/artist item: %s/%s/%X\n", last_genreArtist.name, last_genreArtist.parentID, last_genreArtist.objectID);
} }
sql_exec(db, "INSERT into OBJECTS" sql_exec(db, "INSERT into OBJECTS"
@ -535,22 +540,22 @@ CreateDatabase(void)
{ {
int ret, i; int ret, i;
const char * containers[] = { "0","-1", "root", const char * containers[] = { "0","-1", "root",
"1", "0", "Music", "1", "0", _("Music"),
"1$4", "1", "All Music", "1$4", "1", _("All Music"),
"1$5", "1", "Genre", "1$5", "1", _("Genre"),
"1$6", "1", "Artist", "1$6", "1", _("Artist"),
"1$7", "1", "Album", "1$7", "1", _("Album"),
MUSIC_DIR_ID, "1", "Folders", MUSIC_DIR_ID, "1", _("Folders"),
MUSIC_PLIST_ID, "1", "Playlists", MUSIC_PLIST_ID, "1", _("Playlists"),
"2", "0", "Video", "2", "0", _("Video"),
"2$8", "2", "All Video", "2$8", "2", _("All Video"),
VIDEO_DIR_ID, "2", "Folders", VIDEO_DIR_ID, "2", _("Folders"),
"3", "0", "Pictures", "3", "0", _("Pictures"),
"3$11", "3", "All Pictures", "3$11", "3", _("All Pictures"),
"3$12", "3", "Date Taken", "3$12", "3", _("Date Taken"),
"3$13", "3", "Camera", "3$13", "3", _("Camera"),
IMAGE_DIR_ID, "3", "Folders", IMAGE_DIR_ID, "3", _("Folders"),
"64", "0", "Browse Folders", "64", "0", _("Browse Folders"),
0 }; 0 };
ret = sql_exec(db, "CREATE TABLE OBJECTS ( " ret = sql_exec(db, "CREATE TABLE OBJECTS ( "
@ -713,7 +718,7 @@ ScanDirectory(const char * dir, const char * parent, enum media_types dir_type)
if( chdir(dir) != 0 ) if( chdir(dir) != 0 )
return; return;
DPRINTF(parent?E_INFO:E_WARN, L_SCANNER, "Scanning %s\n", dir); DPRINTF(parent?E_INFO:E_WARN, L_SCANNER, _("Scanning %s\n"), dir);
switch( dir_type ) switch( dir_type )
{ {
case ALL_MEDIA: case ALL_MEDIA:
@ -781,7 +786,7 @@ ScanDirectory(const char * dir, const char * parent, enum media_types dir_type)
} }
else else
{ {
DPRINTF(E_WARN, L_SCANNER, "Scanning %s finished (%llu files)!\n", dir, fileno); DPRINTF(E_WARN, L_SCANNER, _("Scanning %s finished (%llu files)!\n"), dir, fileno);
} }
} }

View File

@ -27,6 +27,12 @@
#define USE_FORK 1 #define USE_FORK 1
#define DB_VERSION 5 #define DB_VERSION 5
#ifdef ENABLE_NLS
#define _(string) gettext(string)
#else
#define _(string) (string)
#endif
#if 0 // Add these once the newer ffmpeg libs that can detect WMAPRO are more widely used #if 0 // Add these once the newer ffmpeg libs that can detect WMAPRO are more widely used
"http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVHIGH_PRO;DLNA.ORG_OP=01;DLNA.ORG_CI=0," "http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVHIGH_PRO;DLNA.ORG_OP=01;DLNA.ORG_CI=0,"
"http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVMED_PRO;DLNA.ORG_OP=01;DLNA.ORG_CI=0," "http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVMED_PRO;DLNA.ORG_OP=01;DLNA.ORG_CI=0,"