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 @@
; use UI_LANGUAGE_LOAD instead of MUI_LANGUAGE if you have a
; translation file for the interface components in a file like
; 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 "Catalan"
!insertmacro UI_LANGUAGE_LOAD "Czech"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro UI_LANGUAGE_LOAD "German"
!insertmacro MUI_LANGUAGE "Estonian"
!insertmacro UI_LANGUAGE_LOAD "Spanish"
!insertmacro UI_LANGUAGE_LOAD "French"
!insertmacro UI_LANGUAGE_LOAD "Greek"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro UI_LANGUAGE_LOAD "Macedonian"
!insertmacro UI_LANGUAGE_LOAD "Dutch"
!insertmacro UI_LANGUAGE_LOAD "Polish"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro UI_LANGUAGE_LOAD "English" ; -
!insertmacro MUI_LANGUAGE "Bulgarian" ; bg
!insertmacro UI_LANGUAGE_LOAD "Catalan" ; ca
!insertmacro UI_LANGUAGE_LOAD "Czech" ; cz
!insertmacro MUI_LANGUAGE "SimpChinese" ; zh
!insertmacro UI_LANGUAGE_LOAD "German" ; de
!insertmacro MUI_LANGUAGE "Hungarian" ; hu
; Esperanto - no NSIS support ; eo
!insertmacro MUI_LANGUAGE "Estonian" ; et
!insertmacro UI_LANGUAGE_LOAD "Spanish" ; es
!insertmacro UI_LANGUAGE_LOAD "French" ; fr
!insertmacro UI_LANGUAGE_LOAD "Greek" ; el
!insertmacro MUI_LANGUAGE "Italian" ; it
!insertmacro MUI_LANGUAGE "Japanese" ; jp
!insertmacro UI_LANGUAGE_LOAD "Macedonian" ; mk
!insertmacro UI_LANGUAGE_LOAD "Dutch" ; nl
!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
# PrepLang v1.0
# Copyright (c) 2005 Mircea Bardac
# E-mail: dev AT mircea.bardac.net
# PrepLang v2.0
# Copyright (c) 2005-2008 Mircea Bardac
# E-mail: dev@mircea.bardac.net
# Script to prepare the (un)install file lists & setup for the language files
# Start from: installer/tools/
......@@ -11,58 +11,85 @@
import os
import string
import array
import sys
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
# they are needed to place translation files in the installer
if not os.path.exists("../build"):
os.mkdir("../build");
if not os.path.exists("../build/psi_lang"):
os.mkdir("../build/psi_lang");
fmap=open("psi_lang.map")
flanginst=open("../build/psi_lang_install.nsh","w")
flangsetup=open("../build/psi_lang_setup.nsh","w")
flanguninst=open("../build/psi_lang_uninstall.nsh","w")
langmap={}
for s in fmap.readlines():
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)):
# read files in translation directory
lang_src_dir = sys.argv[1]
langlist = {}
for file in os.listdir(lang_src_dir):
if os.path.isdir(lang_src_dir+"/"+file): continue
# file format: "app_langkey.extension"
lang_key = file[file.find('_') + 1:file.find('.')]
if (not langmap.has_key(lang_key)):
print "!Language definition not found for file: "+file+" (skipped)"
continue
else:
print "Language definition found for: "+file+" = "+langmap[file][2]
langlist[langmap[file][2]]=[file, langmap[file][0], langmap[file][1]]
shutil.copyfile(lang_src_dir + "/" + file, "../build/psi_lang/" + file);
print "Language definition found for: "+file+" = "+langmap[lang_key]['lang_name']
langmap[lang_key]['files'].append(file)
for lang in sorted(langlist.keys()):
filename=langlist[lang][0]
sectionid=langlist[lang][1]
langid=langlist[lang][2]
flanginst.write("; "+lang+"\n")
flanginst.write("Section /o \""+lang+"\" "+sectionid+"\n")
# generate translation related installer content
flanginst = open("../build/psi_lang_install.nsh","w")
flangsetup = open("../build/psi_lang_setup.nsh","w")
flanguninst = open("../build/psi_lang_uninstall.nsh","w")
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("\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")
flanguninst.write("\tDelete \"$INSTDIR\\"+filename+"\"\n")
if langid!="":
flangsetup.write("\tStrCmp $LANGUAGE ${"+langid+"} 0 +2\n")
flangsetup.write("\t\tSectionSetFlags ${"+sectionid+"} ${SF_SELECTED}\n")
# psi_lang_uninstall.nsh
for filename in files:
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:
flangsetup.write("\t; No "+lang+" AutoSelection\n")
flangsetup.write("\t; No "+lang_name+" AutoSelection\n")
# close open resources
flanginst.close()
flangsetup.close()
flanguninst.close()
# Language Mapping File
# Structure:
# <FileName> <SectionName> <LanguageID> <LanguageName>
# <LanguageID> is the NSIS language ID - can be missing
# <LanguageKey> <SectionName> <LanguageID> <LanguageName>
# 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
psi_nl.qm LangNL LANG_DUTCH Dutch
psi_et.qm LangET LANG_ESTONIAN Estonian
psi_fr.qm LangFR LANG_FRENCH French
psi_de.qm LangDE LANG_GERMAN German
psi_el.qm LangEL LANG_GREEK Greek
psi_mk.qm LangMK LANG_MACEDONIAN Macedonian
psi_pl.qm LangPL LANG_POLISH Polish
psi_zh.qm LangZH LANG_SIMPCHINESE Simplified Chinese
psi_es.qm LangES LANG_SPANISH Spanish
psi_ru.qm LangRU LANG_RUSSIAN Russian
psi_sk.qm LangSK LANG_SLOVAK Slovak
psi_vi.qm LangVI Vietnamese
bg LangBG LANG_BULGARIAN Bulgarian
ca LangCA LANG_CATALAN Catalan
cs LangCS LANG_CZECH Czech
nl LangNL LANG_DUTCH Dutch
et LangET LANG_ESTONIAN Estonian
eo LangEO Esperanto
fr LangFR LANG_FRENCH French
de LangDE LANG_GERMAN German
el LangEL LANG_GREEK Greek
hu LangHU LANG_HUNGARIAN Hungarian
mk LangMK LANG_MACEDONIAN Macedonian
pl LangPL LANG_POLISH Polish
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