Check-in [1e322e20c7]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

SHA1 Hash:1e322e20c721cdbd81592cc7e27ebd169f33f55c
Date: 2012-09-26 01:04:48
User: BarryK
Comment:improve translation of .desktop file if langpack installed

Tags And Properties
Changes

Changes to woof-code/rootfs-skeleton/usr/local/petget/hacks-postinstall.sh

@@ -1,10 +1,10 @@
 #!/bin/sh
 #this is for hacks needed to fix a package, that might not have been done elsewhere.
 #called from /usr/local/petget/installpkg.sh
 #package that has just been installed is passed in on commandline.
-#120924 DejaVu font no good for non-Latin languages.
+#120924 DejaVu font no good for non-Latin languages. 120925 add korean.
 
 INSTALLEDPKG="$1" #ex: vlc_2.0.3-0ubuntu0.12.04.1_i386, without .deb
 
 case $INSTALLEDPKG in
  vlc-nox_*)
@@ -22,11 +22,11 @@
  jwm_theme_*)
   #120924 DejaVu font no good for non-Latin languages...
   #see also langpack_* pinstall.sh (template is in /usr/share/doc/langpack-template/pinstall.sh, read by momanager).
   LANGUSER="`grep '^LANG=' /etc/profile | cut -f 2 -d '=' | cut -f 1 -d ' '`"
   case $LANGUSER in
