1 | /* This file is part of the KDE libraries |
2 | SPDX-FileCopyrightText: 2007 Chusslove Illich <caslav.ilic@gmx.net> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KTRANSCRIPT_P_H |
8 | #define KTRANSCRIPT_P_H |
9 | |
10 | #include <QHash> |
11 | #include <QList> |
12 | #include <QStringList> |
13 | #include <QVariant> |
14 | |
15 | /*! |
16 | * \internal |
17 | * (used by KLocalizedString) |
18 | * |
19 | * Class for supporting programmable translations |
20 | * |
21 | * KTranscript provides support for programmable translations. |
22 | * The class is abstract in order to facilitate dynamic loading. |
23 | */ |
24 | class KTranscript |
25 | { |
26 | public: |
27 | /*! |
28 | * Evaluates interpolation. |
29 | * |
30 | * \a argv list of interpolation tokens |
31 | * \a lang language of the translation |
32 | * \a ctry locale country |
33 | * \a msgctxt message context |
34 | * \a dynctxt dynamic context |
35 | * \a msgid original message |
36 | * \a subs substitutions for message placeholders |
37 | * \a vals values that were formatted to substitutions |
38 | * \a ftrans finalized ordinary translation |
39 | * \a mods scripting modules to load; the list is cleared after loading |
40 | * \a error set to the message detailing the problem, if the script |
41 | failed; set to empty otherwise |
42 | * \a fallback set to true if the script requested fallback to ordinary |
43 | translation; set to false otherwise |
44 | * Returns resolved interpolation if evaluation succeeded, |
45 | * empty string otherwise |
46 | */ |
47 | virtual QString eval(const QList<QVariant> &argv, |
48 | const QString &lang, |
49 | const QString &ctry, |
50 | const QString &msgctxt, |
51 | const QHash<QString, QString> &dynctxt, |
52 | const QString &msgid, |
53 | const QStringList &subs, |
54 | const QList<QVariant> &vals, |
55 | const QString &ftrans, |
56 | QList<QStringList> &mods, |
57 | QString &error, |
58 | bool &fallback) = 0; |
59 | |
60 | /*! |
61 | * Returns the list of calls to execute an all messages after the |
62 | * interpolations are done, as evaluations with no parameters. |
63 | * |
64 | * \a lang language of the translation |
65 | * Returns list of post calls |
66 | */ |
67 | virtual QStringList postCalls(const QString &lang) = 0; |
68 | |
69 | /*! |
70 | * Destructor. |
71 | */ |
72 | virtual ~KTranscript() |
73 | { |
74 | } |
75 | }; |
76 | |
77 | #ifdef KTRANSCRIPT_TESTBUILD |
78 | KTranscript *autotestCreateKTranscriptImp(); |
79 | void autotestDestroyKTranscriptImp(); |
80 | #endif |
81 | |
82 | #endif |
83 | |