diff --git a/src/nhttpd/yhttpd_core/ylanguage.cpp b/src/nhttpd/yhttpd_core/ylanguage.cpp index f733d16e2..32f1ea553 100644 --- a/src/nhttpd/yhttpd_core/ylanguage.cpp +++ b/src/nhttpd/yhttpd_core/ylanguage.cpp @@ -9,6 +9,9 @@ #include #include +#include +#include + #include // 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 //----------------------------------------------------------------------------- diff --git a/src/nhttpd/yhttpd_core/ylanguage.h b/src/nhttpd/yhttpd_core/ylanguage.h index 06570ccfe..2f33b9706 100644 --- a/src/nhttpd/yhttpd_core/ylanguage.h +++ b/src/nhttpd/yhttpd_core/ylanguage.h @@ -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__ */