aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains/locale/advtrains.de.tr3
-rw-r--r--advtrains/locale/advtrains.fr.tr2
-rw-r--r--advtrains/locale/advtrains.zh_CN.tr2
-rw-r--r--advtrains/locale/advtrains.zh_TW.tr2
-rwxr-xr-xadvtrains/locale/gui184
5 files changed, 188 insertions, 5 deletions
diff --git a/advtrains/locale/advtrains.de.tr b/advtrains/locale/advtrains.de.tr
index cc610f1..d53cc82 100644
--- a/advtrains/locale/advtrains.de.tr
+++ b/advtrains/locale/advtrains.de.tr
@@ -16,7 +16,6 @@ Use Sneak+rightclick to bypass closed doors!=Nutzen Sie Schleichen+Rechtsklick,
Doors are closed! Use Sneak+rightclick to ignore the closed doors and get off!=Die Türen sind geschlossen. Nutzen Sie Schleichen+Rechtsklick, um trotz geschlossener Türen auszusteigen.
Access to @1=Zugang zu @1
You don't have the train_operator privilege.=Ihnen fehlt das „train_operator“-Privileg.
-# TODO: rebase fixup
The wagon's inventory is not empty!=Das Inventar dieses Waggons ist nicht leer!
Position is occupied by a train.=Ein Zug steht an dieser Position.
There's a Track Circuit Break here.=Hier ist eine Gleisabschnittsgrenze (TCB).
@@ -137,4 +136,4 @@ Steam Engine=Dampflokomotive
Detailed Steam Engine=detaillierte Dampflokomotive
Passenger Wagon=Passagierwaggon
Box Wagon=Güterwaggon
-Subway Passenger Wagon=U-Bahn-Waggon \ No newline at end of file
+Subway Passenger Wagon=U-Bahn-Waggon
diff --git a/advtrains/locale/advtrains.fr.tr b/advtrains/locale/advtrains.fr.tr
index 7e384c5..f3b169e 100644
--- a/advtrains/locale/advtrains.fr.tr
+++ b/advtrains/locale/advtrains.fr.tr
@@ -136,4 +136,4 @@ Steam Engine=Locomotive à vapeur
Detailed Steam Engine=Locomotive à vapeur Complexe
Passenger Wagon=Voiture Passager
Box Wagon=Wagon de Frêt
-Subway Passenger Wagon=Voiture de Métropolitain \ No newline at end of file
+Subway Passenger Wagon=Voiture de Métropolitain
diff --git a/advtrains/locale/advtrains.zh_CN.tr b/advtrains/locale/advtrains.zh_CN.tr
index 720d147..e887cc2 100644
--- a/advtrains/locale/advtrains.zh_CN.tr
+++ b/advtrains/locale/advtrains.zh_CN.tr
@@ -136,4 +136,4 @@ Steam Engine=蒸汽机车
Detailed Steam Engine=精细的蒸汽机车
Passenger Wagon=客车
Box Wagon=货运车厢
-Subway Passenger Wagon=地铁车厢 \ No newline at end of file
+Subway Passenger Wagon=地铁车厢
diff --git a/advtrains/locale/advtrains.zh_TW.tr b/advtrains/locale/advtrains.zh_TW.tr
index d70a55a..dcce3b5 100644
--- a/advtrains/locale/advtrains.zh_TW.tr
+++ b/advtrains/locale/advtrains.zh_TW.tr
@@ -136,4 +136,4 @@ Steam Engine=蒸汽機車
Detailed Steam Engine=精細的蒸汽機車
Passenger Wagon=客車
Box Wagon=貨運車廂
-Subway Passenger Wagon=地鐵車廂 \ No newline at end of file
+Subway Passenger Wagon=地鐵車廂
diff --git a/advtrains/locale/gui b/advtrains/locale/gui
new file mode 100755
index 0000000..6326916
--- /dev/null
+++ b/advtrains/locale/gui
@@ -0,0 +1,184 @@
+#!/usr/bin/tclsh
+package require Tk
+
+global translationTemplate
+global translationData
+global translationLangs
+
+proc readTranslationTemplate {} {
+ global translationTemplate
+ set translationTemplate [list]
+ set handle [open "template.txt" "r"]
+ fconfigure $handle -translation lf
+ set lst [list]
+ while {[gets $handle line] >= 0} {
+ if {$line eq ""} {
+ lappend lst ""
+ } elseif {[string match "#*" $line]} {
+ lappend lst $line
+ } elseif {[regexp {^(.+[^@])=.+$} $line x str]} {
+ lappend lst $str
+ }
+ }
+ set translationTemplate $lst;
+ close $handle
+}
+
+proc readTranslationFiles {} {
+ global translationData
+ global translationLangs
+ array set translationData [list]
+ set translationLangs [list]
+ set tbl [list]
+ set filelist [glob "advtrains.*.tr"]
+ foreach fn $filelist {
+ if {[regexp {\.([^.]+)\.} $fn x lang]} {
+ set handle [open $fn "r"];
+ fconfigure $handle -translation lf
+ while {[gets $handle line] >= 0} {
+ if {[regexp {^([^#].+[^@])=(.+)$} $line x ori tr]} {
+ set translationData($lang,$ori) $tr
+ }
+ }
+ lappend translationLangs $lang
+ close $handle
+ }
+ }
+ set translationLangs [lsort $translationLangs]
+}
+
+proc loadTranslationToTreeView {} {
+ global translationTemplate;
+ global translationData;
+ set lang [.f.langSelect get];
+ set tree .f.translationView;
+ $tree delete [$tree children {}];
+ set parent {};
+ foreach i [lrange $translationTemplate 1 end] {
+ if {$i eq ""} {
+ # nop
+ } elseif {[regexp {\#+\s*(.+)} $i x comment]} {
+ set parent [$tree insert {} end -text $comment -tags {notranslate}];
+ } elseif {[info exists translationData($lang,$i)]} {
+ $tree insert $parent end -text $i -values [list $translationData($lang,$i)]
+ } else {
+ $tree insert $parent end -text $i -values [list $i]
+ }
+ }
+ updateEntrySelection
+}
+
+proc updateTranslations {} {
+ readTranslationTemplate
+ readTranslationFiles
+}
+
+updateTranslations
+
+proc updateTranslationsToGUI {} {
+ updateTranslations
+ loadTranslationToTreeView
+}
+
+proc updateEntrySelection {args} {
+ global translationData
+ global origEntry
+ global trEntry
+ global refEntry
+ set reflang [.f.refLang get]
+ set focuseditem [.f.translationView focus]
+ set origEntry [.f.translationView item $focuseditem -text]
+ if {[.f.translationView tag has notranslate $focuseditem]} {
+ .f.trEntry state disabled
+ set trEntry ""
+ } else {
+ .f.trEntry state !disabled
+ set trEntry [lindex [.f.translationView item $focuseditem -value] 0]
+ }
+ if {[info exists translationData($reflang,$origEntry)]} {
+ set refEntry $translationData($reflang,$origEntry)
+ } else {
+ set refEntry ""
+ }
+}
+
+proc applyTranslationString {args} {
+ global translationData
+ global origEntry
+ global trEntry
+ set focuseditem [.f.translationView focus]
+ if {![.f.translationView tag has notranslate $focuseditem]} {
+ set lang [.f.langSelect get]
+ set translationData($lang,$origEntry) $trEntry
+ .f.translationView item $focuseditem -values [list $trEntry]
+ }
+}
+
+proc applyTranslationChanges {} {
+ global translationTemplate
+ global translationData
+ global translationLangs
+ foreach lang $translationLangs {
+ set handle [open [string cat "advtrains." $lang ".tr"] "w"]
+ fconfigure $handle -translation lf
+ foreach i $translationTemplate {
+ if {$i eq ""} {
+ puts $handle ""
+ } elseif {[string match "#*" $i]} {
+ puts $handle $i
+ } elseif {[info exists translationData($lang,$i)]} {
+ puts $handle [string cat $i "=" $translationData($lang,$i)]
+ } else {
+ puts $handle [string cat $i "=" $i]
+ }
+ }
+ close $handle
+ }
+}
+
+# GUI
+
+wm title . "Advtrains l10n GUI"
+grid [ttk::frame .f -padding 5] -column 0 -row 0 -sticky nsew
+grid rowconfigure . 0 -weight 1
+grid columnconfigure . 0 -weight 1
+
+grid rowconfigure .f 3 -weight 1
+grid columnconfigure .f 1 -weight 1
+
+foreach i [list 4 5 6] {grid rowconfigure .f $i -uniform bottom}
+
+ttk::combobox .f.langSelect -values $translationLangs -state readonly
+grid .f.langSelect -column 0 -row 0 -sticky we
+bind .f.langSelect <<ComboboxSelected>> {loadTranslationToTreeView}
+.f.langSelect current 0
+
+ttk::button .f.updateBtn -text "Read translation files" -command updateTranslationsToGUI
+grid .f.updateBtn -column 0 -row 1 -sticky we
+ttk::button .f.writeBtn -text "Write changes" -command applyTranslationChanges
+grid .f.writeBtn -column 0 -row 2 -sticky we
+
+ttk::treeview .f.translationView -columns "translation" -yscrollcommand ".f.translationScroll set"
+grid .f.translationView -column 1 -row 0 -rowspan 4 -columnspan 2 -sticky nsew
+bind .f.translationView <<TreeviewSelect>> updateEntrySelection
+ttk::scrollbar .f.translationScroll -orient vertical -command ".f.translationView yview"
+grid .f.translationScroll -column 3 -row 0 -sticky ns -rowspan 4
+
+ttk::label .f.origLabel -text "Original" -anchor w
+grid .f.origLabel -column 0 -row 4 -sticky nswe
+ttk::entry .f.origEntry -state readonly -textvariable origEntry
+grid .f.origEntry -column 1 -row 4 -sticky nswe -columnspan 3
+
+ttk::label .f.trLabel -text "Translated" -anchor w
+grid .f.trLabel -column 0 -row 5 -sticky nswe
+ttk::entry .f.trEntry -textvariable trEntry
+grid .f.trEntry -column 1 -row 5 -sticky nswe -columnspan 3
+trace add variable trEntry write applyTranslationString
+
+ttk::combobox .f.refLang -values [linsert $translationLangs 0 ""] -state readonly
+grid .f.refLang -column 0 -row 6 -sticky nswe
+bind .f.refLang <<ComboboxSelected>> updateEntrySelection
+ttk::entry .f.refEntry -state readonly -textvariable refEntry
+grid .f.refEntry -column 1 -row 6 -sticky nswe -columnspan 3
+
+loadTranslationToTreeView