1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

* w32installer.nsi: Added page to select the language.

* mk-w32-dist: Create the opt.ini using the available languages.
This commit is contained in:
Werner Koch 2005-02-16 13:27:57 +00:00
parent bb71180d07
commit ca24b4ea3f
3 changed files with 167 additions and 47 deletions

View File

@ -1,3 +1,8 @@
2005-02-16 Werner Koch <wk@g10code.com>
* w32installer.nsi: Added page to select the language.
* mk-w32-dist: Create the opt.ini using the available languages.
2005-02-03 Werner Koch <wk@g10code.com>
* w32installer.nsi: Display README.W32 at the end of the

View File

@ -47,6 +47,49 @@ if ! makensis -version >/dev/null 2>&1 ; then
topdir=
fi
# A function to return a plain ASCII (or Latin-1) encoded description
# text for a language identifier. We need this to display the list of
# available languages in the installer. NSIS does not support utf-8
# so we need to standardize on one character set. Note that this
# script itself is written in utf-8 but the resulting file will get
# converted to Latin-1
get_langname () {
case "$1" in
be) r="Belarusian"; ;;
ca) r="Català"; ;;
cs) r="Cesky"; ;;
da) r="Danish"; ;;
de) r="Deutsch"; ;;
el) r="Greek"; ;;
en|en@*) r="English"; ;;
eo) r="Esperanto"; ;;
es) r="Español"; ;;
et) r="Eesti keel"; ;;
fi) r="Suomi"; ;;
fr) r="Français"; ;;
gl) r="Galician"; ;;
hu) r="Magyar"; ;;
id) r="Indonesian"; ;;
it) r="Italiano"; ;;
ja) r="Japanese"; ;;
pl) r="Polski"; ;;
pt) r="Português"; ;;
pt_BR) r="Português (do Brasil)"; ;;
ro) r="Romana"; ;;
ru) r="Russian"; ;;
sk) r="Slovensky"; ;;
sv) r="Svenska"; ;;
tr) r="Türkçe"; ;;
zh_CN) r="Chinese (simplified)"; ;;
zh_TW) r="Chinese (traditional)"; ;;
*) r="" ;;
esac
echo "$r"
}
# Figure out the version
version=$(sed -n 's/^#[ ]*define[ ][ ]*VERSION[ ][ ]*\"\([0-9.a-z-]*\)\"/\1/p' $bindir/config.h)
prod_version=$(echo "$version"|awk -F'[^0-9]' '{print $1 "." $2 "." $3 ".1"}')
@ -89,27 +132,52 @@ for i in gnupg-w32.reg; do
done
# We must distribute the MO files in UTF-8, the conversion is done by
# gpg at runtime.
for i in ${srcdir}/po/*.po; do
# gpg at runtime. To include English at the right position in the list we
# need a special case.
langlist=""
langdesclist=""
for i in `(ls ${srcdir}/po/*.po; echo ${srcdir}/po/en.po) | sort`; do
lang=$(basename $i .po)
grep -s $lang ${srcdir}/po/LINGUAS >/dev/null || continue
[ -f$lang.mo -a $lang.mo -nt $i ] && continue
fromset=`sed -n '/^"Content-Type:/ s/.*charset=\([a-zA-Z0-9_-]*\).*/\1/p' $i`
case "$fromset" in
utf8|utf-8|UTF8|UTF-8)
echo "$lang: keeping $fromset" >&2
msgfmt --output-file=$lang.mo $i
;;
*)
echo "$lang: converting from $fromset to utf-8" >&2
iconv --silent --from-code=$fromset --to-code=utf-8 < $i | \
sed "/^\"Content-Type:/ s/charset=[a-zA-Z0-9_-]*/charset=utf-8/" | \
msgfmt --output-file=$lang.mo -
;;
esac
if [ $lang != "en" ]; then
grep -s $lang ${srcdir}/po/LINGUAS >/dev/null || continue
[ -f$lang.mo -a $lang.mo -nt $i ] && continue
fromset=`sed -n '/^"Content-Type:/ s/.*charset=\([a-zA-Z0-9_-]*\).*/\1/p' $i`
case "$fromset" in
utf8|utf-8|UTF8|UTF-8)
echo "$lang: keeping $fromset" >&2
msgfmt --output-file=$lang.mo $i
;;
*)
echo "$lang: converting from $fromset to utf-8" >&2
iconv --silent --from-code=$fromset --to-code=utf-8 < $i | \
sed "/^\"Content-Type:/ s/charset=[a-zA-Z0-9_-]*/charset=utf-8/"|\
msgfmt --output-file=$lang.mo -
;;
esac
fi
langlist="$langlist $lang"
langname="`get_langname $lang`"
[ -n "$langdesclist" ] && langdesclist="${langdesclist}|"
langdesclist="${langdesclist}${lang} - ${langname}"
done
# Create the option file for use with the NSIS installer.
cat <<EOF | iconv --silent --from-code=utf-8 --to-code=latin1 >opt.ini
[Settings]
NumFields=1
[Field 1]
Type=DropList
Left=0
Right=130
Top=20
Bottom=100
ListItems="$langdesclist"
EOF
# If we have a topdir, assume the full build environment and
# prepare the installer
if [ -n "$topdir" ]; then

View File

