Commit 3cef2b1c authored by Jan Koester's avatar Jan Koester
Browse files

Sprache aus der Konfiguration, fehlende deutsche Uebersetzungen

- BLOGI/LANGUAGE bzw. DOMAINS[]/LANGUAGE (DE/EN) setzt beim ersten Start
  die Spracheinstellung der Domain; bisher galt immer "en", bis sie in der
  Verwaltung geaendert wurde
- 116 fehlende deutsche Texte (Kommentare, Kontakt, Medien, Umfragen,
  statische Seiten, ...)
- content: Fehlermeldung bei unbekanntem Schlagwort uebersetzt

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent e4ddae13
Loading
Loading
Loading
Loading
+1 −0
Changes for config.yaml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ BLOGI:
      DB_CONNECTION: "/var/lib/blogi/blog-example.db"
      TEMPLATE: "/usr/local/share/blogi/themes/aurora"
      STARTPAGE: "/blog/content/index"
      # LANGUAGE: "DE"   # default: BLOGI/LANGUAGE; seeds the language setting on first start
      URL: "https://blog.example.com"
      PREFIX: "/blog"
      PLUGINDIR: "/usr/local/lib/blogi/plugins"
+1 −1
Changes for plugins/content/content.cpp: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ namespace blogi {
            if (!tag.empty()) {
                sql << "SELECT id FROM tags where name='" << dbpp::SQL::escaped(sbuf,tag.c_str()) << "' LIMIT 1";
                if(Args->database[tid]->exec(sql,res)<1){
                    excep[libhttppp::HTTPException::Critical] << "no tag data found for this name!";
                    excep[libhttppp::HTTPException::Critical] << tr(_lang,"No posts found for this tag.");
                    throw excep;
                }else {
                    sql = "SELECT content.id,content.title,content.descrition,users.displayname,content.created,content.slug FROM content ";
+8 −0
Changes for src/blogi.cpp: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -428,6 +428,14 @@ blogi::Blogi::Blogi(std::vector<netplus::socket *> serversocket, bool debug)
        // via ctx.config.
        ctx.config->loadSourcesFromDB(*initdb);

        // LANGUAGE aus der Konfiguration beim ersten Start uebernehmen;
        // danach gilt die Einstellung aus der Verwaltung.
        if (!ctx.config->getLanguage().empty()) {
            std::string cur;
            try { blogi::getConfig(*initdb, "LANGUAGE", cur); }
            catch (...) { blogi::setConfig(*initdb, "LANGUAGE", ctx.config->getLanguage()); }
        }

        ctx.plgArgs->smtp = std::make_unique<SmtpSettings>();

        try
+18 −0
Changes for src/conf.cpp: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -25,12 +25,22 @@
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/

#include <cctype>
#include <sstream>

#include <json-c/json.h>

#include "conf.h"

// LANGUAGE aus der YAML ("DE", "de", "German" ...) -> "de"/"en"; tr() kennt
// nur diese beiden Codes. Unbekanntes bleibt leer (= Standard "en").
static std::string normalizeLanguage(std::string v) {
    for (auto &ch : v) ch = static_cast<char>(std::tolower(static_cast<unsigned char>(ch)));
    if (v.rfind("de", 0) == 0) return "de";
    if (v.rfind("en", 0) == 0) return "en";
    return "";
}

blogi::Config::Config(const std::string &path) : confplus::Config(path), _ConfigPath(path){
    try { _HttpBind=getValue(getKey("/BLOGI/HTTP/BIND"),0); } catch(...) { _HttpBind="0.0.0.0"; }
    try {
@@ -67,6 +77,7 @@ blogi::Config::Config(const std::string &path) : confplus::Config(path), _Config
        _HttpPrefix = "";
    try { _Template=getValue(getKey("/BLOGI/TEMPLATE"),0); } catch(...) {}
    try { _StartPage=getValue(getKey("/BLOGI/STARTPAGE"),0); } catch(...) {}
    try { _Language=normalizeLanguage(getValue(getKey("/BLOGI/LANGUAGE"),0)); } catch(...) {}

    try{
        _SSLCertpath=getValue(getKey("/BLOGI/SSL/CERT"),0);
@@ -137,6 +148,8 @@ blogi::Config::Config(const std::string &path) : confplus::Config(path), _Config
            if (dc.prefix == "/") dc.prefix = "";
            try { dc.templatePath = getValue(getKey((base + "/TEMPLATE").c_str()), 0); } catch(...) {}
            try { dc.startPage = getValue(getKey((base + "/STARTPAGE").c_str()), 0); } catch(...) {}
            dc.language = _Language;
            try { dc.language = normalizeLanguage(getValue(getKey((base + "/LANGUAGE").c_str()), 0)); } catch(...) {}
            try { dc.mediaDBUrl = getValue(getKey((base + "/MEDIA_URL").c_str()), 0); } catch(...) {}
            try {
                std::string v = getValue(getKey((base + "/MEDIA_TLS_VERIFY").c_str()), 0);
@@ -203,6 +216,7 @@ void blogi::Config::applyDomain(const DomainConfig &dc){
        _HttpPrefix = "";
    _Template     = dc.templatePath;
    _StartPage    = dc.startPage;
    _Language     = dc.language;
    _PlgDir       = dc.plgDirs;
    _MediaDBUrl   = dc.mediaDBUrl;
    _MediaTlsVerify = dc.mediaTlsVerify;
@@ -300,6 +314,10 @@ const std::string & blogi::Config::getstartpage() const {
    return _StartPage;
}

const std::string & blogi::Config::getLanguage() const {
    return _Language;
}

const std::string & blogi::Config::getsslcertpath() const {
    return _SSLCertpath;
}
+6 −0
Changes for src/conf.h: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -96,6 +96,9 @@ namespace blogi {
        std::string               prefix;
        std::string               templatePath;
        std::string               startPage;
        // Default site language (LANGUAGE: DE/EN). Seeds the DB option
        // LANGUAGE on first start; the admin setting wins afterwards.
        std::string               language;
        std::vector<std::string>  plgDirs;
        std::string               mediaDBUrl;
        // Peer verification for the mediadb connection (MEDIA_TLS_VERIFY). Defaults to off,
@@ -123,6 +126,8 @@ namespace blogi {
        const std::string &gettemplate() const;

        const std::string &getstartpage() const;
        /// Configured default language, lower case ("de"/"en"), empty if unset.
        const std::string &getLanguage() const;

        const std::string    buildurl(const std::string &url) const;
        // Absolute URL of a server path (as returned by buildurl()) on the
@@ -241,6 +246,7 @@ namespace blogi {
        std::string               _HttpPrefix;
        std::string               _Template;
        std::string               _StartPage;
        std::string               _Language;
        std::string               _SSLCertpath;
        std::string               _SSLKeypath;
        std::string               _SSLPassword;
Loading