mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 23:42:51 +02:00
yWeb 2.8.a.3 Alpha-Version
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@406 e54a6e83-5905-42d5-8d5c-058d10e6a962
Origin commit data
------------------
Branch: ni/coolstream
Commit: 32c7517141
Author: yjogol <yjogol2@online.de>
Date: 2010-02-24 (Wed, 24 Feb 2010)
------------------
This commit was generated by Migit
This commit is contained in:
92
src/nhttpd/yhttpd_core/ylanguage.cpp
Normal file
92
src/nhttpd/yhttpd_core/ylanguage.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
//=============================================================================
|
||||
// YHTTPD
|
||||
// Language
|
||||
//=============================================================================
|
||||
|
||||
// c
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include "yhttpd.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "ylanguage.h"
|
||||
#include "yconnection.h"
|
||||
//=============================================================================
|
||||
// Instance Handling - like Singelton Pattern
|
||||
//=============================================================================
|
||||
//-----------------------------------------------------------------------------
|
||||
// Init as Singelton
|
||||
//-----------------------------------------------------------------------------
|
||||
CLanguage* CLanguage::instance = NULL;
|
||||
CConfigFile* CLanguage::DefaultLanguage = NULL;
|
||||
CConfigFile* CLanguage::ConfigLanguage = NULL;
|
||||
std::string CLanguage::language = "";
|
||||
std::string CLanguage::language_dir = "";
|
||||
//-----------------------------------------------------------------------------
|
||||
// There is only one Instance
|
||||
//-----------------------------------------------------------------------------
|
||||
CLanguage *CLanguage::getInstance(void){
|
||||
if (!instance)
|
||||
instance = new CLanguage();
|
||||
return instance;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLanguage::deleteInstance(void){
|
||||
if (instance)
|
||||
delete instance;
|
||||
instance = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CLanguage::CLanguage(void)
|
||||
{
|
||||
DefaultLanguage = new CConfigFile(',');
|
||||
ConfigLanguage = new CConfigFile(',');
|
||||
language = "";
|
||||
language_dir =getLanguageDir();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CLanguage::~CLanguage(void)
|
||||
{
|
||||
delete DefaultLanguage;
|
||||
delete ConfigLanguage;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLanguage::setLanguage(std::string _language){
|
||||
language=_language;
|
||||
ConfigLanguage->loadConfig(language_dir + "/" + _language);
|
||||
DefaultLanguage->loadConfig(language_dir + "/" + HTTPD_DEFAULT_LANGUAGE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// return translation for "id" if not found use default language
|
||||
//-----------------------------------------------------------------------------
|
||||
std::string CLanguage::getTranslation(std::string id){
|
||||
std::string trans=ConfigLanguage->getString(id,"");
|
||||
if(trans=="")
|
||||
trans=DefaultLanguage->getString(id,"");
|
||||
return trans;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Find language directory
|
||||
//-----------------------------------------------------------------------------
|
||||
std::string CLanguage::getLanguageDir(void){
|
||||
std::string tmpfilename = "/"+Cyhttpd::ConfigList["Language.directory"],dir="";
|
||||
|
||||
if( access(std::string(Cyhttpd::ConfigList["PublicDocumentRoot"] + tmpfilename).c_str(),4) == 0)
|
||||
dir = Cyhttpd::ConfigList["PublicDocumentRoot"] + tmpfilename;
|
||||
else if(access(std::string(Cyhttpd::ConfigList["PrivatDocumentRoot"] + tmpfilename).c_str(),4) == 0)
|
||||
dir = Cyhttpd::ConfigList["PrivatDocumentRoot"] + tmpfilename;
|
||||
return dir;
|
||||
}
|
||||
|
Reference in New Issue
Block a user