]> git.vomp.tv Git - vompclient-marten.git/commitdiff
I18n
authorChris Tallon <chris@vomp.tv>
Mon, 7 Nov 2005 23:51:57 +0000 (23:51 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 7 Nov 2005 23:51:57 +0000 (23:51 +0000)
30 files changed:
Makefile
command.cc
command.h
i18n.cc [new file with mode: 0644]
i18n.h [new file with mode: 0644]
main.cc
vchannellist.cc
vchannellist.h
vconnect.cc
vconnect.h
vdr.cc
vdr.h
vlivebanner.cc
vlivebanner.h
voptions.cc
voptions.h
vquestion.cc
vquestion.h
vrecordinglist.cc
vrecordinglist.h
vrecordingmenu.cc
vrecordingmenu.h
vserverselect.cc
vserverselect.h
vvideolive.cc
vvideolive.h
vwelcome.cc
vwelcome.h
woptionbox.cc
woptionbox.h

index 9c60e3fc611fdd988b4529d5fd6327e8c2a98861..2ab18e585fc18ccad3d9c4bc9335e3ce18155964 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o dire
           view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \
           vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o vradiolive.o \
           vchannelselect.o vserverselect.o colour.o vconnect.o voptions.o \
-          widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o \
+          widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o i18n.o \
           fonts/helvB24.o fonts/helvB18.o
 
 .PHONY: clean fresh all install strip
index f440396fc865bad495819a543c5d064152437409..d30729c136a7de2ed0b9acd56efe0364b2f9a629 100644 (file)
@@ -251,6 +251,7 @@ void Command::doReboot()
 
 void Command::doJustConnected(VConnect* vconnect)
 {
+  I18n::Initialize();
   Video* video = Video::getInstance();
   viewman->removeView(vconnect, 0, 1);
 
@@ -261,7 +262,7 @@ void Command::doJustConnected(VConnect* vconnect)
   else
     vi->setScreenPos(160, 150);
 
-  vi->setMainText("\n               Connected, loading config");
+  vi->setMainText(tr("\n               Connected, loading config"));
   vi->draw();
   vi->show();
   viewman->add(vi);
index 8e357b1a4391eced042b856df3d7567f759ae9cd..2ce40149365f9dee7f5d00c1fa80d5eab8779893 100644 (file)
--- a/command.h
+++ b/command.h
@@ -49,6 +49,7 @@
 #include "vmute.h"
 #include "colour.h"
 #include "osd.h"
+#include "i18n.h"
 
 class VConnect;
 
diff --git a/i18n.cc b/i18n.cc
new file mode 100644 (file)
index 0000000..5b60efe
--- /dev/null
+++ b/i18n.cc
@@ -0,0 +1,349 @@
+/*\r
+ * i18n.c: Internationalization\r
+ *\r
+ * This code is taken from the VDR project and modified for VOMP.\r
+ * See the main source file 'vdr.c' for original copyright information.\r
+ * Modifications (C) 2005 D Pickles.\r
+\r
+     This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+/*\r
+ * How to add a new language:\r
+ *\r
+ * 1. Announce your translation action on the VOMP mailing\r
+ *    list to avoid duplicate work.\r
+ * 2. Increase the value of 'NUM_LANGUAGES' in i18n.h.\r
+ * 3. Insert a new line in the 'Languages' array containing the name of your\r
+ *    language IN YOUR LANGUAGE, so 'Italiano' not 'Italian' for example.\r
+ *    Append your language after the last existing language\r
+ *    but before the 'test' language\r
+ * 4. Insert a new line in the charSets array containing the name of the character\r
+ *    set needed for your language. Note that at present only ISO8859-1 is\r
+ *    supported\r
+ * 5. Insert a new line in the languageCodes array containing the 3-letter\r
+ *    abbreviation(s) for your language as used in the channels.conf.\r
+ * 6. Insert a line in evry member of the 'Phrases[]' array,\r
+ *    containing the translated text for your language. You can use the 'test'\r
+ *    language to see where the phrases appear on the screen.\r
+ * 7. Add the name of your language to the i18nLanguages array in voptions.h.\r
+ * 8. If your language requires a character set other than the default iso8859-1\r
+ *    then work will be needed elsewhere in vomp to manage multiple font files.\r
+ * 9. Compile VOMP and test the new language by switching to it\r
+ *    in the "Options" menu.\r
+ *10. Send the modified files to Chris to have it included in the next version.\r
+ *\r
+ * In case an English phrase is used in more than one context (and might need\r
+ * different translations in other languages) it can be preceeded with an\r
+ * arbitrary string to describe its context, separated from the actual phrase\r
+ * by a '$' character (see for instance "Button$Stop" vs. "Stop").\r
+ * Of course this means that no English phrase may contain the '$' character!\r
+ * If this should ever become necessary, the existing '$' would have to be\r
+ * replaced with something different...\r
+ */\r
+\r
+#include "i18n.h"\r
+#include "log.h"\r
+#include "vdr.h"\r
+\r
+  // The names of the languages (English MUST be first!):\r
+static char *Languages[] =\r
+  { "English",\r
+    "Test"\r
+  };\r
+\r
+  // The character set needed for each language:\r
+const static char *charSets[] =\r
+  { "iso8859-1",\r
+    "iso8859-1"\r
+  };\r
+\r
+  // The 3-letter names of the language (this MUST be the third phrase!):\r
+const char *languageCodes[] =\r
+  { "eng,dos",\r
+    "tst,xxx"\r
+  };\r
+\r
+  // The phrases to be translated:\r
+\r
+const static tI18nPhrase Phrases[] = {\r
+  // Menu titles:\r
+  { "VDR",\r
+    "VDR",\r
+  },\r
+  { "Schedule",\r
+    "0",\r
+  },\r
+  // Welcome screen\r
+  { "Welcome",\r
+    "1",\r
+  },\r
+  { "1. Live TV",\r
+    "2",\r
+  },\r
+  { "2. Radio",\r
+    "3",\r
+  },\r
+  { "3. Recordings",\r
+    "4",\r
+  },\r
+  { "4. Options",\r
+    "5",\r
+  },\r
+  { "5. Stand by",\r
+    "6",\r
+  },\r
+  { "6. Reboot",\r
+    "7",\r
+  },\r
+  { "\n                  Downloading recordings list",\r
+    "8",\r
+  },\r
+  // Recordings list\r
+  { "Recordings - %s",\r
+    "9 - %s",\r
+  },\r
+  { "Recordings",\r
+    "10",\r
+  },\r
+  { "<dir> %lu\t%s",\r
+    "11 %lu\t%s",\r
+  },\r
+  { "[ok] = menu",\r
+    "12",\r
+  },\r
+  { "%lu%% used, %iGB free",\r
+    "13 %lu%% %i",\r
+  },\r
+  { "%i to %i of %i", // Also used in channels list\r
+    "14 %i %i %i",\r
+  },\r
+  // Question\r
+  { "Yes",\r
+    "15",\r
+  },\r
+  { "No",\r
+    "16",\r
+  },\r
+  // Recording Menu\r
+  { "Programme menu",\r
+    "17",\r
+  },\r
+  { "Play",\r
+    "18",\r
+  },\r
+  { "Resume",\r
+    "19",\r
+  },\r
+  { "Summary",\r
+    "20",\r
+  },\r
+  { "Delete",\r
+    "21",\r
+  },\r
+  { "Programme summary",\r
+    "22",\r
+  },\r
+  { "Summary unavailable",\r
+    "23",\r
+  },\r
+  { "Delete recording",\r
+    "24",\r
+  },\r
+  { "Are you sure you want to delete this recording?",\r
+    "25",\r
+  },\r
+  // Server select\r
+  { "Choose a VDR server",\r
+    "26",\r
+  },\r
+\r
+  // Option menus\r
+  { "Options",\r
+    "27",\r
+  },\r
+  { "TV connection type",\r
+    "28",\r
+  },\r
+  { "Remote control type",\r
+    "29",\r
+  },\r
+  { "TV aspect ratio",\r
+    "30",\r
+  },\r
+  { "16:9 on 4:3 display mode",\r
+    "30a",\r
+  },\r
+  { "Power state after bootup",\r
+    "31",\r
+  },\r
+  { "Display channels",\r
+    "32",\r
+  },\r
+  { "Language",\r
+    "33",\r
+  },\r
+  { "Press back to exit, <, > or [ok] to change",\r
+    "34",\r
+  },\r
+  { "VDR-Pri 0=OK !See forums!",\r
+    "34a",\r
+  },\r
+  // Option choices\r
+  { "Old",\r
+    "35",\r
+  },\r
+  { "New",\r
+    "36",\r
+  },\r
+  { "RGB+composite",\r
+    "37",\r
+  },\r
+  { "S-Video",\r
+    "38",\r
+  },\r
+  { "Chop sides",\r
+    "39",\r
+  },\r
+  { "Letterbox",\r
+    "40",\r
+  },\r
+  { "Last state",\r
+    "41",\r
+  },\r
+  { "All",\r
+    "42",\r
+  },\r
+  { "FTA only",\r
+    "43",\r
+  },\r
+  { "On",\r
+    "44",\r
+  },\r
+  { "Off",\r
+    "45",\r
+  },\r
+\r
+  // Channel Lists\r
+  { "Channels",\r
+    "46",\r
+  },\r
+  { "Radio Stations",\r
+    "47",\r
+  },\r
+  // Banners\r
+  { "No channel data available",\r
+    "48",\r
+  },\r
+  { "info",\r
+    "49",\r
+  },\r
+  { "info",\r
+    "50",\r
+  },\r
+  { "\n                    Channel unavailable",\r
+    "51",\r
+  },\r
+  // Connect screen\r
+  { "\n                        Locating server",\r
+    "52",\r
+  },\r
+  { "\n                     Connecting to VDR",\r
+    "53",\r
+  },\r
+  { "\n                           Login failed",\r
+    "54",\r
+  },\r
+  { "\n                      Connection failed",\r
+    "55",\r
+  },\r
+  // Command\r
+  { "\n               Connected, loading config",\r
+    "56",\r
+  },\r
+  // End marker.\r
+  { NULL }\r
+  };\r
+\r
+  static int LanguageID = INITIAL_LANGUAGE_INDEX;\r
+\r
+\r
+int I18n::Initialize(void) {\r
+\r
+  VDR *vdr = VDR::getInstance();\r
+  char *lang = vdr->configLoad("General", "Language");\r
+  if (lang) {\r
+    LanguageID = LanguageIndex(lang);\r
+    if (LanguageID == -1) {\r
+      LanguageID = 0;\r
+    }\r
+  }\r
+  else {\r
+    LanguageID = LanguageIndex(INITIAL_LANGUAGE);\r
+  }\r
+  return LanguageID;\r
+}\r
+\r
+char *I18n::Translate(char *s)\r
+{\r
+  if (LanguageID >= 0) {\r
+     const tI18nPhrase *p = Phrases;\r
+     for (int i = ((p == Phrases) ? 1 : 2); i--; ) {\r
+         for (; **p; p++) {\r
+             if (strcmp(s, **p) == 0) {\r
+                char *t = (*p)[LanguageID];\r
+                if (t && *t) return t;\r
+             }\r
+         }\r
+         p = Phrases;\r
+     }\r
+     Log::getInstance()->log("I18n", Log::ERR, "no translation found for '%s' in language %d (%s)\n",\r
+    s, LanguageID, LanguageName(LanguageID));\r
+  }\r
+  char *p = strchr(s, '$');\r
+  return p ? p + 1 : s;\r
+}\r
+\r
+const char * const * I18n::CharSets(void)\r
+{\r
+  return charSets;\r
+}\r
+\r
+const char * I18n::LanguageCode(int Index)\r
+{\r
+  return 0 <= Index && Index < I18nNumLanguages ? languageCodes[Index] : NULL;\r
+}\r
+\r
+char * I18n::LanguageName(int Index)\r
+{\r
+  return 0 <= Index && Index < I18nNumLanguages ? Languages[Index] : NULL;\r
+}\r
+\r
+int I18n::LanguageIndex(const char *Name)\r
+{\r
+  for (int i = 0; i < I18nNumLanguages; i++) {\r
+      if (strcasestr(Languages[i], Name))\r
+         return i;\r
+  }\r
+  Log::getInstance()->log("I18n", Log::ERR, "unknown language: '%s'", Name);\r
+  return -1;\r
+}\r
+\r
+int I18n::GetNumLanguages(void) {\r
+  return I18nNumLanguages;\r
+}\r
+\r
diff --git a/i18n.h b/i18n.h
new file mode 100644 (file)
index 0000000..f34b00a
--- /dev/null
+++ b/i18n.h
@@ -0,0 +1,58 @@
+/*\r
+ * i18n.h: Internationalization\r
+ *\r
+ * This code is taken from the VDR project and modified for VOMP.\r
+ * See the main source file 'vdr.c' for original copyright information.\r
+ * Modifications (C) 2005 D Pickles.\r
+\r
+    This file is part of VOMP.\r
+\r
+    VOMP is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU General Public License as published by\r
+    the Free Software Foundation; either version 2 of the License, or\r
+    (at your option) any later version.\r
+\r
+    VOMP is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU General Public License for more details.\r
+\r
+    You should have received a copy of the GNU General Public License\r
+    along with VOMP; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+#ifndef __I18N_H\r
+#define __I18N_H\r
+\r
+#include <stdio.h>\r
+\r
+#define NUM_LANGUAGES 2\r
+#define INITIAL_LANGUAGE "English"\r
+#define INITIAL_LANGUAGE_INDEX 0\r
+#define tr(s)  I18n::Translate(s)\r
+\r
+\r
+typedef char *tI18nPhrase[NUM_LANGUAGES];\r
+\r
+\r
+class I18n\r
+{\r
+  public:\r
+    static char *Translate(char *s);\r
+    const char * const * CharSets(void);\r
+    const char * LanguageCode(int Index);\r
+    static int Initialize(void);\r
+\r
+    static char * LanguageName(int Index);\r
+    static int LanguageIndex(const char *Name);\r
+    static int GetNumLanguages(void);\r
+\r
+  private:\r
+\r
+    const static int I18nNumLanguages = NUM_LANGUAGES;\r
+};\r
+\r
+\r
+#endif //__I18N_H\r
+\r
diff --git a/main.cc b/main.cc
index d080782c78830cce98042659fe61adf136954085..333d63fe2a2bc1d32084e514427615172ab44ceb 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -193,6 +193,8 @@ int main(int argc, char** argv)
   else if (videoFormat == Video::NTSC) logger->log("Core", Log::INFO, "Read from MTD: NTSC 720x480");
   else                                 logger->log("Core", Log::INFO, "No help from MTD. Assuming NTSC 720x480");
 
+  //videoFormat = Video::NTSC; // enable this line to test NTSC in PAL land
+
   success = video->init(videoFormat);
   if (success)
   {
index 2e1a476bcba443a0f8afffe8242981fb8ef93677..50f03122be8ef7c892533b6882884cfc937bc129 100644 (file)
@@ -38,11 +38,11 @@ VChannelList::VChannelList(ULONG type)
 
   if (type == VDR::VIDEO)
   {
-    setTitleText("Channels");
+    setTitleText(tr("Channels"));
   }
   else if (type == VDR::RADIO)
   {
-    setTitleText("Radio Stations");
+    setTitleText(tr("Radio Stations"));
   }
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
 
@@ -127,7 +127,7 @@ void VChannelList::doShowingBar()
   if (sl.getNumOptions() == 0) topOption = 0;
 
   char showing[200];
-  sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
+  sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
 
 //  Box b;
 //  b.setSurfaceOffset(220, 385);
index ade2a2027092583e9c886d5759de439c1332a1ba..6f737aa18016f5494c31df18fa92f37dd1104233 100644 (file)
@@ -36,6 +36,7 @@
 #include "vradiolive.h"
 #include "colour.h"
 #include "video.h"
+#include "i18n.h"
 
 class VChannelList : public View
 {
index 0b22d324d191e6a9f392d258c6e6d0a742265050..9f025a59d0d9718951ef4b7a178e69029576c8ff 100644 (file)
@@ -72,7 +72,7 @@ void VConnect::threadMethod()
 
   do
   {
-    setMainText("\n                        Locating server");
+    setMainText(tr("\n                        Locating server"));
     draw();
     show();
 
@@ -113,7 +113,7 @@ void VConnect::threadMethod()
     for(UINT k = 0; k < serverIPs.size(); k++) delete[] serverIPs[k];
     serverIPs.clear();
 
-    setMainText("\n                     Connecting to VDR");
+    setMainText(tr("\n                     Connecting to VDR"));
     draw();
     show();
 
@@ -132,14 +132,14 @@ void VConnect::threadMethod()
       else
       {
         vdr->disconnect();
-        setMainText("\n                           Login failed");
+        setMainText(tr("\n                           Login failed"));
         ts.tv_sec = 3;
         ts.tv_nsec = 0;
       }
     }
     else
     {
-      setMainText("\n                      Connection failed");
+      setMainText(tr("\n                      Connection failed"));
       ts.tv_sec = 3;
       ts.tv_nsec = 0;
     }
index b9f086e86f72a3702fba12864fb2c724413e3d7a..5cc6925406e4c189f5dfe05481dd5cf4b7bb58aa 100644 (file)
@@ -33,6 +33,7 @@
 #include "colour.h"
 #include "video.h"
 #include "thread.h"
+#include "i18n.h"
 
 class VConnect : public VInfo, public Thread
 {
diff --git a/vdr.cc b/vdr.cc
index 7cc6fc252ceeabb0fbf387bb26a18fd26e0d6116..3776d044641d43ac8539660ca137219eca6b35f5 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -710,7 +710,7 @@ ULLONG VDR::getResumePoint(char* fileName)
   return toReturn;
 }
 
-int VDR::configSave(char* section, char* key, char* value)
+int VDR::configSave(char* section, char* key, const char* value)
 {
   if (!connected) return 0;
 
diff --git a/vdr.h b/vdr.h
index 9f971c48ba1602cbebebe41e9d033cea41e7b3da..72322931011c19f01fc4c0be1153e5b7d00834b6 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -76,7 +76,7 @@ class VDR
     UCHAR*     getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived);
     int        stopStreaming();
     EventList* getChannelSchedule(ULONG number);
-    int        configSave(char* section, char* key, char* value);
+    int        configSave(char* section, char* key, const char* value);
     char*      configLoad(char* section, char* key);
 
     // end
index 1c1dcf0817e20ab8e9b8d95715780c88d982149a..639873088380905d06716806d1b5667a61c194f0 100644 (file)
@@ -80,7 +80,7 @@ void VLiveBanner::setChannel(Channel* tChannel)
 
   if (!eventList)
   {
-    sl.addOption("No channel data available", 1);
+    sl.addOption(tr("No channel data available"), 1);
   }
   else
   {
@@ -118,7 +118,7 @@ void VLiveBanner::draw()
   rectangle(0, height - 30, width, 30, titleBarColour);
 
   rectangle(7, height - 24, 18, 16, Colour::RED);
-  drawText("info", 32, height - 25, Colour::LIGHTTEXT);
+  drawText(tr("info"), 32, height - 25, Colour::LIGHTTEXT);
 }
 
 int VLiveBanner::handleCommand(int command)
@@ -186,7 +186,7 @@ int VLiveBanner::handleCommand(int command)
           vi->setBorderOn(1);
           vi->setExitable();
           if (event->description) vi->setMainText(event->description);
-          else vi->setMainText("Summary unavailable");
+          else vi->setMainText(tr("Summary unavailable"));
           if (Video::getInstance()->getFormat() == Video::PAL)
           {
             vi->setScreenPos(120, 130);
index 993db1a0c432480405af7c55d7b739f800760c73..9bb8741ad7e07be7ec31d8722767fd6af8cd3e28 100644 (file)
@@ -35,6 +35,7 @@
 #include "event.h"
 #include "vinfo.h"
 #include "viewman.h"
+#include "i18n.h"
 
 class VLiveBanner : public View
 {
index a18aa2577adcad224944cdcf8b44b7271a6198fe..bb1e6a8f9d8173c599a4a8979cbe4b658168dd88 100644 (file)
 
 VOptions::VOptions()
 {
-  create(500, 285);
+  create(500, 75+(NUM_OPTIONS*30));
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(120, 140);
   }
   else
   {
-    setScreenPos(110, 110);
+    setScreenPos(110, 80);
   }
 
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
-  setTitleText("Options");
+  setTitleText(tr("Options"));
 
   int fontHeight = surface->getFontHeight();
 
@@ -49,7 +49,7 @@ VOptions::VOptions()
     {
       Log::getInstance()->log("Options", Log::DEBUG, "Add option");
       Log::getInstance()->log("Options", Log::DEBUG, "Add option: %s", optionData[i].options[j]);
-      optionBox[i].addOption(optionData[i].options[j]);
+      optionBox[i].addOption(tr(optionData[i].options[j]));
       Log::getInstance()->log("Options", Log::DEBUG, "Done add option");
     }
   }
@@ -59,7 +59,7 @@ VOptions::VOptions()
 
   for (i = 0; i < numOptions; i++)
   {
-    optionBox[i].setSelected(optionData[i].options[optionData[i].defaultOption]);
+    optionBox[i].setSelected(tr(optionData[i].options[optionData[i].defaultOption]));
     config = vdr->configLoad(optionData[i].configSection, optionData[i].configParam);
     if (config)
     {
@@ -67,7 +67,7 @@ VOptions::VOptions()
       {
         if (!strcasecmp(config, optionData[i].options[j]))
         {
-          optionBox[i].setSelected(optionData[i].options[j]);
+          optionBox[i].setSelected(tr(optionData[i].options[j]));
         }
       }
       delete[] config;
@@ -89,13 +89,13 @@ void VOptions::draw()
   WSymbol wsy;
   Colour cl;
 
-  drawText("Press back to exit, <, > or [ok] to change", 10, 255, Colour::LIGHTTEXT);
+  drawText(tr("Press back to exit, <, > or [ok] to change"), 10, 45+numOptions*30, Colour::LIGHTTEXT);
 
   wsy.setSurface(surface);
 
   for (UINT i = 0; i < numOptions; i++)
   {
-    drawText(optionData[i].title, 10, 45+i*30, Colour::LIGHTTEXT);
+    drawText(tr(optionData[i].title), 10, 45+i*30, Colour::LIGHTTEXT);
 
     if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT;
     else cl = Colour::BUTTONBACKGROUND;
@@ -177,18 +177,19 @@ int VOptions::handleCommand(int command)
 
 void VOptions::doSave()
 {
-  char* result[numOptions];
+  int result[numOptions];
 
   for (UINT i = 0; i < numOptions; i++)
   {
-    result[i] = optionBox[i].getSelected();
-    vdr->configSave(optionData[i].configSection, optionData[i].configParam, result[i]);
+    result[i] = optionBox[i].getSelectedIndex();
+    vdr->configSave(optionData[i].configSection, optionData[i].configParam,
+  optionData[i].options[result[i]]);
   }
 
   // Apply changes
   Video* video = Video::getInstance();
 
-  if (!strcmp(result[0], optionData[0].options[1]))
+  if (result[0] == 1)
   {
     Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
     Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
@@ -199,7 +200,7 @@ void VOptions::doSave()
     Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
   }
 
-  if (!strcmp(result[1], optionData[1].options[1]))
+  if (result[2] == 1)
   {
     Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
     video->setConnection(Video::SVIDEO);
@@ -210,7 +211,7 @@ void VOptions::doSave()
     video->setConnection(Video::COMPOSITERGB);
   }
 
-  if (!strcmp(result[2], optionData[2].options[1]))
+  if (result[3] == 1)
   {
     Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
     video->setTVsize(Video::ASPECT16X9);
@@ -221,7 +222,7 @@ void VOptions::doSave()
     video->setTVsize(Video::ASPECT4X3);
   }
 
-  if (!strcmp(result[3], optionData[3].options[1]))
+  if (result[4] == 1)
   {
     Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
     video->setMode(Video::LETTERBOX);
@@ -231,6 +232,6 @@ void VOptions::doSave()
     Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
     video->setMode(Video::NORMAL);
   }
-
+  I18n::Initialize();
 }
 
index 96d2db721c51419f9dde66a823e411cda7ec3d52..1c1fd544decc25ffc8e101a262a29f28bd5546f4 100644 (file)
@@ -29,8 +29,9 @@
 #include "video.h"
 #include "woptionbox.h"
 #include "wsymbol.h"
+#include "i18n.h"
 
-#define NUM_OPTIONS 7
+#define NUM_OPTIONS 8
 typedef struct
 {
   char *title;           // Name of the option
@@ -38,20 +39,22 @@ typedef struct
   char *configParam;     // Parameter name in the config file
   UINT optionCount;      // How many choices?
   UINT defaultOption;    // Serial of the default choice (base 0)
-  const char **options;  // Text for the options
+  char **options;  // Text for the options
 } OPTIONDATA;
 
-const static char* options0[] = {"Old", "New"};
-const static char* options1[] = {"RGB+composite", "S-Video"};
-const static char* options2[] = {"4:3", "16:9"};
-const static char* options3[] = {"Chop sides", "Letterbox"};
-const static char* options4[] = {"On", "Off", "Last state"};
-const static char* options5[] = {"All", "FTA only"};
-const static char* options6[] = {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "99"};
+static char* options0[] = {"Old", "New"};
+static char* options1[] = {"RGB+composite", "S-Video"};
+static char* options2[] = {"4:3", "16:9"};
+static char* options3[] = {"Chop sides", "Letterbox"};
+static char* options4[] = {"On", "Off", "Last state"};
+static char* options5[] = {"All", "FTA only"};
+static char* options6[] = {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "99"};
+static char *i18nLanguages[] = { "English", "Test" };
 
 const static OPTIONDATA optionData[NUM_OPTIONS] =
 {
   {"Remote control type",      "General", "Remote type",      2, 0, options0 },
+  {"Language",                 "General", "Language",         NUM_LANGUAGES, 0, i18nLanguages },
   {"TV connection type",       "TV",      "Connection",       2, 0, options1 },
   {"TV aspect ratio",          "TV",      "Aspect",           2, 0, options2 },
   {"16:9 on 4:3 display mode", "TV",      "Widemode",         2, 0, options3 },
index 9ca83afe527dc0089048fccdfa5c1b108fab3bdc..d34c4de0cf18f7b888f93783ab776528289c79c2 100644 (file)
@@ -28,8 +28,8 @@ VQuestion::VQuestion()
   buttonYes.setSurfaceOffset(40, 120);
   buttonNo.setSurfaceOffset(140, 120);
 
-  buttonYes.setText("Yes");
-  buttonNo.setText("No");
+  buttonYes.setText(tr("Yes"));
+  buttonNo.setText(tr("No"));
   buttonNo.setActive(1);
 }
 
index 67f7d01e35a6cfde7cf43c8eafbc513a0b8954ce..5a96d2d83d4011630878574a7c7ccf61e53aa341 100644 (file)
@@ -29,6 +29,7 @@
 #include "remote.h"
 #include "viewman.h"
 #include "colour.h"
+#include "i18n.h"
 
 class VQuestion : public View
 {
index cf3e73628343bc87e97da968dee193cd689cdb0b..5cce73c0908f78c0f0c649fabdc59f47a0cf3ab2 100644 (file)
@@ -71,12 +71,12 @@ void VRecordingList::setDir(Directory* tdir)
   char title[300];
   if (!recDir->isRoot)
   {
-    snprintf(title, 299, "Recordings - %s", recDir->name);
+    snprintf(title, 299, tr("Recordings - %s"), recDir->name);
     setTitleText(title);
   }
   else
   {
-    setTitleText("Recordings");
+    setTitleText(tr("Recordings"));
   }
 }
 
@@ -117,7 +117,7 @@ void VRecordingList::drawData()
   for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++)
   {
     dir = *i;
-    snprintf(tempA, 299, "<dir> %lu\t%s", dir->getNumRecordings(), dir->name);
+    snprintf(tempA, 299, tr("<dir> %lu\t%s"), dir->getNumRecordings(), dir->name);
     dir->index = sl.addOption(tempA, first);
     first = 0;
   }
@@ -173,13 +173,13 @@ void VRecordingList::draw()
   w.draw();
 
   // FIXME Right justify this!
-  drawText("[ok] = menu", 450, 385, Colour::LIGHTTEXT);
+  drawText(tr("[ok] = menu"), 450, 385, Colour::LIGHTTEXT);
 
   doShowingBar();
 
   char freeSpace[50];
   int gigFree = Directory::freeSpace / 1024;
-  snprintf(freeSpace, 49, "%lu%% used, %iGB free", Directory::usedPercent, gigFree);
+  snprintf(freeSpace, 49, tr("%lu%% used, %iGB free"), Directory::usedPercent, gigFree);
   drawTextRJ(freeSpace, 560, 5, Colour::LIGHTTEXT);
 }
 
@@ -189,7 +189,7 @@ void VRecordingList::doShowingBar()
   if (sl.getNumOptions() == 0) topOption = 0;
 
   char showing[200];
-  sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
+  sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
 
 //  Box b;
 //  b.setSurfaceOffset(220, 385);
index 18a8f5ef6bc2087fd3b8d25f4112435578e2a51d..817901f0a1e4846f2a3e6ae9a29b156399b35e6d 100644 (file)
@@ -37,6 +37,7 @@
 #include "vvideorec.h"
 #include "colour.h"
 #include "video.h"
+#include "i18n.h"
 
 class VRecordingList : public View
 {
index 2aa6ade65fbed7b723329077454ed3c451958b59..bbc3b3b5bb632a9908944ee1a96485b28222fa16 100644 (file)
@@ -38,16 +38,16 @@ VRecordingMenu::VRecordingMenu()
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
   setBorderOn(1);
-  setTitleText("Programme menu");
+  setTitleText(tr("Programme menu"));
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
 
   sl.setSurface(surface);
   sl.setSurfaceOffset(10, 30 + 5);
   sl.setDimensions(width - 20, height - 30 - 15);
-  sl.addOption("Play", 1);
-  sl.addOption("Resume", 0);
-  sl.addOption("Summary", 0);
-  sl.addOption("Delete", 0);
+  sl.addOption(tr("Play"), 1);
+  sl.addOption(tr("Resume"), 0);
+  sl.addOption(tr("Summary"), 0);
+  sl.addOption(tr("Delete"), 0);
 }
 
 VRecordingMenu::~VRecordingMenu()
@@ -117,11 +117,11 @@ int VRecordingMenu::handleCommand(int command)
         char* summary = VDR::getInstance()->getRecordingSummary(rec->fileName);
 
         VInfo* vi = new VInfo();
-        vi->setTitleText("Programme summary");
+        vi->setTitleText(tr("Programme summary"));
         vi->setBorderOn(1);
         vi->setExitable();
         if (summary) vi->setMainText(summary);
-        else vi->setMainText("Summary unavailable");
+        else vi->setMainText(tr("Summary unavailable"));
         if (Video::getInstance()->getFormat() == Video::PAL)
         {
           vi->setScreenPos(120, 130);
@@ -149,8 +149,8 @@ int VRecordingMenu::handleCommand(int command)
         v->setTitleBarColour(Colour::DANGER);
         v->setTitleBarOn(1);
         v->setBorderOn(1);
-        v->setTitleText("Delete recording");
-        v->setMainText("Are you sure you want to delete this recording?");
+        v->setTitleText(tr("Delete recording"));
+        v->setMainText(tr("Are you sure you want to delete this recording?"));
         v->setDefault(VQuestion::NO);
         if (Video::getInstance()->getFormat() == Video::PAL)
         {
index e589f5ff8a92ad2b377f7857318e70b11e942314..3fae830ad85bf22b0cb7e4939e7192d2cad1092c 100644 (file)
@@ -35,6 +35,7 @@
 #include "vdr.h"
 #include "colour.h"
 #include "video.h"
+#include "i18n.h"
 
 class VRecordingList;
 
index 91fb97f0d2300d23fe8c07c431f26a7b25fd7574..687c4a4efa358265a742ae3aca3eb0b21136adb1 100644 (file)
@@ -40,7 +40,7 @@ VServerSelect::VServerSelect(std::vector<char*>* serverIPs)
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
-  setTitleText("Choose a VDR server");
+  setTitleText(tr("Choose a VDR server"));
 
   sl.setSurface(surface);
   sl.setSurfaceOffset(10, 30 + 5);
index 463e104d4f906c76f8e54c1888f63ed2fdad9716..2a9ecd2835a4854234203fa0dd123bce2b4c2bce 100644 (file)
@@ -32,6 +32,7 @@
 #include "colour.h"
 #include "video.h"
 #include "viewman.h"
+#include "i18n.h"
 
 class VServerSelect : public View
 {
index 05f0fed0c43b7a63c622770f5dd4226deb7e1954..1dc413a9ef812b858473509c1cda02773c535a7a 100644 (file)
@@ -188,7 +188,7 @@ void VVideoLive::showUnavailable(int active)
       unavailableView->setScreenPos(160, 150);
     }
     unavailableView->setTitleText((*chanList)[currentChannel]->name);
-    unavailableView->setMainText("\n                    Channel unavailable");
+    unavailableView->setMainText(tr("\n                    Channel unavailable"));
     unavailableView->setDropThrough();
 
     Message* m = new Message();
index 2c72efe3414ef2721ba6a9c2bd44f61fbd2ef6c1..7ef9cb530f34059efa5c9622536385f31e4974de 100644 (file)
@@ -36,6 +36,7 @@
 #include "osd.h"
 #include "vinfo.h"
 #include "command.h"
+#include "i18n.h"
 
 class VVideoLive : public View
 {
index d5e8dc7627914bb338b1bb07d9169f6afedcb89d..29cc91c4e2d636d863d2bf5e5aa5b540e983c40f 100644 (file)
@@ -38,17 +38,17 @@ VWelcome::VWelcome()
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
-  setTitleText("Welcome");
+  setTitleText(tr("Welcome"));
 
   sl.setSurfaceOffset(20, 40);
   sl.setDimensions(170, 140);
 
-  sl.addOption("1. Live TV", 1);
-  sl.addOption("2. Radio", 0);
-  sl.addOption("3. Recordings", 0);
-  sl.addOption("4. Options", 0);
-  sl.addOption("5. Stand by", 0);
-  sl.addOption("6. Reboot", 0);
+  sl.addOption(tr("1. Live TV"), 1);
+  sl.addOption(tr("2. Radio"), 0);
+  sl.addOption(tr("3. Recordings"), 0);
+  sl.addOption(tr("4. Options"), 0);
+  sl.addOption(tr("5. Stand by"), 0);
+  sl.addOption(tr("6. Reboot"), 0);
 
   jpeg.setSurfaceOffset(240, 60);
 }
@@ -221,7 +221,7 @@ void VWelcome::doRecordingsList()
   {
     viewWait->setScreenPos(130, 140);
   }
-  viewWait->setMainText("\n                  Downloading recordings list");
+  viewWait->setMainText(tr("\n                  Downloading recordings list"));
   viewWait->draw();
   viewWait->show();
   viewman->addNoLock(viewWait);
index e8f680ee8b99e36e4ae07b81ed66958ec5279413..e78f01af8d8766e619ef51fbd29bbeea7b573dbd 100644 (file)
@@ -38,6 +38,7 @@
 #include "colour.h"
 #include "video.h"
 #include "voptions.h"
+#include "i18n.h"
 
 class VWelcome : public View
 {
index ca56e273e953f939238f9762472a98de00179abb..70efeb8f7bc60ac5b1a78e50fea2422993fb2cd0 100644 (file)
@@ -112,3 +112,8 @@ char* WOptionBox::getSelected()
 {
   return options[currentOption];
 }
+
+int WOptionBox::getSelectedIndex()
+{
+  return currentOption;
+}
index b840b137705ee3e3e3a92f4dd069d04b4d97ff99..433a7f64435ceade48d22ab34a00a358ea7a50fe 100644 (file)
@@ -40,6 +40,7 @@ class WOptionBox : public Widget
     void right();
     void cycle();
     void draw();
+    int getSelectedIndex();
 
   private:
     UCHAR active;