mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
VDR developer version 2.1.1 is now available at ftp://ftp.tvdr.de/vdr/Developer/vdr-2.1.1.tar.bz2 A 'diff' against the previous version is available at ftp://ftp.tvdr.de/vdr/Developer/vdr-2.0.0-2.1.1.diff MD5 checksums: b17f9838bb8ddee9620f838fea7a171d vdr-2.1.1.tar.bz2 8b8ca593885c380cd370e6d19a5b16a1 vdr-2.0.0-2.1.1.diff WARNING: ======== This is a *developer* version. Even though *I* use it in my productive environment, I strongly recommend that you only use it under controlled conditions and for testing and debugging. The main focus of this version is on adding basic support for positioners to control steerable satellite dishes. Manually controlling the dish position and storing individual positions will follow later. The fixes contained in this version will be released in a stable version 2.0.3 later, if there are no problems. From the HISTORY file: - Fixed initializing cDevice::keepTracks. - Fixed an endless loop in cTextWrapper::Set() in case the given Width is smaller than one character (reported by Stefan Braun). - Removed all "modified since version 1.6" markers from PLUGINS.html. - Added definitions for older DVB API versions, back until 5.0 (based on a patch from Udo Richter). - Changed cThread::SetIOPriority() from "best effort class" to "idle class" in order to improve overall performance when an editing process is running (thanks to Jochen Dolze). - Fixed handling '/' and '~' in recording file names in case DirectoryEncoding is used (thanks to Lars Hanisch). - Changed the sign of the satellite position value in cSource to reflect the standard of western values being negative. The new member function cSource::Position() can be used to retrieve the orbital position of a satellite. - Fixed multiple occurrences of the same directory in the recordings list in case there are directories that only differ in non-alphanumeric characters (was broken by "Fixed selecting the last replayed recording in the Recordings menu in case there are folders and plain recordings with names that differ only in non-alphanumeric characters" in version 1.7.36). - Fixed displaying the frame number when setting an editing mark (thanks to Thomas Günther). - Fixed no longer generating any editing marks if the edited recording results in just one single sequence (reported by Halim Sahin). - Fixed an error message when parsing SCR values in diseqc.conf. - Fixed an unexpected RCS version tag in the newplugin script. - Fixed an endless loop in the DrawEllipse() functions for very small ellipses (reported by Stefan Braun). - Fixed a crash in the LCARS skin's main menu in case there is no current channel (reported by Dominique Dumont). - Added basic support for positioners to control steerable satellite dishes (based on a patch from Seppo Ingalsuo and Ales Jurik). + Supports GotoN (aka "DiSEqC 1.2") and GotoX (aka "USALS"). + The new DiSEqC command code 'P' can be used to instruct a positioner to move the dish to the required satellite position. When a 'P' code is processed, further execution of the remaining DiSEqC sequence (if any) is postponed until the positioner has reached the new satellite position. + The new special source value of "S360E" can be used in diseqc.conf to indicate that an entry using a positioner can move the dish to any requested position within its range. Think of it as "full circle". + The devices a particular cDiseqc or cScr applies to are now stored directly in each cDiseqc or cScr, respectively. + A plugin can implement a custom positioner control (see PLUGINS.html, section "Positioners"). + The new function cSkinDisplayChannel::SetPositioner() can be implemented by skins to show the user a progress display when the dish is being moved. The default implementation calls SetMessage() with a string indicating the new position the dish is being moved to. The LCARS skin shows a progress bar indicating the movement of the dish. + The new parameters "Site latitude", "Site longitude", "Positioner speed", and "Positioner swing" in the "Setup/LNB" menu can be used to configure the necessary values for a steerable dish. + The cDvbTuner now has a new status tsPositioning, in which it waits until a steerable dish has reached its target position. Parsing SI data is paused until the target position has been reached. - The LCARS skin now shows the source value of the current channel in its channel display. - Fixed asserting free disk space in the cutter. - No longer trying to delete old recordings in AssertFreeDiskSpace() if the given Priority is less than 1. - Fixed handling LIRC events in case repeated events are lost. - Fixed a possible crash when shutting down VDR while subtitles are being displayed (reported by Ville Skyttä). - cDevice::IsPrimaryDevice() now also checks whether the primary device actually has a decoder and returns false otherwise. This should improve device allocation on systems that are only used as a receiver and don't actually display anything. - Increased the value of MAXRETRIES to 20 to reduce the probability of disturbances in transfer mode. - All bonded devices (except for the master) now turn off their LNB power completely to avoid problems when receiving vertically polarized transponders (suggested by Manfred Völkel and Oliver Endriss). - Reverted the change from version 1.5.7 that made all logging go to LOG_ERR (thanks to Christopher Reimer). - Added Begin/EndSegmentTransfer() to the EPG handler interface (thanks to Jörg Wendel). - The code for distributing recordings over several video directories is now deprecated and disabled by default. You can re-enable this feature by removing the comment sign ('//') from the beginning of the line //#define DEPRECATED_DISTRIBUTED_VIDEODIR // Code enclosed with this macro is ... in the file videodir.c. Note, though, that this can only be a temporary workaround. This feature will be completely removed in one of the next developer versions. Distributing the video directory over several disks was a useful feature in times when disks were still relatively small, but it also caused serious problems in case one of the disks failed. Nowadays hard disks come in sizes measured in terabytes, and tools like "mhddfs" can be used to combine several disks to form one large volume. A recommended method for a relatively safe disk setup in a VDR system is to use two 1TB (or larger) disks and use them as a RAID-1 (mirrored). That way, if one disk fails, you can replace it without data loss.
301 lines
8.8 KiB
C
301 lines
8.8 KiB
C
/*
|
|
* i18n.c: Internationalization
|
|
*
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
* how to reach the author.
|
|
*
|
|
* $Id: i18n.c 3.0 2012/09/01 10:53:43 kls Exp $
|
|
*/
|
|
|
|
/*
|
|
* In case an English phrase is used in more than one context (and might need
|
|
* different translations in other languages) it can be preceded with an
|
|
* arbitrary string to describe its context, separated from the actual phrase
|
|
* by a '$' character (see for instance "Button$Stop" vs. "Stop").
|
|
* Of course this means that no English phrase may contain the '$' character!
|
|
* If this should ever become necessary, the existing '$' would have to be
|
|
* replaced with something different...
|
|
*/
|
|
|
|
#include "i18n.h"
|
|
#include <ctype.h>
|
|
#include <libintl.h>
|
|
#include <locale.h>
|
|
#include <unistd.h>
|
|
#include "tools.h"
|
|
|
|
// TRANSLATORS: The name of the language, as written natively
|
|
const char *LanguageName = trNOOP("LanguageName$English");
|
|
// TRANSLATORS: The 3-letter code of the language
|
|
const char *LanguageCode = trNOOP("LanguageCode$eng");
|
|
|
|
// List of known language codes with aliases.
|
|
// Actually we could list all codes from http://www.loc.gov/standards/iso639-2
|
|
// here, but that would be several hundreds - and for most of them it's unlikely
|
|
// they're ever going to be used...
|
|
|
|
const char *LanguageCodeList[] = {
|
|
"eng,dos",
|
|
"deu,ger",
|
|
"slv,slo",
|
|
"ita",
|
|
"dut,nla,nld",
|
|
"prt",
|
|
"fra,fre",
|
|
"nor",
|
|
"fin,suo",
|
|
"pol",
|
|
"esl,spa",
|
|
"ell,gre",
|
|
"sve,swe",
|
|
"rom,rum",
|
|
"hun",
|
|
"cat,cln",
|
|
"rus",
|
|
"srb,srp,scr,scc",
|
|
"hrv",
|
|
"est",
|
|
"dan",
|
|
"cze,ces",
|
|
"tur",
|
|
"ukr",
|
|
"ara",
|
|
NULL
|
|
};
|
|
|
|
static cString I18nLocaleDir;
|
|
|
|
static cStringList LanguageLocales;
|
|
static cStringList LanguageNames;
|
|
static cStringList LanguageCodes;
|
|
|
|
static int NumLocales = 1;
|
|
static int CurrentLanguage = 0;
|
|
|
|
static bool ContainsCode(const char *Codes, const char *Code)
|
|
{
|
|
while (*Codes) {
|
|
int l = 0;
|
|
for ( ; l < 3 && Code[l]; l++) {
|
|
if (Codes[l] != tolower(Code[l]))
|
|
break;
|
|
}
|
|
if (l == 3)
|
|
return true;
|
|
Codes++;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
static const char *SkipContext(const char *s)
|
|
{
|
|
const char *p = strchr(s, '$');
|
|
return p ? p + 1 : s;
|
|
}
|
|
|
|
static void SetEnvLanguage(const char *Locale)
|
|
{
|
|
setenv("LANGUAGE", Locale, 1);
|
|
extern int _nl_msg_cat_cntr;
|
|
++_nl_msg_cat_cntr;
|
|
}
|
|
|
|
void I18nInitialize(const char *LocaleDir)
|
|
{
|
|
I18nLocaleDir = LocaleDir;
|
|
LanguageLocales.Append(strdup(I18N_DEFAULT_LOCALE));
|
|
LanguageNames.Append(strdup(SkipContext(LanguageName)));
|
|
LanguageCodes.Append(strdup(LanguageCodeList[0]));
|
|
textdomain("vdr");
|
|
bindtextdomain("vdr", I18nLocaleDir);
|
|
cFileNameList Locales(I18nLocaleDir, true);
|
|
if (Locales.Size() > 0) {
|
|
char *OldLocale = strdup(setlocale(LC_MESSAGES, NULL));
|
|
for (int i = 0; i < Locales.Size(); i++) {
|
|
cString FileName = cString::sprintf("%s/%s/LC_MESSAGES/vdr.mo", *I18nLocaleDir, Locales[i]);
|
|
if (access(FileName, F_OK) == 0) { // found a locale with VDR texts
|
|
if (NumLocales < I18N_MAX_LANGUAGES - 1) {
|
|
SetEnvLanguage(Locales[i]);
|
|
const char *TranslatedLanguageName = gettext(LanguageName);
|
|
if (TranslatedLanguageName != LanguageName) {
|
|
NumLocales++;
|
|
if (strstr(OldLocale, Locales[i]) == OldLocale)
|
|
CurrentLanguage = LanguageLocales.Size();
|
|
LanguageLocales.Append(strdup(Locales[i]));
|
|
LanguageNames.Append(strdup(TranslatedLanguageName));
|
|
const char *Code = gettext(LanguageCode);
|
|
for (const char **lc = LanguageCodeList; *lc; lc++) {
|
|
if (ContainsCode(*lc, Code)) {
|
|
Code = *lc;
|
|
break;
|
|
}
|
|
}
|
|
LanguageCodes.Append(strdup(Code));
|
|
}
|
|
}
|
|
else {
|
|
esyslog("ERROR: too many locales - increase I18N_MAX_LANGUAGES!");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
SetEnvLanguage(LanguageLocales[CurrentLanguage]);
|
|
free(OldLocale);
|
|
dsyslog("found %d locales in %s", NumLocales - 1, *I18nLocaleDir);
|
|
}
|
|
// Prepare any known language codes for which there was no locale:
|
|
for (const char **lc = LanguageCodeList; *lc; lc++) {
|
|
bool Found = false;
|
|
for (int i = 0; i < LanguageCodes.Size(); i++) {
|
|
if (strcmp(*lc, LanguageCodes[i]) == 0) {
|
|
Found = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!Found) {
|
|
dsyslog("no locale for language code '%s'", *lc);
|
|
LanguageLocales.Append(strdup(I18N_DEFAULT_LOCALE));
|
|
LanguageNames.Append(strdup(*lc));
|
|
LanguageCodes.Append(strdup(*lc));
|
|
}
|
|
}
|
|
}
|
|
|
|
void I18nRegister(const char *Plugin)
|
|
{
|
|
cString Domain = cString::sprintf("vdr-%s", Plugin);
|
|
bindtextdomain(Domain, I18nLocaleDir);
|
|
}
|
|
|
|
void I18nSetLocale(const char *Locale)
|
|
{
|
|
if (Locale && *Locale) {
|
|
int i = LanguageLocales.Find(Locale);
|
|
if (i >= 0) {
|
|
CurrentLanguage = i;
|
|
SetEnvLanguage(Locale);
|
|
}
|
|
else
|
|
dsyslog("unknown locale: '%s'", Locale);
|
|
}
|
|
}
|
|
|
|
int I18nCurrentLanguage(void)
|
|
{
|
|
return CurrentLanguage;
|
|
}
|
|
|
|
void I18nSetLanguage(int Language)
|
|
{
|
|
if (Language < LanguageNames.Size()) {
|
|
CurrentLanguage = Language;
|
|
I18nSetLocale(I18nLocale(CurrentLanguage));
|
|
}
|
|
}
|
|
|
|
int I18nNumLanguagesWithLocale(void)
|
|
{
|
|
return NumLocales;
|
|
}
|
|
|
|
const cStringList *I18nLanguages(void)
|
|
{
|
|
return &LanguageNames;
|
|
}
|
|
|
|
const char *I18nTranslate(const char *s, const char *Plugin)
|
|
{
|
|
if (!s)
|
|
return s;
|
|
if (CurrentLanguage) {
|
|
const char *t = Plugin ? dgettext(Plugin, s) : gettext(s);
|
|
if (t != s)
|
|
return t;
|
|
}
|
|
return SkipContext(s);
|
|
}
|
|
|
|
const char *I18nLocale(int Language)
|
|
{
|
|
return 0 <= Language && Language < LanguageLocales.Size() ? LanguageLocales[Language] : NULL;
|
|
}
|
|
|
|
const char *I18nLanguageCode(int Language)
|
|
{
|
|
return 0 <= Language && Language < LanguageCodes.Size() ? LanguageCodes[Language] : NULL;
|
|
}
|
|
|
|
int I18nLanguageIndex(const char *Code)
|
|
{
|
|
for (int i = 0; i < LanguageCodes.Size(); i++) {
|
|
if (ContainsCode(LanguageCodes[i], Code))
|
|
return i;
|
|
}
|
|
//dsyslog("unknown language code: '%s'", Code);
|
|
return -1;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
bool I18nIsPreferredLanguage(int *PreferredLanguages, const char *LanguageCode, int &OldPreference, int *Position)
|
|
{
|
|
int pos = 1;
|
|
bool found = false;
|
|
while (LanguageCode) {
|
|
int LanguageIndex = I18nLanguageIndex(LanguageCode);
|
|
for (int i = 0; i < LanguageCodes.Size(); i++) {
|
|
if (PreferredLanguages[i] < 0)
|
|
break; // the language is not a preferred one
|
|
if (PreferredLanguages[i] == LanguageIndex) {
|
|
if (OldPreference < 0 || i < OldPreference) {
|
|
OldPreference = i;
|
|
if (Position)
|
|
*Position = pos;
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if ((LanguageCode = strchr(LanguageCode, '+')) != NULL) {
|
|
LanguageCode++;
|
|
pos++;
|
|
}
|
|
else if (pos == 1 && Position)
|
|
*Position = 0;
|
|
}
|
|
if (OldPreference < 0) {
|
|
OldPreference = LanguageCodes.Size(); // higher than the maximum possible value
|
|
return true; // if we don't find a preferred one, we take the first one
|
|
}
|
|
return found;
|
|
}
|