From 5324c57a38dafe1e3754e6c94cd63a66dfb42c00 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Fri, 8 Nov 2013 15:07:02 +0100 Subject: [PATCH] - ylanguage.cpp: add neutrino locale as an additional locale file for yWeb --- src/nhttpd/yhttpd_core/Makefile.am | 8 ++++++++ src/nhttpd/yhttpd_core/ylanguage.cpp | 25 +++++++++++++++++++++++++ src/nhttpd/yhttpd_core/ylanguage.h | 1 + 3 files changed, 34 insertions(+) diff --git a/src/nhttpd/yhttpd_core/Makefile.am b/src/nhttpd/yhttpd_core/Makefile.am index 1a0a81aaa..e4ffb5e10 100644 --- a/src/nhttpd/yhttpd_core/Makefile.am +++ b/src/nhttpd/yhttpd_core/Makefile.am @@ -11,6 +11,14 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib/libconfigfile \ @FREETYPE_CFLAGS@ +if BOXTYPE_COOL +if BOXMODEL_APOLLO +AM_CPPFLAGS += -I$(top_srcdir)/lib/libcoolstream2 +else +AM_CPPFLAGS += -I$(top_srcdir)/lib/libcoolstream +endif +endif + AM_CPPFLAGS += -fno-rtti -fno-exceptions noinst_LIBRARIES = libyhttpd.a diff --git a/src/nhttpd/yhttpd_core/ylanguage.cpp b/src/nhttpd/yhttpd_core/ylanguage.cpp index 38c67f9df..f07a01809 100644 --- a/src/nhttpd/yhttpd_core/ylanguage.cpp +++ b/src/nhttpd/yhttpd_core/ylanguage.cpp @@ -15,6 +15,9 @@ #include "ytypes_globals.h" #include "ylanguage.h" #include "yconnection.h" + +#include + //============================================================================= // Instance Handling - like Singelton Pattern //============================================================================= @@ -24,6 +27,7 @@ CLanguage* CLanguage::instance = NULL; CConfigFile* CLanguage::DefaultLanguage = NULL; CConfigFile* CLanguage::ConfigLanguage = NULL; +CConfigFile* CLanguage::NeutrinoLanguage = NULL; std::string CLanguage::language = ""; std::string CLanguage::language_dir = ""; //----------------------------------------------------------------------------- @@ -49,6 +53,7 @@ CLanguage::CLanguage(void) { DefaultLanguage = new CConfigFile(','); ConfigLanguage = new CConfigFile(','); + NeutrinoLanguage = new CConfigFile(','); language = ""; language_dir =getLanguageDir(); } @@ -58,6 +63,7 @@ CLanguage::~CLanguage(void) { delete DefaultLanguage; delete ConfigLanguage; + delete NeutrinoLanguage; } //============================================================================= @@ -67,6 +73,23 @@ void CLanguage::setLanguage(std::string _language){ language=_language; ConfigLanguage->loadConfig(language_dir + "/" + _language); DefaultLanguage->loadConfig(language_dir + "/" + HTTPD_DEFAULT_LANGUAGE); + + const char * path[2] = { CONFIGDIR "/locale/", DATADIR "/neutrino/locale/"}; + for (int i = 0; i < 2; i++) + { + std::string filename = path[i]; + filename += g_settings.language; + filename += ".locale"; + + if(access(filename.c_str(), F_OK) == 0) { + NeutrinoLanguage->loadConfig(filename, ' '); + break; + } + else if (i == 2) { + // load neutrino default language + NeutrinoLanguage->loadConfig(DATADIR "/neutrino/locale/english.locale", ' '); + } + } } //----------------------------------------------------------------------------- @@ -74,6 +97,8 @@ void CLanguage::setLanguage(std::string _language){ //----------------------------------------------------------------------------- std::string CLanguage::getTranslation(std::string id){ std::string trans=ConfigLanguage->getString(id,""); + if(trans=="") + trans=NeutrinoLanguage->getString(id,""); if(trans=="") trans=DefaultLanguage->getString(id,""); return trans; diff --git a/src/nhttpd/yhttpd_core/ylanguage.h b/src/nhttpd/yhttpd_core/ylanguage.h index e90658fc2..06570ccfe 100644 --- a/src/nhttpd/yhttpd_core/ylanguage.h +++ b/src/nhttpd/yhttpd_core/ylanguage.h @@ -24,6 +24,7 @@ class CLanguage static CConfigFile *DefaultLanguage; static CConfigFile *ConfigLanguage; + static CConfigFile *NeutrinoLanguage; public: // Instance Handling