//
//     Copyright 2008 Jim Bublitz <jbublitz@nwinternet.com>
//     Earlier copyrights 1998 - 2007 Jim Bublitz also apply

//                 Generated by twine

// This file is part of PyKDE4.

// PyKDE4 is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.

// PyKDE4 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


class KLocalizedString
{
%TypeHeaderCode
#include <klocalizedstring.h>
%End


public:
    explicit                KLocalizedString ();
                            KLocalizedString (const KLocalizedString& rhs);
    QString                 toString () const;
    QString                 toString (const KLocale* locale) const;
    bool                    isEmpty () const;
//ig     KLocalizedString   subs (int a, int fieldWidth = 0, int base = 10, const QChar& fillChar = QLatin1Char(' ')) const;
//ig     KLocalizedString   subs (uint a, int fieldWidth = 0, int base = 10, const QChar& fillChar = QLatin1Char(' ')) const;
//ig     KLocalizedString   subs (long a, int fieldWidth = 0, int base = 10, const QChar& fillChar = QLatin1Char(' ')) const;
//ig     KLocalizedString   subs (ulong a, int fieldWidth = 0, int base = 10, const QChar& fillChar = QLatin1Char(' ')) const;
     KLocalizedString   subs (qlonglong a, int fieldWidth = 0, int base = 10, const QChar& fillChar = QLatin1Char(' ')) const;
//ig    KLocalizedString        subs (qulonglong a, int fieldWidth = 0, int base = 10, const QChar& fillChar = QLatin1Char(' ')) const;
//ig     KLocalizedString   subs (double a, int fieldWidth = 0, char format = 'g', int precision = -1, const QChar& fillChar = QLatin1Char(' ')) const;
    KLocalizedString        subs (QChar a, int fieldWidth = 0, const QChar& fillChar = QLatin1Char(' ')) const;
    KLocalizedString        subs (const QString& a, int fieldWidth = 0, const QChar& fillChar = QLatin1Char(' ')) const;
    KLocalizedString        inContext (const QString& key, const QString& text) const;
//ig     static void        notifyCatalogsUpdated (const QStringList& languages, const QList<KCatalogName>& catalogs);

private:
                            KLocalizedString (const char* ctxt, const char* msg, const char* plural);
};   // KLocalizedString

KLocalizedString        ki18n (const char* msg);
KLocalizedString        ki18nc (const char* ctxt, const char* msg);
KLocalizedString        ki18np (const char* singular, const char* plural);
KLocalizedString        ki18ncp (const char* ctxt, const char* singular, const char* plural);
QString                 tr2i18n (const char* message, const char* comment = 0);

//ig class I18nTypeCheck;

%ModuleCode
QString klocalizedstring_i18n_template(KLocalizedString base, PyObject *list,int *sipIsErr) {
    KLocalizedString result = base;    
    QString *arg;
    long long_arg;
    double double_arg;
    int iserr = 0;

    for (int i=0; i < PyTuple_Size(list); i++) {
        PyObject *pyarg = PyTuple_GET_ITEM (list, i);
        if (PyInt_Check(pyarg)) {
            long_arg = PyInt_AsLong(pyarg);
            if (long_arg==-1 && PyErr_Occurred()) {
                *sipIsErr = 1;
                return QString();
            }
            result = result.subs(long_arg);

        } else if (PyLong_Check(pyarg)) {
            long_arg = PyLong_AsLong(pyarg);
            if (long_arg==-1 && PyErr_Occurred()) {
                *sipIsErr = 1;
                return QString();
            }
            result = result.subs(long_arg);

        } else if (PyFloat_Check(pyarg)) {
            double_arg = PyFloat_AsDouble(pyarg);
            result = result.subs(double_arg);

        } else {
          int state = 0;
          arg = (QString *)sipForceConvertToType(pyarg, sipType_QString, NULL, SIP_NOT_NONE, &state, &iserr);
          if (iserr) {
              *sipIsErr = 1;
              return QString();
          }
  
          result = result.subs(*arg);
          sipReleaseType(arg,sipType_QString,state);
          arg = 0;
          }
    }

    return result.toString();
}
%End

//ig class I18nTypeCheck;

QString                 i18n (const char* text,...);
%MethodCode
    QString result = klocalizedstring_i18n_template(ki18n(a0),a1,&sipIsErr);
    if (!sipIsErr) {
        sipRes = new QString(result);
    }
%End

QString                 i18nc (const char* ctxt, const char* text,...);
%MethodCode
    QString result = klocalizedstring_i18n_template(ki18nc(a0,a1),a2,&sipIsErr);
    if (!sipIsErr) {
        sipRes = new QString(result);
    }
%End

QString                 i18np (const char*sing, const char*plur,...);
%MethodCode
    QString result = klocalizedstring_i18n_template(ki18np(a0,a1),a2,&sipIsErr);
    if (!sipIsErr) {
        sipRes = new QString(result);
    }
%End

QString                 i18ncp (const char *ctxt, const char*sing, const char*plur,...);
%MethodCode
    QString result = klocalizedstring_i18n_template(ki18ncp(a0,a1,a2),a3,&sipIsErr);
    if (!sipIsErr) {
        sipRes = new QString(result);
    }
%End

%ModuleHeaderCode
#include <klocalizedstring.h>
%End


