share_message_phrase_factory.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "chat_helpers/share_message_phrase_factory.h"
  8. #include "data/data_peer.h"
  9. #include "lang/lang_keys.h"
  10. #include "ui/text/text_utilities.h"
  11. namespace ChatHelpers {
  12. rpl::producer<TextWithEntities> ForwardedMessagePhrase(
  13. const ForwardedMessagePhraseArgs &args) {
  14. if (args.toCount <= 1) {
  15. Assert(args.to1);
  16. if (args.to1->isSelf()) {
  17. return (args.singleMessage
  18. ? tr::lng_share_message_to_saved_messages
  19. : tr::lng_share_messages_to_saved_messages)(
  20. Ui::Text::RichLangValue);
  21. } else {
  22. return (args.singleMessage
  23. ? tr::lng_share_message_to_chat
  24. : tr::lng_share_messages_to_chat)(
  25. lt_chat,
  26. rpl::single(TextWithEntities{ args.to1->name() }),
  27. Ui::Text::RichLangValue);
  28. }
  29. } else if ((args.toCount == 2) && (args.to1 && args.to2)) {
  30. return (args.singleMessage
  31. ? tr::lng_share_message_to_two_chats
  32. : tr::lng_share_messages_to_two_chats)(
  33. lt_user,
  34. rpl::single(TextWithEntities{ args.to1->name() }),
  35. lt_chat,
  36. rpl::single(TextWithEntities{ args.to2->name() }),
  37. Ui::Text::RichLangValue);
  38. } else {
  39. return (args.singleMessage
  40. ? tr::lng_share_message_to_many_chats
  41. : tr::lng_share_messages_to_many_chats)(
  42. lt_count,
  43. rpl::single(args.toCount) | tr::to_count(),
  44. Ui::Text::RichLangValue);
  45. }
  46. }
  47. } // namespace ChatHelpers