changeset 29949:0d42077e36cf

Automatically select the translation corresponding to the installer language. Fixes #11882
author Daniel Atallah <daniel.atallah@gmail.com>
date Sat, 15 May 2010 03:24:24 +0000
parents 2aaa31c7046f
children e8b781c23fb6
files pidgin/win32/nsis/pidgin-installer.nsi
diffstat 1 files changed, 125 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/win32/nsis/pidgin-installer.nsi	Fri May 14 19:35:19 2010 +0000
+++ b/pidgin/win32/nsis/pidgin-installer.nsi	Sat May 15 03:24:24 2010 +0000
@@ -10,7 +10,6 @@
 Var name
 Var ISSILENT
 Var STARTUP_RUN_KEY
-Var SPELLCHECK_SEL
 
 ;--------------------------------
 ;Configuration
@@ -595,7 +594,7 @@
     DeleteRegValue HKCU "${STARTUP_RUN_KEY}" "Pidgin"
     DeleteRegValue HKLM "${STARTUP_RUN_KEY}" "Pidgin"
     ; Remove Language preference info
-    DeleteRegValue HKCU "${PIDGIN_REG_KEY}" "Installer Language"
+    DeleteRegValue HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
 
     ; Remove any URI handlers
     ; I can't think of an easy way to maintain a list in a single place
@@ -1109,18 +1108,17 @@
   Call RunCheck
 
   StrCpy $name "Pidgin ${PIDGIN_VERSION}"
