KCoreAddons

kjsonutils.h
1/*
2 SPDX-FileCopyrightText: 2014 Alex Richardson <arichardson.kde@gmail.com>
3 SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KJSONUTILS_H
9#define KJSONUTILS_H
10
11#include "kcoreaddons_export.h"
12
13#include <QJsonValue>
14
15class QJsonObject;
16class QString;
17
18namespace KJsonUtils
19{
20/**
21 * Reads a value from @p jo but unlike QJsonObject::value() it allows different entries for each locale
22 * This is done by appending the locale identifier in brackets to the key (e.g. "[de_DE]" or "[es]")
23 * When looking for a key "foo" with German (Germany) locale we will first attempt to read "foo[de_DE]",
24 * if that does not exist "foo[de]", finally falling back to "foo" if that also doesn't exist.
25 * @return the translated value for @p key from @p jo or @p defaultValue if @p key was not found
26 * @since 5.88
27 */
28KCOREADDONS_EXPORT QJsonValue readTranslatedValue(const QJsonObject &jo, const QString &key, const QJsonValue &defaultValue = QJsonValue());
29
30/**
31 * @return the translated value of @p key from @p jo as a string or @p defaultValue if @p key was not found
32 * or the value for @p key is not of type string
33 * @see KPluginMetaData::readTranslatedValue(const QJsonObject &jo, const QString &key)
34 * @since 5.88
35 */
36KCOREADDONS_EXPORT QString readTranslatedString(const QJsonObject &jo, const QString &key, const QString &defaultValue = QString());
37}
38
39#endif // KJSONUTILS_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.