@ -17,6 +17,8 @@
; We use the modern UI.
!include "MUI.nsh"
!include "StrFunc.nsh"
!include "Sections.nsh"
; -------------
; General stuff
@ -59,11 +61,6 @@ VIAddVersionKey "FileVersion" "${PROD_VERSION}"
Var MYTMP
Var STARTMENU_FOLDER
Var DOC_INSTALLED
!ifdef WITH_WINPT
Var WINPT_INSTALLED
!endif
; ------------------
; Interface Settings
; ------------------
@ -101,10 +98,10 @@ Var WINPT_INSTALLED
!insertmacro MUI_PAGE_LICENSE "COPYING.txt"
;;Page custom PageSelectOptions
!insertmacro MUI_PAGE_COMPONENTS
Page custom CustomPageOptions
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
@ -138,15 +135,18 @@ Var WINPT_INSTALLED
; Installer Sections
; ------------------
${StrStr} # Supportable for Install Sections and Functions
${StrTok} # Supportable for Install Sections and Functions
;InstType "full"
;InstType "minimal"
!insertmacro MUI_RESERVEFILE_LANGDLL
;;!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
;;ReserveFile "w32inst-opt.ini"
ReserveFile "COPYING.txt"
ReserveFile "opt.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
;----------------------
@ -211,8 +211,6 @@ Section "WinPT" SecWinPT
WriteRegStr HKCU "Software\GNU\GnuPG" "gpgProgram" "$INSTDIR\gpg.exe"
StrCpy $WINPT_INSTALLED 1
SectionEnd ; Section WinPT
!endif
@ -233,8 +231,6 @@ Section "Documentation" SecDoc
File "NEWS.winpt.txt"
!endif ; WITH_WINPT
StrCpy $DOC_INSTALLED 1
SectionEnd ; Section Documentation
@ -279,18 +275,25 @@ Section "-Finish"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GnuPG NEWS.lnk" \
"$INSTDIR\Doc\NEWS.txt"
IntCmp $DOC_INSTALLED 1 0 +2 +2
SectionGetFlags ${SecDoc} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} 0 +2
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GnuPG Manual Page.lnk" \
"$INSTDIR\Doc\gpg.man"
!ifdef WITH_WINPT
IntCmp $WINPT_INSTALLED 1 0 no_winpt_menu no_winpt_menu
SectionGetFlags ${SecWinPT} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} 0 no_winpt_menu
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\winpt.lnk" \
"$INSTDIR\winpt.exe"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\WinPT README.lnk" \
"$INSTDIR\Doc\README.winpt.txt"
IntCmp $DOC_INSTALLED 1 0 +2 +2
SectionGetFlags ${SecDoc} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} 0 +2
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\WinPT NEWS.lnk" \
"$INSTDIR\Doc\NEWS.winpt.txt"
@ -304,6 +307,29 @@ Section "-Finish"
!insertmacro MUI_STARTMENU_WRITE_END
;;-----------------
;; Set the language
;;-----------------
SectionGetFlags ${SecNLS} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} 0 no_lang_set
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "opt.ini" "Field 1" "ListItems"
DetailPrint "Available languages: $R0"
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "opt.ini" "Field 1" "State"
DetailPrint "Selected language: $R1"
${StrStr} $R2 $R0 $R1
StrCmp $R2 "" +1 +3
DetailPrint "No language selected - using default"
StrCpy $R2 "en - English"
${StrTok} $R3 $R2 " " "0" "1"
DetailPrint "Setting language to: $R3"
WriteRegStr HKCU "Software\GNU\GnuPG" "Lang" $R3
no_lang_set:
;;
SectionEnd ; "-Finish"
@ -392,8 +418,7 @@ Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
; !insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS \
; "${GNUPG_SRCDIR}/scripts/w32inst-opt.ini" "w32inst-opt.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "opt.ini"
FunctionEnd
@ -405,17 +430,33 @@ Function un.onInit
FunctionEnd
;;Function PageSelectOptions
;;
;; ; Setup a default for the langage to install. Take it form the registry
;;
;; !insertmacro MUI_HEADER_TEXT "Install Options" "Languages"
;; !insertmacro MUI_INSTALLOPTIONS_DISPLAY "w32inst-opt.ini"
;;
;; ; Save away the language to install
;;
;;FunctionEnd
;;
Function CustomPageOptions
SectionGetFlags ${SecNLS} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} show
Abort
show:
!insertmacro MUI_HEADER_TEXT "$(T_InstallOptions)" "$(T_SelectLanguage)"
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "opt.ini" "Field 1" "ListItems"
;;DetailPrint "Available languages: $R0"
ReadRegStr $R1 HKCU "Software\GNU\GnuPG" "Lang"
;;DetailPrint "Currently configured language: $R1"
${StrStr} $R2 $R0 "$R1 - "
StrCmp $R2 "" +1 +3
DetailPrint "Configured language not avalailbe - using default"
StrCpy $R2 "en - English"
${StrTok} $R3 $R2 "|" "0" "1"
;;DetailPrint "Setting selection to: $R3"
!insertmacro MUI_INSTALLOPTIONS_WRITE "opt.ini" "Field 1" "State" $R3
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "opt.ini"
FunctionEnd
; Install iconv.dll if it has not been installed on the system.
@ -475,6 +516,12 @@ LangString T_About ${LANG_GERMAN} \
\r\n\r\n$_CLICK \
\r\n\r\n\r\n\r\n\r\nDies ist GnuPG version ${VERSION}\r\n\
erstellt am $%BUILDINFO%"
LangString T_InstallOptions ${LANG_ENGLISH} "Install Options"
LangString T_InstallOptions ${LANG_GERMAN} "Installationsoptionen"
LangString T_SelectLanguage ${LANG_ENGLISH} "GnuPG Language Selection"
LangString T_SelectLanguage ${LANG_German} "Auswahl der Sprache für GnuPG"
LangString T_ShowReadme ${LANG_ENGLISH} "Show the README file"
LangString T_ShowReadme ${LANG_GERMAN} "Die README Datei anzeigen"