const char *I18nNormalizeLanguageCode(const char *Code) { for (int i = 0; i < 3; i++) { if (Code[i]) { // ETSI EN 300 468 defines language codes as consisting of three letters // according to ISO 639-2. This means that they are supposed to always consist // of exactly three letters in the range a-z - no digits, UTF-8 or other // funny characters. However, some broadcasters apparently don't have a // copy of the DVB standard (or they do, but are perhaps unable to read it), // so they put all sorts of non-standard stuff into the language codes, // like nonsense as "2ch" or "A 1" (yes, they even go as far as using // blanks!). Such things should go into the description of the EPG event's // ComponentDescriptor. // So, as a workaround for this broadcaster stupidity, let's ignore // language codes with unprintable characters... if (!isprint(Code[i])) { //dsyslog("invalid language code: '%s'", Code); return "???"; } // ...and replace blanks with underlines (ok, this breaks the 'const' // of the Code parameter - but hey, it's them who started this): if (Code[i] == ' ') *((char *)&Code[i]) = '_'; } else break; } int n = I18nLanguageIndex(Code); return n >= 0 ? I18nLanguageCode(n) : Code; }
void cSetup::StoreLanguages(const char *Name, int *Values) { char buffer[I18nLanguages()->Size() * 4]; char *q = buffer; for (int i = 0; i < I18nLanguages()->Size(); i++) { if (Values[i] < 0) break; const char *s = I18nLanguageCode(Values[i]); if (s) { if (q > buffer) *q++ = ' '; strncpy(q, s, 3); q += 3; } } *q = 0; Store(Name, buffer); }
bool cTheme::Save(const char *FileName) { if (!FileNameOk(FileName)) return false; bool result = true; cSafeFile f(FileName); if (f.Open()) { for (int i = 0; i < I18nNumLanguages; i++) { if (descriptions[i]) fprintf(f, "Description%s%.*s = %s\n", i ? "." : "", 3, i ? I18nLanguageCode(i) : "", descriptions[i]); } for (int i = 0; i < MaxThemeColors; i++) { if (colorNames[i]) fprintf(f, "%s = %08X\n", colorNames[i], colorValues[i]); } if (!f.Close()) result = false; } else result = false; return result; }
string FileNameFactory(string FileType) { string configDir = cPlugin::ConfigDirectory(); string::size_type pos = configDir.find("plugin"); configDir.erase(pos-1); #ifdef EXTRA_VERBOSE_DEBUG cout << " Config Dir : " << configDir << endl; #endif if (FileType == "configDirecory") // vdr config base directory { #if EXTRA_VERBOSE_DEBUG cout << "DEBUG [setup]: ConfigDirectory " << configDir << endl; #endif return configDir; } if (FileType == "help") // returns symbolic link { string configFile; configFile = cPlugin::ConfigDirectory(); configFile += "/setup/help/help."; string tmp = I18nLanguageCode(::Setup.OSDLanguage); // if two token given we take the first one. string::size_type pos = tmp.find(','); if (pos != string::npos) { configFile += tmp.substr(0,pos); } else { configFile += tmp; } configFile += ".xml"; #ifdef EXTRA_VERBOSE_DEBUG cout << " debug config file: " << configFile << endl; #endif return configFile; } //else if (FileType == "channelsFile") // returns channels.conf else if (FileType == "link") // returns symbolic link { #ifdef EXTRA_VERBOSE_DEBUG cout << " Config Dir : " << configDir << "/channels.conf" << endl; #endif return configDir += "/channels.conf"; } else if (FileType == "channels") // returns channels dir; { #ifdef EXTRA_VERBOSE_DEBUG cout << " Config Dir : " << configDir << "/channels" << endl; #endif return configDir += "/channels"; } else if (FileType == "setup") // returns plugins/setup dir; change to "configDir" { #ifdef EXTRA_VERBOSE_DEBUG cout << " Config Dir : " << configDir << "/plugins/setup" << endl; #endif return configDir += "/plugins/setup"; } configDir.append("/"); configDir += "/channels/"; configDir += FileType; #ifdef EXTRA_VERBOSE_DEBUG cout << " Config Dir end : " << configDir << ".conf" << endl; #endif return configDir += ".conf"; }