diff --git a/Makefile b/Makefile index cb95882..e5cdb3d 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ WIN32_CC ?= $(WIN32_DEV_TOP)/mingw-4.7.2/bin/gcc PROTOC_C ?= protoc-c PKG_CONFIG ?= pkg-config +XGETTEXT ?= xgettext DIR_PERM = 0755 LIB_PERM = 0755 @@ -129,7 +130,7 @@ libdiscord3.dll: $(PURPLE_C_FILES) $(PURPLE_COMPAT_FILES) $(WIN32_CC) -O0 -g -ggdb -shared -o $@ $^ $(WIN32_PIDGIN3_CFLAGS) $(WIN32_PIDGIN3_LDFLAGS) po/purple-discord.pot: libdiscord.c - xgettext $^ -k_ --no-location -o $@ + $(XGETTEXT) $^ -k_ --no-location -o $@ po/%.po: po/purple-discord.pot msgmerge $@ po/purple-discord.pot > tmp-$* diff --git a/libdiscord.c b/libdiscord.c index 80c7204..a4a32ed 100644 --- a/libdiscord.c +++ b/libdiscord.c @@ -893,6 +893,9 @@ discord_create_fullname(DiscordUser *user) { g_return_val_if_fail(user != NULL, NULL); + if (user->discriminator == 0) { + return g_strdup(user->name); + } return g_strdup_printf("%s#%04d", user->name, user->discriminator); } @@ -925,7 +928,11 @@ discord_alloc_nickname(DiscordUser *user, DiscordGuild *guild, const gchar *sugg if (existing && existing->id != user->id) { /* Ambiguous; try with the discriminator */ - nick = g_strdup_printf("%s#%04d", base_nick, user->discriminator); + if (user->discriminator == 0) { + nick = g_strdup(base_nick); + } else { + nick = g_strdup_printf("%s#%04d", base_nick, user->discriminator); + } existing = g_hash_table_lookup(guild->nicknames_rev, nick); @@ -933,7 +940,11 @@ discord_alloc_nickname(DiscordUser *user, DiscordGuild *guild, const gchar *sugg /* Ambiguous; use the full tag */ g_free(nick); - nick = g_strdup_printf("%s (%s#%04d)", base_nick, user->name, user->discriminator); + if (user->discriminator == 0) { + nick = g_strdup_printf("%s (%s)", base_nick, user->name); + } else { + nick = g_strdup_printf("%s (%s#%04d)", base_nick, user->name, user->discriminator); + } } } @@ -1300,11 +1311,13 @@ discord_combine_username(const gchar *username, const gchar *discriminator) { g_return_val_if_fail(username != NULL, NULL); - if (discriminator == NULL) { - discriminator = "0000"; + gint disc_int = to_int(discriminator); + + if (disc_int == 0) { + return g_strdup(username); } - return g_strconcat(username, "#", discriminator, NULL); + return g_strdup_printf("%s#%04d", username, disc_int); } static gchar * @@ -5050,8 +5063,21 @@ discord_create_relationship(DiscordAccount *da, JsonObject *json) PurpleBuddy *buddy = purple_blist_find_buddy(da->account, merged_username); if (buddy == NULL) { + PurpleContact *buddy_contact = NULL; + PurpleGroup *buddy_group = discord_get_or_create_default_group(); + + // Special case: Check we're not migrating a friend from #0000 to just the username, so we can keep logs + if (user->discriminator == 0) { + gchar *old_username = g_strdup_printf("%s#0000", user->name); + PurpleBuddy *old_buddy = purple_blist_find_buddy(da->account, old_username); + if (old_buddy != NULL) { + buddy_contact = purple_buddy_get_contact(old_buddy); + buddy_group = purple_buddy_get_group(old_buddy); + } + g_free(old_username); + } buddy = purple_buddy_new(da->account, merged_username, user->name); - purple_blist_add_buddy(buddy, NULL, discord_get_or_create_default_group(), NULL); + purple_blist_add_buddy(buddy, buddy_contact, buddy_group, NULL); } discord_get_avatar(da, user, TRUE); diff --git a/po/purple-discord.pot b/po/purple-discord.pot index 7d669b7..20cb7b5 100644 --- a/po/purple-discord.pot +++ b/po/purple-discord.pot @@ -8,38 +8,68 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-01-09 21:03+1300\n" +"POT-Creation-Date: 2024-07-13 08:55+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" +msgid "Unknown user" +msgstr "" + +#, c-format +msgid "<message at %s>" +msgstr "" + #, c-format msgid "Connection error: %s." msgstr "" -msgid "people" +msgid "your" msgstr "" -msgid "You" +#, c-format +msgid "%s's" msgstr "" #, c-format -msgid "%s
%s reacted with %s" +msgid "%s removed the reaction \"%s\"%s" msgstr "" #, c-format -msgid "%s reacted with %s" +msgid "%s reacted with \"%s\"%s" +msgstr "" + +msgid "You" +msgstr "" + +msgid "person" +msgstr "" + +msgid "people" msgstr "" #, c-format -msgid "EDIT: %s" +msgid "%d %s%s" msgstr "" -msgid "Unknown user" +msgid "other " +msgstr "" + +#, c-format +msgid "and %s" +msgstr "" + +msgid ", " +msgstr "" + +msgid " " +msgstr "" + +#, c-format +msgid "EDIT: %s" msgstr "" #, c-format @@ -50,10 +80,52 @@ msgstr "" msgid "%s joined the guild!" msgstr "" -msgid "Someone" +#, c-format +msgid "%s started thread \"%s\" from message at %s" +msgstr "" + +#, c-format +msgid "%s started thread \"%s\"" +msgstr "" + +#, c-format +msgid "%d %s" msgstr "" -msgid "A new thread has been started!" +#, c-format +msgid "%u messages between " +msgstr "" + +#, c-format +msgid "%u messages at " +msgstr "" + +#, c-format +msgid "%sand %s were deleted" +msgstr "" + +#, c-format +msgid "Message at %s was deleted" +msgstr "" + +#, c-format +msgid "Your request to join the server %s has been approved!" +msgstr "" + +#, c-format +msgid "" +"Your request to join the server %s is currently pending. You will be " +"notified of any updates regarding your request." +msgstr "" + +#, c-format +msgid "" +"Your request to join the server %s was rejected. The reason given was:\n" +"\n" +"%s" +msgstr "" + +msgid "Server Join Request Update" msgstr "" msgid "Group DMs" @@ -107,15 +179,12 @@ msgstr "" msgid "Couldn't connect to gateway" msgstr "" -#, c-format -msgid "%s reacted with \"%s\" to %s's message: %s" -msgstr "" - -#, c-format -msgid "%s reacted with \"%s\" to your message: %s" +msgid "No pinned messages" msgstr "" -msgid "No pinned messages" +msgid "" +"Active Threads:\n" +"
Creation Time       | Last Message Time   | Name"
 msgstr ""
 
 msgid "Server Roles:"
@@ -253,12 +322,38 @@ msgstr ""
 msgid "Display custom emoji as inline images"
 msgstr ""
 
+msgid ""
+"Approximate max number of users to keep track of, per server (0 disables)"
+msgstr ""
+
+msgid "Fetch names for reactors to backlogged messages (can be spammy)"
+msgstr ""
+
+msgid "Fetch unread chat messages when account connects"
+msgstr ""
+
 msgid "Open chat when you are @mention'd"
 msgstr ""
 
+msgid "Indicate thread replies with this prefix: "
+msgstr ""
+
+msgid "Indicate thread parent messages with this prefix: "
+msgstr ""
+
 msgid "Auth token"
 msgstr ""
 
+msgid "Server Rules"
+msgstr ""
+
+#, c-format
+msgid "%s Member Screening"
+msgstr ""
+
+msgid "_OK"
+msgstr ""
+
 msgid "Join a server"
 msgstr ""
 
@@ -268,17 +363,114 @@ msgstr ""
 msgid "_Join"
 msgstr ""
 
+#, c-format
+msgid "Are you sure you want to leave the server %s?"
+msgstr ""
+
+msgid "Leaving Server!"
+msgstr ""
+
+msgid "Buddy List Abbreviation"
+msgstr ""
+
+msgid "Effective Guild Size"
+msgstr ""
+
+msgid "Large"
+msgstr ""
+
+msgid "Small"
+msgstr ""
+
+msgid "Leave this server"
+msgstr ""
+
+msgid "Manage discord servers"
+msgstr ""
+
+msgid "Edit per-server settings"
+msgstr ""
+
 msgid "Join a server..."
 msgstr ""
 
-msgid "nick :  Changes nickname on a server"
+msgid "Manage servers..."
 msgstr ""
 
-msgid "kick :  Remove someone from a server"
+msgid "Warning"
 msgstr ""
 
 msgid ""
-"ban :  Remove someone from a server and prevent them rejoining"
+"Fetching a channel's entire history can take a lot of memory and time to "
+"complete. Are you sure you want to continue?"
+msgstr ""
+
+msgid "Can't Cancel Upload"
+msgstr ""
+
+msgid "Cannot Cancel Discord Upload After Start"
+msgstr ""
+
+msgid "Connection Error"
+msgstr ""
+
+msgid "Malformed Response"
+msgstr ""
+
+msgid "Check Debug Logs For More Info"
+msgstr ""
+
+msgid "Couldn't load file"
+msgstr ""
+
+msgid "Maximum file size is 25MB"
+msgstr ""
+
+msgid "Guessing file type is:"
+msgstr ""
+
+msgid "DM Does Not Exist"
+msgstr ""
+
+msgid "DM does not exist"
+msgstr ""
+
+msgid "Try Sending A Regular Message First"
+msgstr ""
+
+msgid "Couldn't find room id"
+msgstr ""
+
+msgid "Check debug messages for more info"
+msgstr ""
+
+msgid ""
+"reply <timestamp> <message>:  Replies to the message at <"
+"timestamp> with <message>
Accepted timestamp formats: YYYY-MM-" +"DDthh:mm:ss, YYYY-MM-DDThh:mm:ss, hh:mm:ss" +msgstr "" + +msgid "" +"react <timestamp> <emoji>: Reacts to the message at <" +"timestamp> with <emoji>
Accepted timestamp formats: YYYY-MM-" +"DDthh:mm:ss, YYYY-MM-DDThh:mm:ss, hh:mm:ss" +msgstr "" + +msgid "" +"unreact <timestamp> <emoji>: Removes the reaction <emoji> " +"from the message at <timestamp>
Accepted timestamp formats: YYYY-" +"MM-DDthh:mm:ss, YYYY-MM-DDThh:mm:ss, hh:mm:ss" +msgstr "" + +msgid "nick <new nickname>: Changes nickname on a server" +msgstr "" + +msgid "kick <username>: Remove someone from a server" +msgstr "" + +msgid "" +"ban <username>: Remove someone from a server and prevent them " +"rejoining" msgstr "" msgid "leave: Leave the channel" @@ -293,6 +485,34 @@ msgstr "" msgid "roles: Display server roles" msgstr "" +msgid "" +"thread <timestamp> <message>: Sends message to thread
Accepted timestamp formats: YYYY-MM-DDthh:mm:ss, YYYY-MM-DDThh:mm:ss, hh:mm:" +"ss" +msgstr "" + +msgid "threads: Display active channel threads" +msgstr "" + +msgid "threadhistory <timestamp>: Retrieves full history of thread" +msgstr "" + +msgid "" +"thist <timestamp>: Retrieves full history of thread.
Alias of " +"threadhistory" +msgstr "" + +msgid "" +"grabhistory: Retrieves full history of channel. Intended for rules channels " +"and the like. Using this on old, highly active channels is not recommended" +msgstr "" + +msgid "" +"hist: Retrieves full history of channel. Intended for rules channels and " +"the like. Using this on old, highly active channels is not recommended.
Alias of grabhistory" +msgstr "" + msgid "mute : Mute someone in channel" msgstr ""