Commit ba850bad authored by Mircea Bardac's avatar Mircea Bardac

new version for preplang, now with support for multiple files per language


git-svn-id: svn+ssh://svn.psi-im.org/home/psi/svn/win-installer/trunk@49 2d3a5ac0-73f9-4639-b284-2310bd1da355
parent 2a24a91a
...@@ -25,24 +25,35 @@ ...@@ -25,24 +25,35 @@
; use UI_LANGUAGE_LOAD instead of MUI_LANGUAGE if you have a ; use UI_LANGUAGE_LOAD instead of MUI_LANGUAGE if you have a
; translation file for the interface components in a file like ; translation file for the interface components in a file like
; lang\psi_installer_LANG.nsh ; lang\psi_installer_LANG.nsh
;
; Languages for the installer supported by NSIS:
; http://cvs.sourceforge.net/viewcvs.py/nsis/NSIS/Contrib/Language%20files/
!insertmacro UI_LANGUAGE_LOAD "English" !insertmacro UI_LANGUAGE_LOAD "English" ; -
!insertmacro UI_LANGUAGE_LOAD "Catalan" !insertmacro MUI_LANGUAGE "Bulgarian" ; bg
!insertmacro UI_LANGUAGE_LOAD "Czech" !insertmacro UI_LANGUAGE_LOAD "Catalan" ; ca
!insertmacro MUI_LANGUAGE "SimpChinese" !insertmacro UI_LANGUAGE_LOAD "Czech" ; cz
!insertmacro UI_LANGUAGE_LOAD "German" !insertmacro MUI_LANGUAGE "SimpChinese" ; zh
!insertmacro MUI_LANGUAGE "Estonian" !insertmacro UI_LANGUAGE_LOAD "German" ; de
!insertmacro UI_LANGUAGE_LOAD "Spanish" !insertmacro MUI_LANGUAGE "Hungarian" ; hu
!insertmacro UI_LANGUAGE_LOAD "French" ; Esperanto - no NSIS support ; eo
!insertmacro UI_LANGUAGE_LOAD "Greek" !insertmacro MUI_LANGUAGE "Estonian" ; et
!insertmacro MUI_LANGUAGE "Italian" !insertmacro UI_LANGUAGE_LOAD "Spanish" ; es
!insertmacro MUI_LANGUAGE "Japanese" !insertmacro UI_LANGUAGE_LOAD "French" ; fr
!insertmacro UI_LANGUAGE_LOAD "Macedonian" !insertmacro UI_LANGUAGE_LOAD "Greek" ; el
!insertmacro UI_LANGUAGE_LOAD "Dutch" !insertmacro MUI_LANGUAGE "Italian" ; it
!insertmacro UI_LANGUAGE_LOAD "Polish" !insertmacro MUI_LANGUAGE "Japanese" ; jp
!insertmacro MUI_LANGUAGE "Russian" !insertmacro UI_LANGUAGE_LOAD "Macedonian" ; mk
!insertmacro MUI_LANGUAGE "Slovak" !insertmacro UI_LANGUAGE_LOAD "Dutch" ; nl
!insertmacro MUI_LANGUAGE "Swedish" !insertmacro UI_LANGUAGE_LOAD "Polish" ; pl
!insertmacro MUI_LANGUAGE "Portuguese" ; pt
!insertmacro MUI_LANGUAGE "PortugueseBR" ; pt_BR
!insertmacro MUI_LANGUAGE "Russian" ; ru
!insertmacro MUI_LANGUAGE "Slovak" ; sk
!insertmacro MUI_LANGUAGE "Slovenian" ; sl
!insertmacro MUI_LANGUAGE "SerbianLatin" ; sr@Latn
!insertmacro MUI_LANGUAGE "Swedish" ; se
; Vietnamese - no NSIS support ; vi
; ******************************** ; ********************************
#!/usr/bin/env python #!/usr/bin/env python
# PrepLang v1.0 # PrepLang v2.0
# Copyright (c) 2005 Mircea Bardac # Copyright (c) 2005-2008 Mircea Bardac
# E-mail: dev AT mircea.bardac.net # E-mail: dev@mircea.bardac.net
# Script to prepare the (un)install file lists & setup for the language files # Script to prepare the (un)install file lists & setup for the language files
# Start from: installer/tools/ # Start from: installer/tools/
...@@ -11,58 +11,85 @@ ...@@ -11,58 +11,85 @@
import os import os
import string import string
import array
import sys import sys
import shutil import shutil
# langmap[<LanguageKey>] = [<SectionName>,<LanguageID>,<LanguageName>,<FileList>]
langmap = {}
# read language mappings
fmap = open("psi_lang.map")
for s in fmap.readlines():
s = s.replace("\n","")
# langsettings[<LanguageKey>,<SectionName>,<LanguageID>,<LanguageName>]
langsettings = s.split('\t')
if langsettings[0] == '': continue
if s[0] == '#': continue
lang_key = langsettings[0]
langmap[lang_key] = {}
langmap[lang_key]['section_id'] = langsettings[1]
langmap[lang_key]['lang_id'] = langsettings[2]
langmap[lang_key]['lang_name'] = langsettings[3]
langmap[lang_key]['files'] = []
fmap.close()
# create build paths if they do not exist # create build paths if they do not exist
# they are needed to place translation files in the installer
if not os.path.exists("../build"): if not os.path.exists("../build"):
os.mkdir("../build"); os.mkdir("../build");
if not os.path.exists("../build/psi_lang"): if not os.path.exists("../build/psi_lang"):
os.mkdir("../build/psi_lang"); os.mkdir("../build/psi_lang");
fmap=open("psi_lang.map") # read files in translation directory
lang_src_dir = sys.argv[1]
flanginst=open("../build/psi_lang_install.nsh","w") langlist = {}
flangsetup=open("../build/psi_lang_setup.nsh","w") for file in os.listdir(lang_src_dir):
flanguninst=open("../build/psi_lang_uninstall.nsh","w") if os.path.isdir(lang_src_dir+"/"+file): continue
# file format: "app_langkey.extension"
langmap={} lang_key = file[file.find('_') + 1:file.find('.')]
for s in fmap.readlines(): if (not langmap.has_key(lang_key)):
s=s.replace("\n","")
langsettings=s.split('\t')
if langsettings[0]!='':
if s[0]=='#': continue
langmap[langsettings[0]]=langsettings[1:]
langlist={}
for file in os.listdir(sys.argv[1]):
if os.path.isdir(sys.argv[1]+"/"+file): continue
shutil.copyfile(sys.argv[1]+"/"+file, "../build/psi_lang/"+file);
if (not langmap.has_key(file)):
print "!Language definition not found for file: "+file+" (skipped)" print "!Language definition not found for file: "+file+" (skipped)"
continue continue
else: else:
print "Language definition found for: "+file+" = "+langmap[file][2] shutil.copyfile(lang_src_dir + "/" + file, "../build/psi_lang/" + file);
langlist[langmap[file][2]]=[file, langmap[file][0], langmap[file][1]] print "Language definition found for: "+file+" = "+langmap[lang_key]['lang_name']
langmap[lang_key]['files'].append(file)
for lang in sorted(langlist.keys()): # generate translation related installer content
filename=langlist[lang][0] flanginst = open("../build/psi_lang_install.nsh","w")
sectionid=langlist[lang][1] flangsetup = open("../build/psi_lang_setup.nsh","w")
langid=langlist[lang][2] flanguninst = open("../build/psi_lang_uninstall.nsh","w")
flanginst.write("; "+lang+"\n")
flanginst.write("Section /o \""+lang+"\" "+sectionid+"\n") for lang_key in sorted(langmap.keys()):
files=langmap[lang_key]['files']
if len(files) == 0: continue
section_id=langmap[lang_key]['section_id']
lang_id=langmap[lang_key]['lang_id']
lang_name=langmap[lang_key]['lang_name']
# psi_lang_install.nsh
flanginst.write("; "+lang_name+"\n")
flanginst.write("Section /o \""+lang_name+"\" "+section_id+"\n")
flanginst.write("\tSetOverwrite on\n") flanginst.write("\tSetOverwrite on\n")
flanginst.write("\tSetOutPath \"$INSTDIR\\\"\n") flanginst.write("\tSetOutPath \"$INSTDIR\\\"\n")
flanginst.write("\tFile \"${APP_BUILD}psi_lang${FILE_SEPARATOR}"+filename+"\"\n") for filename in files:
flanginst.write("\tFile \"${APP_BUILD}psi_lang${FILE_SEPARATOR}" + filename + "\"\n")
flanginst.write("SectionEnd\n\n") flanginst.write("SectionEnd\n\n")
flanguninst.write("\tDelete \"$INSTDIR\\"+filename+"\"\n")
if langid!="": # psi_lang_uninstall.nsh
flangsetup.write("\tStrCmp $LANGUAGE ${"+langid+"} 0 +2\n") for filename in files:
flangsetup.write("\t\tSectionSetFlags ${"+sectionid+"} ${SF_SELECTED}\n") flanguninst.write("\tDelete \"$INSTDIR\\" + filename + "\"\n")
# psi_lang_setup.nsh
if lang_id!="":
flangsetup.write("\tStrCmp $LANGUAGE ${" + lang_id + "} 0 +2\n")
flangsetup.write("\t\tSectionSetFlags ${" + section_id + "} ${SF_SELECTED}\n")
else: else:
flangsetup.write("\t; No "+lang+" AutoSelection\n") flangsetup.write("\t; No "+lang_name+" AutoSelection\n")
# close open resources
flanginst.close() flanginst.close()
flangsetup.close() flangsetup.close()
flanguninst.close() flanguninst.close()
# Language Mapping File # Language Mapping File
# Structure: # Structure:
# <FileName> <SectionName> <LanguageID> <LanguageName> # <LanguageKey> <SectionName> <LanguageID> <LanguageName>
# <LanguageID> is the NSIS language ID - can be missing # above fields are separated by tabs
# <LanguageKey> is the language unique code (example: xx in psi_xx.qm)
# There might be multiple translation files matching the format app_xx.extension
# <LanguageID> is the NSIS language ID - can be empty
psi_cs.qm LangCS LANG_FRENCH Czech bg LangBG LANG_BULGARIAN Bulgarian
psi_nl.qm LangNL LANG_DUTCH Dutch ca LangCA LANG_CATALAN Catalan
psi_et.qm LangET LANG_ESTONIAN Estonian cs LangCS LANG_CZECH Czech
psi_fr.qm LangFR LANG_FRENCH French nl LangNL LANG_DUTCH Dutch
psi_de.qm LangDE LANG_GERMAN German et LangET LANG_ESTONIAN Estonian
psi_el.qm LangEL LANG_GREEK Greek eo LangEO Esperanto
psi_mk.qm LangMK LANG_MACEDONIAN Macedonian fr LangFR LANG_FRENCH French
psi_pl.qm LangPL LANG_POLISH Polish de LangDE LANG_GERMAN German
psi_zh.qm LangZH LANG_SIMPCHINESE Simplified Chinese el LangEL LANG_GREEK Greek
psi_es.qm LangES LANG_SPANISH Spanish hu LangHU LANG_HUNGARIAN Hungarian
psi_ru.qm LangRU LANG_RUSSIAN Russian mk LangMK LANG_MACEDONIAN Macedonian
psi_sk.qm LangSK LANG_SLOVAK Slovak pl LangPL LANG_POLISH Polish
psi_vi.qm LangVI Vietnamese pt LangPT LANG_PORTUGUESE Portuguese
pt_BR LangPTBR LANG_PORTUGUESEBR Portuguese (BR)
zh LangZH LANG_SIMPCHINESE Simplified Chinese
es LangES LANG_SPANISH Spanish
ru LangRU LANG_RUSSIAN Russian
sr@Latn LangSRLat LANG_SERBIANLATIN Serbian (Latin)
sk LangSK LANG_SLOVAK Slovak
sl LangSL LANG_SLOVENIAN Slovenian
vi LangVI Vietnamese
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment