2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Use tr:: instead of Lang::Viewer.

This commit is contained in:
John Preston
2019-06-18 14:16:43 +02:00
parent f35085800a
commit 7af0dd105e
43 changed files with 483 additions and 511 deletions

View File

@@ -780,18 +780,21 @@ Instance &Current() {
return Core::App().langpack();
}
namespace details {
QString Current(LangKey key) {
return Current().getValue(key);
return Lang::Current().getValue(key);
}
rpl::producer<QString> Viewer(LangKey key) {
return rpl::single(
Current().getValue(key)
Lang::Current().getValue(key)
) | then(base::ObservableViewer(
Current().updated()
Lang::Current().updated()
) | rpl::map([=] {
return Current().getValue(key);
return Lang::Current().getValue(key);
}));
}
} // namespace details
} // namespace Lang

View File

@@ -56,9 +56,6 @@ Language DefaultLanguage();
class Instance;
Instance &Current();
QString Current(LangKey key);
rpl::producer<QString> Viewer(LangKey key);
enum class Pack {
None,
Current,
@@ -162,4 +159,10 @@ private:
};
namespace details {
QString Current(LangKey key);
rpl::producer<QString> Viewer(LangKey key);
} // namespace details
} // namespace Lang

View File

@@ -13,14 +13,13 @@ enum LangKey : int;
enum lngtag_count : int;
namespace Lang {
QString Current(LangKey key);
rpl::producer<QString> Viewer(LangKey key);
namespace details {
inline constexpr auto kPluralCount = 6;
QString Current(LangKey key);
rpl::producer<QString> Viewer(LangKey key);
template <typename Tag> struct TagValue;
template <int Index, typename Type, typename Tuple>
@@ -90,7 +89,9 @@ struct Producer {
typename T = decltype(std::declval<P>()(QString())),
typename ...Values>
static T Current(LangKey base, P p, const Values &...values) {
return ReplaceUnwrap<Tags...>::template Call(p(Lang::Current(base)), values...);
return ReplaceUnwrap<Tags...>::template Call(
p(Lang::details::Current(base)),
values...);
}
};
@@ -107,7 +108,7 @@ struct Producer<> {
typename P,
typename T = decltype(std::declval<P>()(QString()))>
static T Current(LangKey base, P p) {
return p(Lang::Current(base));
return p(Lang::details::Current(base));
}
};
@@ -169,7 +170,7 @@ struct Producer<lngtag_count, Tags...> {
auto plural = Plural(base, count, type);
return ReplaceUnwrap<Tags...>::template Call(
ReplaceTag<T>::Call(
p(Lang::Current(LangKey(base + plural.keyShift))),
p(Lang::details::Current(LangKey(base + plural.keyShift))),
type,
StartReplacements<T>::Call(
std::move(plural.replacement))),