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
@@ -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]));
@@ -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);
@@ -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():