-   zh*|ja*) #chinese, japanese
+   zh*|ja*|ko*) #chinese, japanese, korean
     sed -i -e 's%DejaVu Sans%Sans%' /etc/xdg/templates/_root_*
     sed -i -e 's%DejaVu Sans%Sans%' /root/.jwm/themes/*-jwmrc
     sed -i -e 's%DejaVu Sans%Sans%' /root/.jwm/jwmrc-theme
    ;;
   esac
@@ -34,11 +34,11 @@
  openbox*)
   #120924 DejaVu font no good for non-Latin languages...
   #see also langpack_* pinstall.sh (template is in /usr/share/doc/langpack-template/pinstall.sh, read by momanager).
   LANGUSER="`grep '^LANG=' /etc/profile | cut -f 2 -d '=' | cut -f 1 -d ' '`"
   case $LANGUSER in
-   zh*|ja*) #chinese, japanese
+   zh*|ja*|ko*) #chinese, japanese, korean
     sed -i -e 's%DejaVu Sans%Sans%' /etc/xdg/openbox/*.xml
     sed -i -e 's%DejaVu Sans%Sans%' /root/.config/openbox/*.xml
    ;;
   esac
  ;;
@@ -45,11 +45,11 @@
  gtk_theme_*)
   #120924 DejaVu font no good for non-Latin languages...
   #see also langpack_* pinstall.sh (template is in /usr/share/doc/langpack-template/pinstall.sh, read by momanager).
   LANGUSER="`grep '^LANG=' /etc/profile | cut -f 2 -d '=' | cut -f 1 -d ' '`"
   case $LANGUSER in
-   zh*|ja*) #chinese, japanese
+   zh*|ja*|ko*) #chinese, japanese, korean
     GTKRCFILE="$(find /usr/share/themes -type f -name gtkrc | tr '\n' ' ')"
     for ONEGTKRC in $GTKRCFILE
     do
      sed -i -e 's%DejaVu Sans%Sans%' $ONEGTKRC
     done
@@ -59,11 +59,11 @@
  seamonkey*|firefox*)
   #120924 DejaVu font no good for non-Latin languages...
   #see also langpack_* pinstall.sh (template is in /usr/share/doc/langpack-template/pinstall.sh, read by momanager).
   LANGUSER="`grep '^LANG=' /etc/profile | cut -f 2 -d '=' | cut -f 1 -d ' '`"
   case $LANGUSER in
-   zh*|ja*) #chinese, japanese
+   zh*|ja*|ko*) #chinese, japanese, korean
     MOZFILE="$(find /root/.mozilla -type f -name prefs.js -o -name '*.css' | tr '\n' ' ')"
     for ONEMOZ in $MOZFILE
     do
      sed -i -e 's%DejaVu Sans%Sans%' $ONEMOZ
     done

Changes to woof-code/rootfs-skeleton/usr/local/petget/installpkg.sh

@@ -30,10 +30,11 @@
 #120523 may need to run gio-query-modules and/or glib-compile-schemas. (refer also rc.update and 3builddistro)
 #120628 fix Categories= assignment in .desktop files. see also 2createpackages in woof.
 #120818 Categories management improved. pkg db now has category[;subcategory] (see 0setup), xdg enhanced (see /etc/xdg and /usr/share/desktop-directories), and generic icons for all subcategories (see /usr/local/lib/X11/mini-icons).
 #120901 .desktop files, get rid of param on end of Exec, ex: Exec=gimp-2.8 %U
 #120907 post-install hacks.
+#120926 apply translation for .desktop file if langpack installed.
 
 #information from 'labrador', to expand a .pet directly to '/':
 #NAME="a52dec-0.7.4"
 #pet2tgz "${NAME}.pet"
 #tar -C / --transform 's/^\(\.\/\)\?'"$NAME"'//g' -zxf "${NAME}.tar.gz"
@@ -421,10 +422,53 @@
    fi
   fi
   #substitute a default icon...
   sed -i -e "$iPATTERN" $ONEDOT #note, ONEDOT is name of .desktop file.
  fi
+
+ #120926 if a langpack installed, it will have /usr/share/applications.in (see /usr/sbin/momanager, /usr/share/doc/langpack-template/pinstall.sh).
+ ABASEDESKTOP="`basename $ONEDOT`"
+ if [ -f /usr/share/applications.in/${ABASEDESKTOP} ];then
+  TARGETLANG="`echo -n $LANG_USER | cut -f 1 -d '_'`" #ex: de
+  tlPTN="^Name\[${TARGETLANG}\]"
+  if [ "$(grep "$tlPTN" /usr/share/applications/${ABASEDESKTOP})" = "" ];then
+   if [ "$(grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP})" != "" ];then
+    #aaargh, these accursed back-slashes! ....
+    INSERTALINE="`grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
+    sed -i -e "s%^Name=%${INSERTALINE}\\nName=%" /usr/share/applications/${ABASEDESKTOP}
+   fi
+  fi
+  #do same for Comment field...
+  tlPTN="^Comment\[${TARGETLANG}\]"
+  if [ "$(grep "$tlPTN" /usr/share/applications/${ABASEDESKTOP})" = "" ];then
+   if [ "$(grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP})" != "" ];then
+    #aaargh, these accursed back-slashes! ....
+    INSERTALINE="`grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
+    sed -i -e "s%^Comment=%${INSERTALINE}\\nComment=%" /usr/share/applications/${ABASEDESKTOP}
+   fi
+  fi
+  #well, i suppose need this too...
+  TARGETLANG="`echo -n $LANG_USER | cut -f 1 -d '.'`" #ex: de_DE
+  tlPTN="^Name\[${TARGETLANG}\]"
+  if [ "$(grep "$tlPTN" /usr/share/applications/${ABASEDESKTOP})" = "" ];then
+   if [ "$(grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP})" != "" ];then
+    #aaargh, these accursed back-slashes! ....
+    INSERTALINE="`grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
+    sed -i -e "s%^Name=%${INSERTALINE}\\nName=%" /usr/share/applications/${ABASEDESKTOP}
+   fi
+  fi
+  #do same for Comment field...
+  tlPTN="^Comment\[${TARGETLANG}\]"
+  if [ "$(grep "$tlPTN" /usr/share/applications/${ABASEDESKTOP})" = "" ];then
+   if [ "$(grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP})" != "" ];then
+    #aaargh, these accursed back-slashes! ....
+    INSERTALINE="`grep "$tlPTN" /usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
+    sed -i -e "s%^Comment=%${INSERTALINE}\\nComment=%" /usr/share/applications/${ABASEDESKTOP}
+   fi
+  fi
+ fi
+
 done
 
 #due to images at / in .pet and post-install script, .files may have some invalid entries...
 INSTFILES="`cat /root/.packages/${DLPKG_NAME}.files`"
 echo "$INSTFILES" |

Changes to woof-code/rootfs-skeleton/usr/share/doc/langpack-template/pinstall.sh

@@ -2,21 +2,22 @@
 #Barry Kauler, Feb. 2012. GPL3 (/usr/share/doc/legal)
 #this is the post-install script for a langpack PET created by /usr/sbin/momanager.
 #MoManager will replace the strings TARGETLANG and POSTINSTALLMSG.
 #120315 maybe have hunspell dictionaries in langpack.
 #120830 improved symlinks to hunspell dictionaries.
-#120924 DejaVu font no good for non-Latin languages.
+#120924 DejaVu font no good for non-Latin languages. 120925 add korean.
+#120926 translate Comment field in .desktop file. note: applications.in now handled in /usr/local/petget/installpkg.sh.
 
 echo "Post install script for TARGETLANG language pack"
 
 #if [ "$LANG" = "C" ];then #in case caller script did this.
  LANG="`grep '^LANG=' /etc/profile | cut -f 2 -d '=' | cut -f 1 -d ' '`"
  export LANG
 #fi
 LANG1="`echo -n $LANG | cut -f 1 -d '_'`"  #ex: de
 
-if [ -d usr/share/applications.in ];then
+if [ -d usr/share/applications.in ];then #refer: /usr/sbin/momanager
  for ADESKTOPFILE in `find usr/share/applications.in -mindepth 1 -maxdepth 1 -type f -name '*.desktop' | tr '\n' ' '`
  do
   ABASEDESKTOP="`basename $ADESKTOPFILE`"
   if [ -f usr/share/applications/${ABASEDESKTOP} ];then
    if [ "`grep '^Name\[TARGETLANG\]' usr/share/applications/${ABASEDESKTOP}`" = "" ];then
@@ -24,14 +25,23 @@
      #aaargh, these accursed back-slashes! ....
      INSERTALINE="`grep '^Name\[TARGETLANG\]' usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
      sed -i -e "s%^Name=%${INSERTALINE}\\nName=%" usr/share/applications/${ABASEDESKTOP}
     fi
    fi
+   #120926 do same for Comment field...
+   if [ "`grep '^Comment\[TARGETLANG\]' usr/share/applications/${ABASEDESKTOP}`" = "" ];then
+    if [ "`grep '^Comment\[TARGETLANG\]' usr/share/applications.in/${ABASEDESKTOP}`" != "" ];then
+     #aaargh, these accursed back-slashes! ....
+     INSERTALINE="`grep '^Comment\[TARGETLANG\]' usr/share/applications.in/${ABASEDESKTOP} | sed -e 's%\[%\\\\[%' -e 's%\]%\\\\]%'`"
+     sed -i -e "s%^Comment=%${INSERTALINE}\\nComment=%" usr/share/applications/${ABASEDESKTOP}
+    fi
+   fi
   fi
  done
  #rm -r -f usr/share/applications.in
  #...don't remove it. might be useful for ppm when install future packages.
+ #...120926 yes, applications.in now handled in /usr/local/petget/installpkgs.sh.
 fi
 
 if [ -d usr/share/desktop-directories.in ];then
  for ADESKTOPFILE in `find usr/share/desktop-directories.in -mindepth 1 -maxdepth 1 -type f -name '*.directory' | tr '\n' ' '`
  do
@@ -72,11 +82,11 @@
 
 #120924 DejaVu font no good for non-Latin languages...
 #see also similar code in /usr/local/petget/hacks-postinstall.sh.
 LANGPACKLANG=TARGETLANG
 case $LANGPACKLANG in
- zh*|ja*) #chinese, japanese
+ zh*|ja*|ko*) #chinese, japanese, korean
   sed -i -e 's%DejaVu Sans%Sans%' ./etc/xdg/templates/_root_*
   if [ -d ./root/.jwm ];then
    sed -i -e 's%DejaVu Sans%Sans%' ./root/.jwm/themes/*-jwmrc
    sed -i -e 's%DejaVu Sans%Sans%' ./root/.jwm/jwmrc-theme
   fi