From patchwork Sat Jan 19 12:24:08 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Schmidinger X-Patchwork-Id: 12581 Received: from raven.cadsoft.de ([217.7.101.211]) by www.linuxtv.org with esmtp (Exim 4.63) (envelope-from ) id 1JGCk9-00025D-0Z for vdr@linuxtv.org; Sat, 19 Jan 2008 13:24:13 +0100 Received: from [192.168.100.10] (hawk.cadsoft.de [192.168.100.10]) by raven.cadsoft.de (8.13.3/8.13.3) with ESMTP id m0JCO9re023635 for ; Sat, 19 Jan 2008 13:24:09 +0100 Message-ID: <4791EBE8.6070301@cadsoft.de> Date: Sat, 19 Jan 2008 13:24:08 +0100 From: Klaus Schmidinger Organization: CadSoft Computer GmbH User-Agent: Thunderbird 2.0.0.9 (X11/20070801) MIME-Version: 1.0 To: vdr@linuxtv.org References: In-Reply-To: X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (raven.cadsoft.de [192.168.1.1]); Sat, 19 Jan 2008 13:24:10 +0100 (CET) Subject: Re: [vdr] Locale commandline option. Patch not accepted? X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jan 2008 12:24:13 -0000 Status: O X-Status: X-Keywords: X-UID: 15154 On 01/18/08 19:57, Stefan Huelswitt wrote: > Hi, > > some time ago I suggested to have a commandline option to > specifiy the location of the locale files at runtime. > > It hasn't appeared in VDR source since then. > Has the patch been rejected? It was still in my inbox (like several others). I didn't know it was that important ;-) Attached is the version as I've adopted it. I didn't like the I18nLocaleDir to be exposed, so I made the LocaleDir a parameter of the I18nInitialize() function. There is also no -O single character option, just --localedir (didn't want to waste a single character option on this, especially since it isn't even the actual first character of the option). In a quick test it appeared to work, but you may want to test the modified patch to make sure I didn't break anything. Klaus --- i18n.c 2007/11/01 10:38:27 1.318 +++ i18n.c 2008/01/19 12:07:11 @@ -100,8 +100,10 @@ ++_nl_msg_cat_cntr; } -void I18nInitialize(void) +void I18nInitialize(const char *LocaleDir) { + if (LocaleDir) + I18nLocaleDir = LocaleDir; LanguageLocales.Append(strdup(I18N_DEFAULT_LOCALE)); LanguageNames.Append(strdup(SkipContext(LanguageName))); LanguageCodes.Append(strdup(LanguageCodeList[0])); --- i18n.h 2007/08/24 13:35:18 1.24 +++ i18n.h 2008/01/19 11:56:19 @@ -19,8 +19,10 @@ #define I18N_MAX_LOCALE_LEN 16 // for buffers that hold en_US etc. #define I18N_MAX_LANGUAGES 256 // for buffers that hold all available languages -void I18nInitialize(void); +void I18nInitialize(const char *LocaleDir = NULL); ///< Detects all available locales and loads the language names and codes. + ///< If LocaleDir is given, it must point to a static string that lives + ///< for the entire lifetime of the program. void I18nRegister(const char *Plugin); ///< Registers the named plugin, so that it can use internationalized texts. void I18nSetLocale(const char *Locale); --- vdr.c 2008/01/13 11:51:53 1.305 +++ vdr.c 2008/01/19 12:14:15 @@ -198,6 +198,7 @@ bool MuteAudio = false; int WatchdogTimeout = DEFAULTWATCHDOG; const char *Terminal = NULL; + const char *LocaleDir = NULL; bool UseKbd = true; const char *LircDevice = NULL; @@ -229,6 +230,7 @@ { "help", no_argument, NULL, 'h' }, { "lib", required_argument, NULL, 'L' }, { "lirc", optional_argument, NULL, 'l' | 0x100 }, + { "localedir",required_argument, NULL, 'l' | 0x200 }, { "log", required_argument, NULL, 'l' }, { "mute", no_argument, NULL, 'm' }, { "no-kbd", no_argument, NULL, 'n' | 0x100 }, @@ -306,6 +308,14 @@ case 'l' | 0x100: LircDevice = optarg ? optarg : LIRC_DEVICE; break; + case 'l' | 0x200: + if (access(optarg, R_OK | X_OK) == 0) + LocaleDir = optarg; + else { + fprintf(stderr, "vdr: can't access locale directory: %s\n", optarg); + return 2; + } + break; case 'm': MuteAudio = true; break; case 'n' | 0x100: @@ -407,6 +417,8 @@ " -L DIR, --lib=DIR search for plugins in DIR (default is %s)\n" " --lirc[=PATH] use a LIRC remote control device, attached to PATH\n" " (default: %s)\n" + " --localedir=DIR search for locale files in DIR (default is\n" + " %s)\n" " -m, --mute mute audio of the primary DVB device at startup\n" " --no-kbd don't use the keyboard as an input device\n" " -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n" @@ -430,6 +442,7 @@ DEFAULTEPGDATAFILENAME, DEFAULTPLUGINDIR, LIRC_DEVICE, + LOCDIR, DEFAULTSVDRPPORT, RCU_DEVICE, VideoDirectory, @@ -515,7 +528,7 @@ // Initialize internationalization: - I18nInitialize(); + I18nInitialize(LocaleDir); // Main program loop variables - need to be here to have them initialized before any EXIT():