This file is indexed.

/usr/include/KF5/KI18n/klocalizedtranslator.h is in libkf5i18n-dev 5.44.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
/*
 * Copyright 2014  Martin Gräßlin <mgraesslin@kde.org>
 *
 * This library 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) version 3, or any
 * later version accepted by the membership of KDE e.V. (or its
 * successor approved by the membership of KDE e.V.), which shall
 * act as a proxy defined in Section 6 of version 3 of the license.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KLOCALIZEDTRANSLATOR_H
#define KLOCALIZEDTRANSLATOR_H

#include <ki18n_export.h>

#include <QtCore/QTranslator>

class KLocalizedTranslatorPrivate;

/**
 * @class KLocalizedTranslator klocalizedtranslator.h <KLocalizedTranslator>
 *
 * @brief A QTranslator using KLocalizedString for translations.
 *
 * This class allows to translate strings in Qt's translation system with KLocalizedString.
 * An example is the translation of a dynamically loaded user interface through QUILoader.
 *
 * To use this Translator install it in the QCoreApplication and provide the translation domain
 * to be used. The Translator can operate for multiple contexts, those needs to be specified.
 *
 * Example for translating a UI loaded through QUILoader:
 * @code
 * // create translator and install in QCoreApplication
 * KLocalizedTranslator *translator = new KLocalizedTranslator(this);
 * QCoreApplication::instance()->installTranslator(translator);
 * translator->setTranslationDomain(QStringLiteral("MyAppsDomain"));
 *
 * // create the QUILoader
 * QUiLoader *loader = new QUiLoader(this);
 * loader->setLanguageChangeEnabled(true);
 *
 * // load the UI
 * QFile uiFile(QStringLiteral("/path/to/userInterface.ui"));
 * uiFile.open(QFile::ReadOnly);
 * QWidget *loadedWidget = loader->load(&uiFile, this);
 * uiFile.close();
 *
 * // the object name of the loaded UI is the context in this case
 * translator->addContextToMonitor(loadedWidget->objectName());
 *
 * // send a LanguageChange event, this will re-translate using our translator
 * QEvent le(QEvent::LanguageChange);
 * QCoreApplication::sendEvent(loadedWidget, &le);
 * @endcode
 *
 * @since 5.0
 **/
class KI18N_EXPORT KLocalizedTranslator : public QTranslator
{
    Q_OBJECT
public:
    explicit KLocalizedTranslator(QObject *parent = nullptr);
    virtual ~KLocalizedTranslator();
    QString translate(const char *context, const char *sourceText, const char *disambiguation = nullptr, int n = -1) const Q_DECL_OVERRIDE;

    /**
     * Sets the @p translationDomain to be used.
     *
     * The translation domain is required. Without the translation domain any invocation of
     * translate() will be delegated to the base class.
     *
     * @param translationDomain The translation domain to be used.
     **/
    void setTranslationDomain(const QString &translationDomain);

    /**
     * Adds a @p context for which this Translator should be active.
     *
     * The Translator only translates texts with a context matching one of the monitored contexts.
     * If the context is not monitored, the translate() method delegates to the base class.
     *
     * @param context The context for which the Translator should be active
     *
     * @see removeContextToMonitor
     **/
    void addContextToMonitor(const QString &context);

    /**
     * Stop translating for the given @p context.
     *
     * @param context The context for which the Translator should no longer be active
     *
     * @see addContextToMonitor
     **/
    void removeContextToMonitor(const QString &context);

private:
    const QScopedPointer<KLocalizedTranslatorPrivate> d;
};

#endif //KLOCALIZEDTRANSLATOR_H