Moved special text command for lang tags to td_lang.

This commit is contained in:
23rd 2022-01-07 00:40:02 +03:00 committed by John Preston
parent 74f9d0935b
commit 2af3770b29
3 changed files with 5 additions and 8 deletions

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
#include "ui/boxes/confirm_box.h"
#include "lang/lang_file_parser.h"
#include "lang/lang_tag.h" // kTextCommandLangTag.
#include "base/platform/base_platform_info.h"
#include "base/qthelp_regex.h"
@ -134,7 +135,7 @@ bool ValueParser::readTag() {
if (_currentTagReplacer.isEmpty()) {
_currentTagReplacer = QString(4, TextCommand);
_currentTagReplacer[1] = TextCommandLangTag;
_currentTagReplacer[1] = kTextCommandLangTag;
}
_currentTagReplacer[2] = QChar(0x0020 + _currentTagIndex);

View File

@ -869,19 +869,14 @@ auto ChoosePlural = ChoosePluralDefault;
int FindTagReplacementPosition(const QString &original, ushort tag) {
for (auto s = original.constData(), ch = s, e = ch + original.size(); ch != e;) {
if (*ch == TextCommand) {
if (ch + kTagReplacementSize <= e && (ch + 1)->unicode() == TextCommandLangTag && *(ch + 3) == TextCommand) {
if (ch + kTagReplacementSize <= e && (ch + 1)->unicode() == kTextCommandLangTag && *(ch + 3) == TextCommand) {
if ((ch + 2)->unicode() == 0x0020 + tag) {
return ch - s;
} else {
ch += kTagReplacementSize;
}
} else {
auto next = textSkipCommand(ch, e);
if (next == ch) {
++ch;
} else {
ch = next;
}
++ch;
}
} else {
++ch;

View File

@ -11,6 +11,7 @@ enum lngtag_count : int;
namespace Lang {
inline constexpr auto kTextCommandLangTag = 0x20;
constexpr auto kTagReplacementSize = 4;
int FindTagReplacementPosition(const QString &original, ushort tag);