diff --git a/platform/get_text_by_id.cpp b/platform/get_text_by_id.cpp index e86c1bea58..35730d3e0a 100644 --- a/platform/get_text_by_id.cpp +++ b/platform/get_text_by_id.cpp @@ -7,6 +7,7 @@ #include "3party/jansson/myjansson.hpp" +#include "std/algorithm.hpp" #include "std/target_os.hpp" namespace @@ -120,4 +121,15 @@ string GetTextById::operator()(string const & textId) const return string(); return textIt->second; } + +TTranslations GetTextById::GetAllSortedTranslations() const +{ + TTranslations all; + all.reserve(m_localeTexts.size()); + for (auto const & tr : m_localeTexts) + all.emplace_back(tr.first, tr.second); + using TValue = TTranslations::value_type; + sort(all.begin(), all.end(), [](TValue const & v1, TValue const & v2) { return v1.second < v2.second; }); + return all; +} } // namespace platform diff --git a/platform/get_text_by_id.hpp b/platform/get_text_by_id.hpp index 8a54a5e506..3daf102018 100644 --- a/platform/get_text_by_id.hpp +++ b/platform/get_text_by_id.hpp @@ -4,6 +4,7 @@ #include "std/unique_ptr.hpp" #include "std/unordered_map.hpp" #include "std/utility.hpp" +#include "std/vector.hpp" namespace platform { @@ -18,6 +19,7 @@ enum class TextSource class GetTextById; using TGetTextByIdPtr = unique_ptr; +using TTranslations = vector>; /// GetTextById represents text messages which are saved in textsDir /// in a specified locale. @@ -29,6 +31,7 @@ public: /// The boolean flag is set to false otherwise. string operator()(string const & textId) const; string GetLocale() const { return m_locale; } + TTranslations GetAllSortedTranslations() const; private: friend TGetTextByIdPtr GetTextByIdFactory(TextSource textSource, string const & localeName);