--- a/Tools__InternationalLanguageTranslationEditor.st Mon Mar 06 11:19:00 2006 +0100
+++ b/Tools__InternationalLanguageTranslationEditor.st Mon Mar 06 19:27:26 2006 +0100
@@ -10,7 +10,7 @@
languageShownHolders dataSetView lastExtractedClass
lastExtractedApplicationClass stopApplicationIconVisibleHolder
monitoredApplication originalTextModifiedHolder
- languageTextModifiedHolder'
+ languageTextModifiedHolder inSingleFileMode'
classVariableNames:'LastExtractedClass LastExtractedApplicationClass'
poolDictionaries:''
category:'Interface-UIPainter'
@@ -551,6 +551,7 @@
initialize
modified := false.
+ inSingleFileMode := false.
super initialize
!
@@ -687,23 +688,54 @@
!
readResourceFile:aFilename
- |inStream lineString|
+ |lang|
+
+ lang := Dialog choose:'For which language ?' fromList:languagesList lines:10.
+ lang isNil ifTrue:[^ self ].
+
+ self readResourceFile:aFilename asLanguage:lang asSymbol
+!
+
+readResourceFile:aFilename asLanguage:lang
+ |resourcePack inStream lineString encoding decoder sortedKeys remainingKeys|
aFilename exists ifFalse:[^ self ].
+ resourcePack := ResourcePack new.
+
inStream := aFilename readStream.
[inStream atEnd] whileFalse:[
lineString := inStream nextLine.
(lineString notEmpty
and:[ (lineString startsWith:';') not ]) ifTrue:[
- (lineString startsWith:'#encoding ') ifTrue:[
-self halt.
+ ((lineString startsWith:'#') and:[(lineString startsWith:'#(') not]) ifTrue:[
+ lineString := (lineString copyFrom:2) withoutSeparators.
+ (lineString startsWith:'encoding ') ifTrue:[
+ encoding := ResourcePack extractEncodingFromLine:lineString.
+ decoder := CharacterEncoder encoderFor:encoding ifAbsent:nil.
+ ].
] ifFalse:[
-self halt.
+ ResourcePack
+ processResourceLine:lineString
+ encoding:decoder
+ file:aFilename pathName
+ printErrorWith:[:msg | Transcript showCR:msg ]
+ for:resourcePack
+ keepUselessTranslations:true.
].
].
].
inStream close.
+
+ sortedKeys := (resourcePack keys select:[:k | k isString]) asSortedCollection.
+ remainingKeys := resourcePack keys select:[:k | k isString not].
+
+ sortedKeys do:[:k |
+ keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k)
+ ].
+ remainingKeys do:[:k |
+ keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k)
+ ].
!
removeLanguage
@@ -1163,8 +1195,10 @@
!InternationalLanguageTranslationEditor::KeyStringsToLanguageMappings methodsFor:'accessing'!
addKey:aKey
- keys add:aKey.
- self changed.
+ (keys includes:aKey) ifFalse:[
+ keys add:aKey.
+ self changed.
+ ]
!
addKeys:aCollectionOfKey
@@ -1173,8 +1207,10 @@
!
addLanguage:lang
- languages add:lang.
- languageMappings at:lang put:(Dictionary new).
+ (languages includes:lang) ifFalse:[
+ languages add:lang.
+ languageMappings at:lang put:(Dictionary new).
+ ]
!
at:aKey language:language
@@ -1232,6 +1268,15 @@
languages := OrderedCollection new.
languageMappings := Dictionary new.
+ self addLanguage:#'de'.
+ self addLanguage:#'fr'.
+ self addLanguage:#'es'.
+ self addLanguage:(Smalltalk language).
+
+ "/ self initializeDemoMappings.
+!
+
+initializeDemoMappings
keys add:'open'.
keys add:'close'.
keys add:'yes'.