mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 17:01:15 +02:00
yWeb: write missing translations to file
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <system/helpers.h>
|
||||
|
||||
// yhttpd
|
||||
@@ -103,10 +106,40 @@ std::string CLanguage::getTranslation(std::string id){
|
||||
trans=NeutrinoLanguage->getString(id,"");
|
||||
if(trans.empty())
|
||||
trans=DefaultLanguage->getString(id,"");
|
||||
if (trans.empty())
|
||||
if (trans.empty()) {
|
||||
write_missing_trans(id);
|
||||
trans = "# " + id + " #";
|
||||
}
|
||||
return trans;
|
||||
}
|
||||
void CLanguage::write_missing_trans(std::string const& entry)
|
||||
{
|
||||
std::string file = "/tmp/yweb.missing.translation";
|
||||
std::ifstream in;
|
||||
std::ofstream out;
|
||||
std::string line;
|
||||
bool found = false;
|
||||
|
||||
in.open(file, std::ios::in);
|
||||
if(in.is_open())
|
||||
{
|
||||
while (std::getline(in, line) && !found)
|
||||
{
|
||||
if (line.compare(entry) == 0)
|
||||
found = true;
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
out.open(file, std::ios::out|std::ios::app);
|
||||
if (out.is_open())
|
||||
{
|
||||
out << entry << std::endl;
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Find language directory
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@@ -40,6 +40,7 @@ class CLanguage
|
||||
std::string getLanguageDir(void);
|
||||
|
||||
std::string getTranslation(std::string id);
|
||||
void write_missing_trans(std::string const& entry);
|
||||
};
|
||||
|
||||
#endif /* __yttpd_language_h__ */
|
||||
|
Reference in New Issue
Block a user