Skip to content

Commit

Permalink
Improve export phrases.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 24, 2018
1 parent 9d66f9c commit 914e043
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 84 deletions.
12 changes: 6 additions & 6 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_settings_calls_privacy" = "Phone calls privacy";
"lng_settings_groups_invite_privacy" = "Group invite settings";
"lng_settings_show_sessions" = "Show all sessions";
"lng_settings_export_data" = "Export all my data";
"lng_settings_export_data" = "Export Telegram data";
"lng_settings_self_destruct" = "Account self-destruct settings";
"lng_settings_change_phone" = "Change phone number";

Expand Down Expand Up @@ -1656,10 +1656,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL

"lng_export_title" = "Export Personal Data";
"lng_export_progress_title" = "Exporting personal data";
"lng_export_option_info" = "Personal information";
"lng_export_option_info_about" = "Your chosen screen name, username and profile pictures are public and available to everyone. You don't have to supply your real name.";
"lng_export_option_info" = "Account information";
"lng_export_option_info_about" = "Your chosen screen name, username, phone number and profile pictures.";
"lng_export_option_contacts" = "Contacts list";
"lng_export_option_contacts_about" = "To let you connect with friends across all your devices, your contacts are continuosly synced with Telegram. You can disable syncing or delete your stored contacts in Settings > Privacy & Security.";
"lng_export_option_contacts_about" = "If you allow access, contacts are continuously synced with Telegram. You can adjust this in Settings > Privacy & Security on mobile devices.";
"lng_export_option_sessions" = "Sessions list";
"lng_export_option_sessions_about" = "We store this to display your connected devices in Settings > Privacy & Security > Active Sessions. Terminating a session removes this data from Telegram servers.";
"lng_export_header_chats" = "Chat export settings";
Expand All @@ -1685,7 +1685,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_export_option_json" = "Machine-readable JSON";
"lng_export_start" = "Export";
"lng_export_state_initializing" = "Initializing...";
"lng_export_state_userpics" = "Personal photos";
"lng_export_state_userpics" = "Profile pictures";
"lng_export_state_chats_list" = "Processing chats...";
"lng_export_state_chats" = "Chats";
"lng_export_state_progress" = "{count} / {total}";
Expand All @@ -1695,7 +1695,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_export_state_video_message" = "Round video message";
"lng_export_state_sticker" = "Sticker";
"lng_export_state_gif" = "Animated GIF";
"lng_export_progress" = "Note: You can close this window, but please don't quit Telegram while the export is running.";
"lng_export_progress" = "You can close this window now. Please don't quit Telegram until the data export is completed.";
"lng_export_stop" = "Stop";
"lng_export_sure_stop" = "Are you sure you want to stop exporting your data?\n\nIf you do, you'll need to start over.";
"lng_export_about_done" = "Your data was successfully exported.";
Expand Down
51 changes: 42 additions & 9 deletions Telegram/SourceFiles/export/data/export_data_about.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,33 @@ For license and copyright information please follow this link:
namespace Export {
namespace Data {

inline Utf8String AboutPersonalInfo() {
return "Your chosen screen name, username and profile pictures "
"are public and available to everyone. "
"You don't have to supply your real name.";
inline Utf8String AboutContacts() {
return "If you allow access, your contacts are continuously synced "
"with Telegram. Thanks to this, you can easily switch to Telegram "
"without losing your existing social graph "
"\xE2\x80\x93 and connect with friends across all your devices. "
"We use data about your contacts to let you know "
"when they join Telegram. We also use it to make sure "
"that you see the names you have in your phone book "
"instead of the screen names people choose for themselves.\n\n"
"You can disable contacts syncing or delete your stored contacts "
"in Settings > Privacy & Security on Telegram's mobile apps.";
}

inline Utf8String AboutContacts() {
return "To let you connect with friends across all your devices, "
"your contacts are continuosly synced with Telegram. "
"You can disable syncing or delete your stored contacts "
"in Settings > Privacy & Security.";
inline Utf8String AboutFrequent() {
return "This rating shows which people "
"you are likelier to message frequently. "
"Telegram uses this data to populate the 'People' box at the top "
"of the Search section. The rating is also calculated "
"for inline bots so that the app can suggest you "
"the bots you are most likely to use in the attachment menu "
"(or when you start a new message with \"@\").\n\n"
"To delete this data, go to Settings > Privacy & Security and "
"disable 'Suggest Frequent Contacts' "
"(requires Telegram for iOS v.4.8.3 "
"or Telegram for Android v.4.8.10 or higher). "
"See this page for more information: "
"https://telegram.org/faq/data-export";
}

inline Utf8String AboutSessions() {
Expand All @@ -31,5 +47,22 @@ inline Utf8String AboutSessions() {
"Terminating a session removes this data from Telegram servers.";
}

inline Utf8String AboutWebSessions() {
return "We store this to display you the websites "
"where you used Telegram to log in "
"in Settings > Privacy & Security > Active Sessions. "
"Disconnecting a website removes this data from Telegram servers.";
}

inline Utf8String AboutChats() {
return "This page lists all chats from this export "
"and where to look for their data.";
}

inline Utf8String AboutLeftChats() {
return "This page lists all supergroups and channels from this export "
"that you've left and where to look for their data.";
}

} // namespace Data
} // namespace Export
34 changes: 17 additions & 17 deletions Telegram/SourceFiles/export/data/export_data_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,21 @@ QString ComputeDocumentName(
const auto pattern = patterns.isEmpty() ? QString() : patterns.front();
if (data.isVoiceMessage) {
const auto isMP3 = hasMimeType(qstr("audio/mp3"));
return qsl("Audio_")
return qsl("audio_")
+ QString::number(++context.audios)
+ (isMP3 ? qsl(".mp3") : qsl(".ogg"));
} else if (data.isVideoFile) {
const auto extension = pattern.isEmpty()
? qsl(".mov")
: QString(pattern).replace('*', QString());
return qsl("Video_")
return qsl("video_")
+ QString::number(++context.videos)
+ extension;
} else {
const auto extension = pattern.isEmpty()
? qsl(".unknown")
: QString(pattern).replace('*', QString());
return qsl("File_")
return qsl("file_")
+ QString::number(++context.files)
+ extension;
}
Expand Down Expand Up @@ -326,17 +326,17 @@ QString CleanDocumentName(QString name) {

QString DocumentFolder(const Document &data) {
if (data.isVideoFile) {
return "VideoFiles";
return "video_files";
} else if (data.isAnimated) {
return "AnimatedGIFs";
return "animations";
} else if (data.isSticker) {
return "Stickers";
return "stickers";
} else if (data.isVoiceMessage) {
return "VoiceMessages";
return "voice_messages";
} else if (data.isVideoMessage) {
return "RoundVideoMessages";
return "round_video_messages";
}
return "Files";
return "files";
}

Document ParseDocument(
Expand Down Expand Up @@ -413,8 +413,8 @@ UserpicsSlice ParseUserpicsSlice(
auto result = UserpicsSlice();
result.list.reserve(list.size());
for (const auto &photo : list) {
const auto suggestedPath = "PersonalPhotos/"
"Photo_" + QString::number(++baseIndex) + ".jpg";
const auto suggestedPath = "profile_pictures/"
"photo_" + QString::number(++baseIndex) + ".jpg";
result.list.push_back(ParsePhoto(photo, suggestedPath));
}
return result;
Expand Down Expand Up @@ -645,8 +645,8 @@ Media ParseMedia(
result.content = data.has_photo()
? ParsePhoto(
data.vphoto,
folder + "Photos/"
"Photo_" + QString::number(++context.photos) + ".jpg")
folder + "photos/"
"photo_" + QString::number(++context.photos) + ".jpg")
: Photo();
if (data.has_ttl_seconds()) {
result.ttl = data.vttl_seconds.v;
Expand Down Expand Up @@ -700,8 +700,8 @@ ServiceAction ParseServiceAction(
auto content = ActionChatEditPhoto();
content.photo = ParsePhoto(
data.vphoto,
mediaFolder + "Photos/"
"Photo_" + QString::number(++context.photos) + ".jpg");
mediaFolder + "photos/"
"photo_" + QString::number(++context.photos) + ".jpg");
result.content = content;
}, [&](const MTPDmessageActionChatDeletePhoto &data) {
result.content = ActionChatDeletePhoto();
Expand Down Expand Up @@ -1190,7 +1190,7 @@ void FinalizeDialogsInfo(DialogsInfo &info, const Settings &settings) {
auto index = 0;
for (auto &dialog : list) {
const auto number = Data::NumberToString(++index, digits, '0');
dialog.relativePath = "Chats/chat_" + number + '/';
dialog.relativePath = "chats/chat_" + number + '/';

using DialogType = DialogInfo::Type;
using Type = Settings::Type;
Expand Down Expand Up @@ -1219,7 +1219,7 @@ void FinalizeLeftChannelsInfo(DialogsInfo &info, const Settings &settings) {
auto index = 0;
for (auto &dialog : list) {
const auto number = Data::NumberToString(++index, digits, '0');
dialog.relativePath = "Chats/left_" + number + '/';
dialog.relativePath = "chats/left_" + number + '/';
dialog.onlyMyMessages = true;
}
}
Expand Down
10 changes: 7 additions & 3 deletions Telegram/SourceFiles/export/output/export_output_abstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Stats AbstractWriter::produceTestExample(const QString &path) {
result.id = counter();
result.image.width = 512;
result.image.height = 512;
result.image.file.relativePath = "Files/Photo_"
result.image.file.relativePath = "files/photo_"
+ QString::number(++index)
+ ".jpg";
return result;
Expand Down Expand Up @@ -439,7 +439,9 @@ Stats AbstractWriter::produceTestExample(const QString &path) {
dialogBot.name = peerBot.name();
dialogBot.onlyMyMessages = false;
dialogBot.peerId = peerBot.id();
dialogBot.relativePath = "Chats/C_" + QString::number(counter()) + '/';
dialogBot.relativePath = "chats/chat_"
+ QString::number(counter())
+ '/';
dialogBot.splits.push_back(0);
dialogBot.splits.push_back(1);
dialogBot.topMessageDate = sliceBot2.list.back().date;
Expand All @@ -451,7 +453,9 @@ Stats AbstractWriter::produceTestExample(const QString &path) {
dialogChat.name = peerChat.name();
dialogChat.onlyMyMessages = true;
dialogChat.peerId = peerChat.id();
dialogChat.relativePath = "Chats/C_" + QString::number(counter()) + '/';
dialogChat.relativePath = "chats/chat_"
+ QString::number(counter())
+ '/';
dialogChat.splits.push_back(0);
dialogChat.splits.push_back(1);
dialogChat.topMessageDate = sliceChat2.list.back().date;
Expand Down
62 changes: 43 additions & 19 deletions Telegram/SourceFiles/export/output/export_output_html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,12 @@ QByteArray SerializeMessage(
: SerializeString(name + ' ');
switch (file.skipReason) {
case SkipReason::Unavailable: return pre + "(file unavailable)";
case SkipReason::FileSize: return pre + "(file too large)";
case SkipReason::FileType: return pre + "(file skipped)";
case SkipReason::FileSize:
return pre + "(" + label + " exceeds maximum size. "
"Change data exporting settings to download.)";
case SkipReason::FileType:
return pre + "(" + label + " not included. "
"Change data exporting settings to download.)";
case SkipReason::None: return SerializeLink(
FormatFilePath(file),
relativePath(file.relativePath));
Expand Down Expand Up @@ -307,10 +311,10 @@ QByteArray SerializeMessage(
push("Title", data.title);
}, [&](const ActionChatMigrateTo &data) {
pushActor();
pushAction("Migrate this group to supergroup");
pushAction("Convert this group to supergroup");
}, [&](const ActionChannelMigrateFrom &data) {
pushActor();
pushAction("Migrate this supergroup from group");
pushAction("Basic group converted to supergroup");
push("Title", data.title);
}, [&](const ActionPinMessage &data) {
pushActor();
Expand Down Expand Up @@ -669,8 +673,6 @@ Result HtmlWriter::writePersonal(const Data::PersonalInfo &data) {
{ "Bio", SerializeString(data.bio) },
})
+ kLineBreak
+ SerializeString(Data::AboutPersonalInfo())
+ kLineBreak
+ kLineBreak;
return _summary->writeBlock(serialized);
}
Expand All @@ -683,11 +685,11 @@ Result HtmlWriter::writeUserpicsStart(const Data::UserpicsInfo &data) {
if (!_userpicsCount) {
return Result::Success();
}
const auto filename = "personal_photos.html";
const auto filename = "profile_pictures.html";
_userpics = fileWithRelativePath(filename);

const auto serialized = SerializeLink(
"Personal photos "
"Profile pictures "
"(" + Data::NumberToString(_userpicsCount) + ")",
_summary->relativePath(filename))
+ kLineBreak
Expand All @@ -712,8 +714,12 @@ Result HtmlWriter::writeUserpicsSlice(const Data::UserpicsSlice &data) {
const auto path = [&]() -> Data::Utf8String {
switch (file.skipReason) {
case SkipReason::Unavailable: return "(file unavailable)";
case SkipReason::FileSize: return "(file too large)";
case SkipReason::FileType: return "(file skipped)";
case SkipReason::FileSize:
return "(Photo exceeds maximum size. "
"Change data exporting settings to download.)";
case SkipReason::FileType:
return "(Photo not included. "
"Change data exporting settings to download.)";
case SkipReason::None: return SerializeLink(
FormatFilePath(file),
_userpics->relativePath(file.relativePath));
Expand Down Expand Up @@ -775,7 +781,7 @@ Result HtmlWriter::writeSavedContacts(const Data::ContactsList &data) {
Data::FormatPhoneNumber(contact.phoneNumber))
},
{
"Date",
"Added",
SerializeString(Data::FormatDateTime(contact.date))
}
}));
Expand Down Expand Up @@ -867,10 +873,13 @@ Result HtmlWriter::writeFrequentContacts(const Data::ContactsList &data) {
}));
}
};
writeList(data.correspondents, "Correspondents");
writeList(data.correspondents, "People");
writeList(data.inlineBots, "Inline bots");
writeList(data.phoneCalls, "Calls");
const auto full = JoinList(kLineBreak, list);
const auto full = SerializeString(Data::AboutFrequent())
+ kLineBreak
+ kLineBreak
+ JoinList(kLineBreak, list);
if (const auto result = file->writeBlock(full); !result) {
return result;
} else if (const auto closed = file->close(); !closed) {
Expand Down Expand Up @@ -991,7 +1000,10 @@ Result HtmlWriter::writeWebSessions(const Data::SessionsList &data) {
},
}));
}
const auto full = JoinList(kLineBreak, list);
const auto full = SerializeString(Data::AboutWebSessions())
+ kLineBreak
+ kLineBreak
+ JoinList(kLineBreak, list);
if (const auto result = file->writeBlock(full); !result) {
return result;
} else if (const auto closed = file->close(); !closed) {
Expand All @@ -1008,7 +1020,11 @@ Result HtmlWriter::writeWebSessions(const Data::SessionsList &data) {
}

Result HtmlWriter::writeDialogsStart(const Data::DialogsInfo &data) {
return writeChatsStart(data, "Chats", "chats.html");
return writeChatsStart(
data,
"Chats",
Data::AboutChats(),
"chats.html");
}

Result HtmlWriter::writeDialogStart(const Data::DialogInfo &data) {
Expand All @@ -1028,7 +1044,11 @@ Result HtmlWriter::writeDialogsEnd() {
}

Result HtmlWriter::writeLeftChannelsStart(const Data::DialogsInfo &data) {
return writeChatsStart(data, "Left chats", "left_chats.html");
return writeChatsStart(
data,
"Left chats",
Data::AboutLeftChats(),
"left_chats.html");
}

Result HtmlWriter::writeLeftChannelStart(const Data::DialogInfo &data) {
Expand All @@ -1050,6 +1070,7 @@ Result HtmlWriter::writeLeftChannelsEnd() {
Result HtmlWriter::writeChatsStart(
const Data::DialogsInfo &data,
const QByteArray &listName,
const QByteArray &about,
const QString &fileName) {
Expects(_summary != nullptr);
Expects(_chats == nullptr);
Expand All @@ -1062,6 +1083,11 @@ Result HtmlWriter::writeChatsStart(
_dialogIndex = 0;
_dialogsCount = data.list.size();

const auto block = SerializeString(about) + kLineBreak;
if (const auto result = _chats->writeBlock(block); !result) {
return result;
}

const auto header = SerializeLink(
listName + " "
"(" + Data::NumberToString(data.list.size()) + ")",
Expand Down Expand Up @@ -1097,9 +1123,7 @@ Result HtmlWriter::writeChatSlice(const Data::MessagesSlice &data) {
data.peers,
_settings.internalLinksDomain));
}
const auto full = _chat->empty()
? JoinList(kLineBreak, list)
: kLineBreak + JoinList(kLineBreak, list);
const auto full = kLineBreak + JoinList(kLineBreak, list);
return _chat->writeBlock(full);
}

Expand Down
Loading

0 comments on commit 914e043

Please sign in to comment.