#pragma once

#include <utility>

#include <QByteArray>
#include <QObject>
#include <QString>

namespace detail {

class LogTr {
  public:
    LogTr() = delete;
    LogTr(const char* strLiteral) : m_string(QObject::tr(strLiteral)) {}

    operator const char *()
    {
        m_utf8String = m_string.toUtf8();
        return m_utf8String.constData();
    }

    operator QString() const { return m_string; }

    template<typename... Args>
    LogTr& arg(Args&&... args)
    {
        m_string = m_string.arg(std::forward<Args>(args)...);
        return *this;
    }

  private:
    QString m_string;
    QByteArray m_utf8String;
};

} // namespace detail

detail::LogTr log_tr(const char* formatString);

#define ltr(FormatString) "%s", (const char*)log_tr(FormatString)
