2017-04-13 08:45:58 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-04-13 08:45:58 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-04-13 08:45:58 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-05-20 12:06:34 +00:00
|
|
|
enum lngtag_count : int;
|
|
|
|
|
2017-04-13 08:45:58 +00:00
|
|
|
namespace Lang {
|
|
|
|
|
2017-06-20 16:03:18 +00:00
|
|
|
constexpr auto kTagReplacementSize = 4;
|
|
|
|
|
|
|
|
int FindTagReplacementPosition(const QString &original, ushort tag);
|
|
|
|
|
2019-05-20 12:06:34 +00:00
|
|
|
struct ShortenedCount {
|
|
|
|
int64 number = 0;
|
|
|
|
QString string;
|
2019-05-03 13:12:23 +00:00
|
|
|
};
|
2019-05-20 12:06:34 +00:00
|
|
|
ShortenedCount FormatCountToShort(int64 number);
|
2019-05-03 13:12:23 +00:00
|
|
|
|
2017-06-20 16:03:18 +00:00
|
|
|
struct PluralResult {
|
2019-06-16 13:08:15 +00:00
|
|
|
int keyShift = 0;
|
2017-06-20 16:03:18 +00:00
|
|
|
QString replacement;
|
|
|
|
};
|
2019-05-03 13:12:23 +00:00
|
|
|
PluralResult Plural(
|
|
|
|
ushort keyBase,
|
|
|
|
float64 value,
|
2019-05-20 12:06:34 +00:00
|
|
|
lngtag_count type);
|
2017-06-02 11:46:02 +00:00
|
|
|
void UpdatePluralRules(const QString &languageId);
|
2017-04-13 08:45:58 +00:00
|
|
|
|
2017-06-20 16:03:18 +00:00
|
|
|
template <typename ResultString>
|
|
|
|
struct StartReplacements;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct StartReplacements<QString> {
|
|
|
|
static inline QString Call(QString &&langString) {
|
|
|
|
return std::move(langString);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename ResultString>
|
|
|
|
struct ReplaceTag;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ReplaceTag<QString> {
|
|
|
|
static inline QString Call(QString &&original, ushort tag, const QString &replacement) {
|
|
|
|
auto replacementPosition = FindTagReplacementPosition(original, tag);
|
|
|
|
if (replacementPosition < 0) {
|
|
|
|
return std::move(original);
|
|
|
|
}
|
|
|
|
return Replace(std::move(original), replacement, replacementPosition);
|
|
|
|
}
|
|
|
|
static QString Replace(QString &&original, const QString &replacement, int start);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-04-13 08:45:58 +00:00
|
|
|
} // namespace Lang
|