mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 09:41:41 -05:00
Clear 'Find in Files' search by lang key results.
This commit is contained in:
parent
89fb121caf
commit
826d229c1a
2 changed files with 17 additions and 16 deletions
|
@ -279,22 +279,11 @@ inline constexpr phrase<" << tags.join(", ") << "> " << (isPlural ? entry.keyBas
|
|||
header_->newline();
|
||||
}
|
||||
|
||||
void Generator::writeSourceLangKeyConstants() {
|
||||
source_->newline();
|
||||
auto index = 0;
|
||||
for (auto &entry : langpack_.entries) {
|
||||
source_->stream() << "constexpr auto " << getFullKey(entry) << " = ushort(" << (index++) << ");\n";
|
||||
}
|
||||
source_->newline();
|
||||
}
|
||||
|
||||
bool Generator::writeSource() {
|
||||
source_ = std::make_unique<common::CppFile>(basePath_ + ".cpp", project_);
|
||||
|
||||
source_->include("lang/lang_keys.h").pushNamespace("Lang").pushNamespace();
|
||||
|
||||
writeSourceLangKeyConstants();
|
||||
|
||||
source_->stream() << "\
|
||||
QChar DefaultData[] = {";
|
||||
auto count = 0;
|
||||
|
@ -359,6 +348,19 @@ ushort GetKeyIndex(QLatin1String key) {\n\
|
|||
auto size = key.size();\n\
|
||||
auto data = key.data();\n";
|
||||
|
||||
auto index = 0;
|
||||
auto indices = std::map<QString, QString>();
|
||||
for (auto &entry : langpack_.entries) {
|
||||
indices.emplace(getFullKey(entry), QString::number(index++));
|
||||
}
|
||||
const auto indexOfKey = [&](const QString &full) {
|
||||
const auto i = indices.find(full);
|
||||
if (i == indices.end()) {
|
||||
return QString();
|
||||
}
|
||||
return i->second;
|
||||
};
|
||||
|
||||
auto taggedKeys = std::map<QString, QString>();
|
||||
auto keysSet = std::set<QString, std::greater<>>();
|
||||
for (auto &entry : langpack_.entries) {
|
||||
|
@ -379,7 +381,8 @@ ushort GetKeyIndex(QLatin1String key) {\n\
|
|||
|
||||
writeSetSearch(keysSet, [&](const QString &key) {
|
||||
auto it = taggedKeys.find(key);
|
||||
return (it != taggedKeys.end()) ? it->second : key;
|
||||
const auto name = (it != taggedKeys.end()) ? it->second : key;
|
||||
return indexOfKey(name);
|
||||
}, "kKeysCount");
|
||||
header_->popNamespace().newline();
|
||||
|
||||
|
@ -401,11 +404,11 @@ bool IsTagReplaced(ushort key, ushort tag) {\n\
|
|||
lastWrittenPluralEntry = entry.keyBase;
|
||||
for (auto i = 0; i != kPluralPartCount; ++i) {
|
||||
source_->stream() << "\
|
||||
case " << ComputePluralKey(entry.keyBase, i) << ":" << ((i + 1 == kPluralPartCount) ? " {" : "") << "\n";
|
||||
case " << indexOfKey(ComputePluralKey(entry.keyBase, i)) << ":" << ((i + 1 == kPluralPartCount) ? " {" : "") << "\n";
|
||||
}
|
||||
} else {
|
||||
source_->stream() << "\
|
||||
case " << getFullKey(entry) << ": {\n";
|
||||
case " << indexOfKey(getFullKey(entry)) << ": {\n";
|
||||
}
|
||||
source_->stream() << "\
|
||||
switch (tag) {\n";
|
||||
|
|
|
@ -37,8 +37,6 @@ private:
|
|||
void writeHeaderProducersInterface();
|
||||
void writeHeaderProducersInstances();
|
||||
|
||||
void writeSourceLangKeyConstants();
|
||||
|
||||
QString getFullKey(const LangPack::Entry &entry);
|
||||
|
||||
template <typename ComputeResult>
|
||||
|
|
Loading…
Add table
Reference in a new issue