From 03708ef626b309a4e23b0c6655cbae77ee902bc4 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 7 Nov 2005 23:51:57 +0000 Subject: [PATCH] I18n --- Makefile | 2 +- command.cc | 3 +- command.h | 1 + i18n.cc | 349 ++++++++++++++++++++++++++++++++++++++++++++++ i18n.h | 58 ++++++++ main.cc | 2 + vchannellist.cc | 6 +- vchannellist.h | 1 + vconnect.cc | 8 +- vconnect.h | 1 + vdr.cc | 2 +- vdr.h | 2 +- vlivebanner.cc | 6 +- vlivebanner.h | 1 + voptions.cc | 33 ++--- voptions.h | 21 +-- vquestion.cc | 4 +- vquestion.h | 1 + vrecordinglist.cc | 12 +- vrecordinglist.h | 1 + vrecordingmenu.cc | 18 +-- vrecordingmenu.h | 1 + vserverselect.cc | 2 +- vserverselect.h | 1 + vvideolive.cc | 2 +- vvideolive.h | 1 + vwelcome.cc | 16 +-- vwelcome.h | 1 + woptionbox.cc | 5 + woptionbox.h | 1 + 30 files changed, 496 insertions(+), 66 deletions(-) create mode 100644 i18n.cc create mode 100644 i18n.h diff --git a/Makefile b/Makefile index 9c60e3f..2ab18e5 100644 --- 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 diff --git a/command.cc b/command.cc index f440396..d30729c 100644 --- a/command.cc +++ b/command.cc @@ -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); diff --git a/command.h b/command.h index 8e357b1..2ce4014 100644 --- 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 index 0000000..5b60efe --- /dev/null +++ b/i18n.cc @@ -0,0 +1,349 @@ +/* + * i18n.c: Internationalization + * + * This code is taken from the VDR project and modified for VOMP. + * See the main source file 'vdr.c' for original copyright information. + * Modifications (C) 2005 D Pickles. + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * How to add a new language: + * + * 1. Announce your translation action on the VOMP mailing + * list to avoid duplicate work. + * 2. Increase the value of 'NUM_LANGUAGES' in i18n.h. + * 3. Insert a new line in the 'Languages' array containing the name of your + * language IN YOUR LANGUAGE, so 'Italiano' not 'Italian' for example. + * Append your language after the last existing language + * but before the 'test' language + * 4. Insert a new line in the charSets array containing the name of the character + * set needed for your language. Note that at present only ISO8859-1 is + * supported + * 5. Insert a new line in the languageCodes array containing the 3-letter + * abbreviation(s) for your language as used in the channels.conf. + * 6. Insert a line in evry member of the 'Phrases[]' array, + * containing the translated text for your language. You can use the 'test' + * language to see where the phrases appear on the screen. + * 7. Add the name of your language to the i18nLanguages array in voptions.h. + * 8. If your language requires a character set other than the default iso8859-1 + * then work will be needed elsewhere in vomp to manage multiple font files. + * 9. Compile VOMP and test the new language by switching to it + * in the "Options" menu. + *10. Send the modified files to Chris to have it included in the next version. + * + * In case an English phrase is used in more than one context (and might need + * different translations in other languages) it can be preceeded 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 "log.h" +#include "vdr.h" + + // The names of the languages (English MUST be first!): +static char *Languages[] = + { "English", + "Test" + }; + + // The character set needed for each language: +const static char *charSets[] = + { "iso8859-1", + "iso8859-1" + }; + + // The 3-letter names of the language (this MUST be the third phrase!): +const char *languageCodes[] = + { "eng,dos", + "tst,xxx" + }; + + // The phrases to be translated: + +const static tI18nPhrase Phrases[] = { + // Menu titles: + { "VDR", + "VDR", + }, + { "Schedule", + "0", + }, + // Welcome screen + { "Welcome", + "1", + }, + { "1. Live TV", + "2", + }, + { "2. Radio", + "3", + }, + { "3. Recordings", + "4", + }, + { "4. Options", + "5", + }, + { "5. Stand by", + "6", + }, + { "6. Reboot", + "7", + }, + { "\n Downloading recordings list", + "8", + }, + // Recordings list + { "Recordings - %s", + "9 - %s", + }, + { "Recordings", + "10", + }, + { " %lu\t%s", + "11 %lu\t%s", + }, + { "[ok] = menu", + "12", + }, + { "%lu%% used, %iGB free", + "13 %lu%% %i", + }, + { "%i to %i of %i", // Also used in channels list + "14 %i %i %i", + }, + // Question + { "Yes", + "15", + }, + { "No", + "16", + }, + // Recording Menu + { "Programme menu", + "17", + }, + { "Play", + "18", + }, + { "Resume", + "19", + }, + { "Summary", + "20", + }, + { "Delete", + "21", + }, + { "Programme summary", + "22", + }, + { "Summary unavailable", + "23", + }, + { "Delete recording", + "24", + }, + { "Are you sure you want to delete this recording?", + "25", + }, + // Server select + { "Choose a VDR server", + "26", + }, + + // Option menus + { "Options", + "27", + }, + { "TV connection type", + "28", + }, + { "Remote control type", + "29", + }, + { "TV aspect ratio", + "30", + }, + { "16:9 on 4:3 display mode", + "30a", + }, + { "Power state after bootup", + "31", + }, + { "Display channels", + "32", + }, + { "Language", + "33", + }, + { "Press back to exit, <, > or [ok] to change", + "34", + }, + { "VDR-Pri 0=OK !See forums!", + "34a", + }, + // Option choices + { "Old", + "35", + }, + { "New", + "36", + }, + { "RGB+composite", + "37", + }, + { "S-Video", + "38", + }, + { "Chop sides", + "39", + }, + { "Letterbox", + "40", + }, + { "Last state", + "41", + }, + { "All", + "42", + }, + { "FTA only", + "43", + }, + { "On", + "44", + }, + { "Off", + "45", + }, + + // Channel Lists + { "Channels", + "46", + }, + { "Radio Stations", + "47", + }, + // Banners + { "No channel data available", + "48", + }, + { "info", + "49", + }, + { "info", + "50", + }, + { "\n Channel unavailable", + "51", + }, + // Connect screen + { "\n Locating server", + "52", + }, + { "\n Connecting to VDR", + "53", + }, + { "\n Login failed", + "54", + }, + { "\n Connection failed", + "55", + }, + // Command + { "\n Connected, loading config", + "56", + }, + // End marker. + { NULL } + }; + + static int LanguageID = INITIAL_LANGUAGE_INDEX; + + +int I18n::Initialize(void) { + + VDR *vdr = VDR::getInstance(); + char *lang = vdr->configLoad("General", "Language"); + if (lang) { + LanguageID = LanguageIndex(lang); + if (LanguageID == -1) { + LanguageID = 0; + } + } + else { + LanguageID = LanguageIndex(INITIAL_LANGUAGE); + } + return LanguageID; +} + +char *I18n::Translate(char *s) +{ + if (LanguageID >= 0) { + const tI18nPhrase *p = Phrases; + for (int i = ((p == Phrases) ? 1 : 2); i--; ) { + for (; **p; p++) { + if (strcmp(s, **p) == 0) { + char *t = (*p)[LanguageID]; + if (t && *t) return t; + } + } + p = Phrases; + } + Log::getInstance()->log("I18n", Log::ERR, "no translation found for '%s' in language %d (%s)\n", + s, LanguageID, LanguageName(LanguageID)); + } + char *p = strchr(s, '$'); + return p ? p + 1 : s; +} + +const char * const * I18n::CharSets(void) +{ + return charSets; +} + +const char * I18n::LanguageCode(int Index) +{ + return 0 <= Index && Index < I18nNumLanguages ? languageCodes[Index] : NULL; +} + +char * I18n::LanguageName(int Index) +{ + return 0 <= Index && Index < I18nNumLanguages ? Languages[Index] : NULL; +} + +int I18n::LanguageIndex(const char *Name) +{ + for (int i = 0; i < I18nNumLanguages; i++) { + if (strcasestr(Languages[i], Name)) + return i; + } + Log::getInstance()->log("I18n", Log::ERR, "unknown language: '%s'", Name); + return -1; +} + +int I18n::GetNumLanguages(void) { + return I18nNumLanguages; +} + diff --git a/i18n.h b/i18n.h new file mode 100644 index 0000000..f34b00a --- /dev/null +++ b/i18n.h @@ -0,0 +1,58 @@ +/* + * i18n.h: Internationalization + * + * This code is taken from the VDR project and modified for VOMP. + * See the main source file 'vdr.c' for original copyright information. + * Modifications (C) 2005 D Pickles. + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __I18N_H +#define __I18N_H + +#include + +#define NUM_LANGUAGES 2 +#define INITIAL_LANGUAGE "English" +#define INITIAL_LANGUAGE_INDEX 0 +#define tr(s) I18n::Translate(s) + + +typedef char *tI18nPhrase[NUM_LANGUAGES]; + + +class I18n +{ + public: + static char *Translate(char *s); + const char * const * CharSets(void); + const char * LanguageCode(int Index); + static int Initialize(void); + + static char * LanguageName(int Index); + static int LanguageIndex(const char *Name); + static int GetNumLanguages(void); + + private: + + const static int I18nNumLanguages = NUM_LANGUAGES; +}; + + +#endif //__I18N_H + diff --git a/main.cc b/main.cc index d080782..333d63f 100644 --- 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) { diff --git a/vchannellist.cc b/vchannellist.cc index 2e1a476..50f0312 100644 --- a/vchannellist.cc +++ b/vchannellist.cc @@ -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); diff --git a/vchannellist.h b/vchannellist.h index ade2a20..6f737aa 100644 --- a/vchannellist.h +++ b/vchannellist.h @@ -36,6 +36,7 @@ #include "vradiolive.h" #include "colour.h" #include "video.h" +#include "i18n.h" class VChannelList : public View { diff --git a/vconnect.cc b/vconnect.cc index 0b22d32..9f025a5 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -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; } diff --git a/vconnect.h b/vconnect.h index b9f086e..5cc6925 100644 --- a/vconnect.h +++ b/vconnect.h @@ -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 7cc6fc2..3776d04 100644 --- 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 9f971c4..7232293 100644 --- 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 diff --git a/vlivebanner.cc b/vlivebanner.cc index 1c1dcf0..6398730 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -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); diff --git a/vlivebanner.h b/vlivebanner.h index 993db1a..9bb8741 100644 --- a/vlivebanner.h +++ b/vlivebanner.h @@ -35,6 +35,7 @@ #include "event.h" #include "vinfo.h" #include "viewman.h" +#include "i18n.h" class VLiveBanner : public View { diff --git a/voptions.cc b/voptions.cc index a18aa25..bb1e6a8 100644 --- a/voptions.cc +++ b/voptions.cc @@ -22,20 +22,20 @@ 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(); } diff --git a/voptions.h b/voptions.h index 96d2db7..1c1fd54 100644 --- a/voptions.h +++ b/voptions.h @@ -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 }, diff --git a/vquestion.cc b/vquestion.cc index 9ca83af..d34c4de 100644 --- a/vquestion.cc +++ b/vquestion.cc @@ -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); } diff --git a/vquestion.h b/vquestion.h index 67f7d01..5a96d2d 100644 --- a/vquestion.h +++ b/vquestion.h @@ -29,6 +29,7 @@ #include "remote.h" #include "viewman.h" #include "colour.h" +#include "i18n.h" class VQuestion : public View { diff --git a/vrecordinglist.cc b/vrecordinglist.cc index cf3e736..5cce73c 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -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, " %lu\t%s", dir->getNumRecordings(), dir->name); + snprintf(tempA, 299, tr(" %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); diff --git a/vrecordinglist.h b/vrecordinglist.h index 18a8f5e..817901f 100644 --- a/vrecordinglist.h +++ b/vrecordinglist.h @@ -37,6 +37,7 @@ #include "vvideorec.h" #include "colour.h" #include "video.h" +#include "i18n.h" class VRecordingList : public View { diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index 2aa6ade..bbc3b3b 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -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) { diff --git a/vrecordingmenu.h b/vrecordingmenu.h index e589f5f..3fae830 100644 --- a/vrecordingmenu.h +++ b/vrecordingmenu.h @@ -35,6 +35,7 @@ #include "vdr.h" #include "colour.h" #include "video.h" +#include "i18n.h" class VRecordingList; diff --git a/vserverselect.cc b/vserverselect.cc index 91fb97f..687c4a4 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -40,7 +40,7 @@ VServerSelect::VServerSelect(std::vector* 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); diff --git a/vserverselect.h b/vserverselect.h index 463e104..2a9ecd2 100644 --- a/vserverselect.h +++ b/vserverselect.h @@ -32,6 +32,7 @@ #include "colour.h" #include "video.h" #include "viewman.h" +#include "i18n.h" class VServerSelect : public View { diff --git a/vvideolive.cc b/vvideolive.cc index 05f0fed..1dc413a 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -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(); diff --git a/vvideolive.h b/vvideolive.h index 2c72efe..7ef9cb5 100644 --- a/vvideolive.h +++ b/vvideolive.h @@ -36,6 +36,7 @@ #include "osd.h" #include "vinfo.h" #include "command.h" +#include "i18n.h" class VVideoLive : public View { diff --git a/vwelcome.cc b/vwelcome.cc index d5e8dc7..29cc91c 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -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); diff --git a/vwelcome.h b/vwelcome.h index e8f680e..e78f01a 100644 --- a/vwelcome.h +++ b/vwelcome.h @@ -38,6 +38,7 @@ #include "colour.h" #include "video.h" #include "voptions.h" +#include "i18n.h" class VWelcome : public View { diff --git a/woptionbox.cc b/woptionbox.cc index ca56e27..70efeb8 100644 --- a/woptionbox.cc +++ b/woptionbox.cc @@ -112,3 +112,8 @@ char* WOptionBox::getSelected() { return options[currentOption]; } + +int WOptionBox::getSelectedIndex() +{ + return currentOption; +} diff --git a/woptionbox.h b/woptionbox.h index b840b13..433a7f6 100644 --- a/woptionbox.h +++ b/woptionbox.h @@ -40,6 +40,7 @@ class WOptionBox : public Widget void right(); void cycle(); void draw(); + int getSelectedIndex(); private: UCHAR active; -- 2.39.5