[Xfce4-commits] <thunar:master> Write localized name of a desktop file (bug #8783).

Nick Schermer noreply at xfce.org
Thu Nov 1 21:46:03 CET 2012


Updating branch refs/heads/master
         to 1567b995c746286cd736c705dee8afc266281e04 (commit)
       from 36b4a2778633d3ab8ba51fa951e92c81c3e75254 (commit)

commit 1567b995c746286cd736c705dee8afc266281e04
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Nov 1 21:43:59 2012 +0100

    Write localized name of a desktop file (bug #8783).

 thunar/thunar-file.c |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 0dd11cd..9f4fe72 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -1573,6 +1573,9 @@ thunar_file_rename (ThunarFile   *file,
   GFile                *previous_file;
   GFile                *renamed_file;
   gboolean              is_secure;
+  const gchar * const  *languages;
+  guint                 i;
+  gboolean              name_set = FALSE;
 
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
   _thunar_return_val_if_fail (g_utf8_validate (name, -1, NULL), FALSE);
@@ -1593,9 +1596,32 @@ thunar_file_rename (ThunarFile   *file,
           return FALSE;
         }
 
-      /* change the Name field of the desktop entry */
-      g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
-                             G_KEY_FILE_DESKTOP_KEY_NAME, name);
+      /* check if we can set the language name */
+      languages = g_get_language_names ();
+      if (languages != NULL)
+        {
+          for (i = 0; !name_set && languages[i] != NULL; i++)
+            {
+              /* skip C language */
+              if (g_ascii_strcasecmp (languages[i], "C") == 0)
+                continue;
+
+              /* change the translated Name field of the desktop entry */
+              g_key_file_set_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
+                                            G_KEY_FILE_DESKTOP_KEY_NAME,
+                                            languages[i], name);
+
+              /* done */
+              name_set = TRUE;
+            }
+        }
+
+      if (!name_set)
+        {
+          /* change the Name field of the desktop entry */
+          g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
+                                 G_KEY_FILE_DESKTOP_KEY_NAME, name);
+        }
 
       /* write the changes back to the file */
       if (thunar_g_file_write_key_file (file->gfile, key_file, cancellable, &err))


More information about the Xfce4-commits mailing list