-  StrCpy $SPELLCHECK_SEL ""
 
   ;Try to copy the old Gaim installer Lang Reg. key
   ;(remove it after we're done to prevent this being done more than once)
   ClearErrors
-  ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "Installer Language"
+  ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
   IfErrors 0 +5
   ClearErrors
-  ReadRegStr $R0 HKCU "${OLD_GAIM_REG_KEY}" "Installer Language"
+  ReadRegStr $R0 HKCU "${OLD_GAIM_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
   IfErrors +3
-  DeleteRegValue HKCU "${OLD_GAIM_REG_KEY}" "Installer Language"
-  WriteRegStr HKCU "${PIDGIN_REG_KEY}" "Installer Language" "$R0"
+  DeleteRegValue HKCU "${OLD_GAIM_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
+  WriteRegStr HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" "$R0"
 
   ${MementoSectionRestore}
 
@@ -1130,7 +1128,7 @@
   ;Preselect the "shortcuts" checkboxes according to the previous installation
   ClearErrors
   ;Make sure that there was a previous installation
-  ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "Installer Language"
+  ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
   IfErrors done_preselecting_shortcuts
     ;Does the Desktop shortcut exist?
     GetFileTime "$DESKTOP\Pidgin.lnk" $R0 $R0
@@ -1222,11 +1220,14 @@
     StrCpy $INSTDIR "$R2\Pidgin"
 
   instdir_done:
+;LogSet on
+
+  ; Try to select a translation and a dictionary for the currently selected Language
+  Call SelectTranslationForCurrentLanguage
 
   ;Mark the dictionaries that are already installed as readonly
   Call SelectAndDisableInstalledDictionaries
 
-;LogSet on
   Pop $R3
   Pop $R2
   Pop $R1
@@ -1276,13 +1277,124 @@
   Pop $R0
 FunctionEnd
 
+; Convert the current $LANGUAGE to a language code that we can use for translation mo selection
+; If there's a better way to do this, I'd love to know it
+Function SelectTranslationForCurrentLanguage
+
+  StrCmp "$LANGUAGE" "1078" 0 sq
+  !insertmacro SelectSection ${SecLang_af}
+  Goto done
+  sq: StrCmp "$LANGUAGE" "1052" 0 ar
+  !insertmacro SelectSection ${SecLang_sq}
+  Goto done
+  ar: StrCmp "$LANGUAGE" "1025" 0 eu
+  !insertmacro SelectSection ${SecLang_ar}
+  Goto done
+  eu: StrCmp "$LANGUAGE" "1069" 0 bg
+  !insertmacro SelectSection ${SecLang_eu}
+  Goto done
+  bg: StrCmp "$LANGUAGE" "1026" 0 ca 
+  !insertmacro SelectSection ${SecLang_bg}
+  Goto done
+  ca: StrCmp "$LANGUAGE" "1027" 0 cs
+  !insertmacro SelectSection ${SecLang_ca}
+  Goto done
+  cs: StrCmp "$LANGUAGE" "1029" 0 da 
+  !insertmacro SelectSection ${SecLang_cs}
+  Goto done
+  da: StrCmp "$LANGUAGE" "1030" 0 nl
+  !insertmacro SelectSection ${SecLang_da}
+  Goto done
+  nl: StrCmp "$LANGUAGE" "1043" 0 fa
+  !insertmacro SelectSection ${SecLang_nl}
+  Goto done
+  ;We have several English translations, but we don't have a way of guessing, so we don't choose one
+  ;en: StrCmp "$LANGUAGE" "1033" 0 +3
+  ;!insertmacro SelectSection ${SecLang_en_??}
+  ;Goto done
+  fa: StrCmp "$LANGUAGE" "1065" 0 fi
+  !insertmacro SelectSection ${SecLang_fa}
+  Goto done
+  fi: StrCmp "$LANGUAGE" "1035" 0 fr
+  !insertmacro SelectSection ${SecLang_fi}
+  Goto done
+  fr: StrCmp "$LANGUAGE" "1036" 0 de
+  !insertmacro SelectSection ${SecLang_fr}
+  Goto done
+  de: StrCmp "$LANGUAGE" "1031" 0 he
+  !insertmacro SelectSection ${SecLang_de}
+  Goto done
+  he: StrCmp "$LANGUAGE" "1037" 0 hu
+  !insertmacro SelectSection ${SecLang_he}
+  Goto done
+  hu: StrCmp "$LANGUAGE" "1038" 0 it
+  !insertmacro SelectSection ${SecLang_hu}
+  Goto done
+  it: StrCmp "$LANGUAGE" "1040" 0 ja
+  !insertmacro SelectSection ${SecLang_it}
+  Goto done
+  ja: StrCmp "$LANGUAGE" "1041" 0 ko
+  !insertmacro SelectSection ${SecLang_ja}
+  Goto done
+  ko: StrCmp "$LANGUAGE" "1042" 0 ku
+  !insertmacro SelectSection ${SecLang_ko}
+  Goto done
+  ku: StrCmp "$LANGUAGE" "9999" 0 lt
+  !insertmacro SelectSection ${SecLang_ku}
+  Goto done
+  lt: StrCmp "$LANGUAGE" "1063" 0 nb
+  !insertmacro SelectSection ${SecLang_lt}
+  Goto done
+  nb: StrCmp "$LANGUAGE" "1044" 0 nn
+  !insertmacro SelectSection ${SecLang_nb}
+  Goto done
+  nn: StrCmp "$LANGUAGE" "2068" 0 pl
+  !insertmacro SelectSection ${SecLang_nn}
+  Goto done
+  pl: StrCmp "$LANGUAGE" "1045" 0 pt
+  !insertmacro SelectSection ${SecLang_pl}
+  Goto done
+  pt: StrCmp "$LANGUAGE" "2070" 0 pt_BR
+  !insertmacro SelectSection ${SecLang_pt}
+  Goto done
+  pt_BR: StrCmp "$LANGUAGE" "1046" 0 ro
+  !insertmacro SelectSection ${SecLang_pt_BR}
+  Goto done
+  ro: StrCmp "$LANGUAGE" "1048" 0 ru
+  !insertmacro SelectSection ${SecLang_ro}
+  Goto done
+  ru: StrCmp "$LANGUAGE" "1049" 0 sr
+  !insertmacro SelectSection ${SecLang_ru}
+  Goto done
+  sr: StrCmp "$LANGUAGE" "3098" 0 zh_CN
+  !insertmacro SelectSection ${SecLang_sr}
+  Goto done
+  zh_CN: StrCmp "$LANGUAGE" "2052" 0 sk
+  !insertmacro SelectSection ${SecLang_zh_CN}
+  Goto done
+  sk: StrCmp "$LANGUAGE" "1051" 0 sl
+  !insertmacro SelectSection ${SecLang_sk}
+  Goto done
+  sl: StrCmp "$LANGUAGE" "1060" 0 es
+  !insertmacro SelectSection ${SecLang_sl}
+  Goto done
+  es: StrCmp "$LANGUAGE" "1034" 0 sv
+  !insertmacro SelectSection ${SecLang_es}
+  Goto done
+  sv: StrCmp "$LANGUAGE" "1053" 0 zh_TW
+  !insertmacro SelectSection ${SecLang_sv}
+  Goto done
+  zh_TW: StrCmp "$LANGUAGE" "1028" 0 done
+  !insertmacro SelectSection ${SecLang_zh_TW}
+  Goto done
+
+  done:
+FunctionEnd
+
+
 ; SpellChecker Related Functions
 ;-------------------------------
 
-; Convert the a Section index to the language code
-; Push the section index onto the stack and pop off the language code after the call
-; This will set the error code, if no match is found
-
 ; Select and Disable any Sections that have currently installed dictionaries
 !macro CHECK_SPELLCHECK_SECTION lang
   ;Advance to the next (correct) section index