2 Copyright 2007 Mark Calderbank
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 //Nothing is using this ?
35 I18n::trans_table I18n::Translations;
37 int I18n::initialize(void)
39 VDR *vdr = VDR::getInstance();
40 char *lang = vdr->configLoad("General", "LangCode");
41 lang_code_list list = vdr->getLanguageList();
43 if (lang && list.count(lang) > 0)
47 // There is no LangCode in the config file, or the selected
48 // language isn't available on the server.
49 // Use 'en' if it exists on the server or if no languages
50 // are available. Otherwise use the first available language.
51 if (list.count("en") > 0 || list.empty())
54 code = list.begin()->first;
55 vdr->configSave("General", "LangCode", code.c_str());
57 vdr->getLanguageContent(code, Translations);
61 const char* I18n::translate(const char *s)
64 if (Translations.count(str) == 0) return s;
65 return Translations[str].c_str();
66 // This isn't ideal. A call to initialize() invalidates
67 // the c_str(), so we need to make sure that no return
68 // values from this function are expected to remain
69 // valid after an initialize().