ResourcePack.st
changeset 8667 6b5cdd36a62f
parent 8650 8b8e5b724ebe
child 8675 62c554057380
--- a/ResourcePack.st	Wed Mar 27 11:07:53 2019 +0100
+++ b/ResourcePack.st	Wed Mar 27 15:21:44 2019 +0100
@@ -19,7 +19,7 @@
 	instanceVariableNames:'packsClassName packsFileName fileReadFailed superPack projectPack
 		usedKeys cache superPacks'
 	classVariableNames:'DebugModifications FailedToLoadPacks KeepStatisticsOnUsedKeys
-		Packs LastLanguageChosen'
+		Packs LastLanguageChosen DebugResources'
 	poolDictionaries:''
 	category:'Interface-Internationalization'
 !
@@ -870,7 +870,13 @@
             ignoreTranslation ifFalse:[
                 oldValue := aResourcePack at:name ifAbsent:nil.
                 oldValue notNil ifTrue:[
-                    |fromInfo oldPack|
+                    |fromInfo oldPack newValue|
+
+                    value isBlock ifTrue:[
+                        newValue := value value
+                    ] ifFalse:[
+                        newValue := value
+                    ].    
 
                     fromInfo := ''.
                     oldPack := aResourcePack resourcePackContainingKey:name.
@@ -878,10 +884,10 @@
                         fromInfo := ' (from ',oldPack packsFileName,')' 
                     ].
 
-                    oldValue ~= value ifTrue:[
+                    oldValue ~= newValue ifTrue:[
                         printError value:('conflicting resource: "' , name , '"').
                         printError value:('  oldValue: "%1"%2' bindWith:oldValue with:fromInfo).
-                        printError value:('  newValue: "%1"' bindWith:value).
+                        printError value:('  newValue: "%1"' bindWith:newValue).
                     ] ifFalse:[
                         printError value:('duplicate resource: "%1"%2' bindWith:name with:fromInfo).
                     ].
@@ -890,6 +896,7 @@
                     value := aResourcePack string:value.
                 ].
 
+                "/ DebugModifications := true
                 DebugModifications == true ifTrue:[
                     "/ for debugging only !! (not all primitive code is ready for immutableStrings)
                     value class == String ifTrue:[
@@ -903,7 +910,7 @@
     ]
 
     "Modified: / 06-02-2014 / 15:33:03 / cg"
-    "Modified: / 20-02-2019 / 13:00:47 / Claus Gittinger"
+    "Modified: / 27-03-2019 / 11:59:49 / Claus Gittinger"
 !
 
 resourceFileEntryFor:keyString to:nationalString
@@ -1737,10 +1744,12 @@
     ] ifFalse:[
         fileReadFailed := true.
 
-        ('ResourcePack [warning]: "' , triedFilename , '" contains error(s) - data may be incomplete.') errorPrintCR.
+        Logger warning:'ResourcePack [warning]: "%1" contains error(s) - data may be incomplete.'
+               with:triedFilename.
     ].
 
     "Modified: / 20-08-2011 / 17:10:02 / cg"
+    "Modified: / 27-03-2019 / 11:01:57 / Claus Gittinger"
 !
 
 readFromResourceStream:inStream in:dirName
@@ -1755,17 +1764,17 @@
                     ifTrue:[inStream baseName]
                     ifFalse:['---']).
 
-    printError := [:message |
-                    'ResourcePack [warning]: ' errorPrint.
-                    message errorPrint.
-                    ' in file:' errorPrint.
-                    fileName errorPrint.
-                    ' line: ' errorPrint.
-                    lineNumber errorPrintCR
-                  ].
-
-    printError := [:message | ].
-
+    DebugResources == true ifTrue:[                
+        printError := [:message |
+                        Logger warning:'ResourcePack [warning]: %1 in file: %2 line: %3' 
+                               with:message
+                               with:fileName
+                               with:lineNumber.
+                      ].
+    ] ifFalse:[
+        printError := [:message | ].
+    ].
+    
     encoding := nil.
 
     ok := true.
@@ -1774,23 +1783,27 @@
     lineNumber := 0.
     pushedSkipValues := OrderedCollection new.
 
-    errorHandler := [:ex |
-                        |con count|
+    errorHandler := 
+        [:ex |
+            |con count|
 
-                        Logger warning:('ResourcePack [warning]: ''' , ex description , '''').
-                        Logger info:('ResourcePack [info]: file: ' , inStream pathName printString , ' line: ' , lineNumber printString , ': ''' , lineString , '''') "errorPrintCR".
-                        con := ex suspendedContext.
-                        Logger info:('ResourcePack [info]: in: ' , con fullPrintString).
-                        con := con sender.
-                        count := 1.
-                        [con notNil and:[count <= 20]] whileTrue:[
-                            Logger info:('ResourcePack [info]:   : ' , con fullPrintString) .
-                            count := count + 1.
-                            con := con sender.
-                        ].    
-                        value := nil.
-                        ok := false.
-                    ].
+            Logger warning:'ResourcePack [warning]: "%1"' with:ex description.
+            Logger warning:'ResourcePack [info]: in: %1 [%2]: "%3"'
+                   with:inStream pathName
+                   with:lineNumber
+                   with:lineString.
+            con := ex suspendedContext.
+            Logger warning:'ResourcePack [info]: in: %1' with:con fullPrintString.
+            con := con sender.
+            count := 1.
+            [con notNil and:[count <= 20]] whileTrue:[
+                Logger warning:'ResourcePack [info]:   : %1' with:con fullPrintString.
+                count := count + 1.
+                con := con sender.
+            ].    
+            value := nil.
+            ok := false.
+        ].
 
     [inStream atEnd] whileFalse:[
         lineString := inStream nextLine. lineNumber := lineNumber + 1.
@@ -1896,13 +1909,14 @@
                                                       compile:false.
                                 ] ifFalse:[
                                     "/ process as resource
-                                    self
-                                        processLine:lineString
+                                    self class
+                                        processResourceLine:lineString
                                         encoding:decoder
                                         file:(inStream isFileStream
                                                 ifTrue:[inStream pathName]
                                                 ifFalse:['---'])
                                         printErrorWith:printError
+                                        for:self
                                 ]]
                     ]
                 ]
@@ -1915,7 +1929,7 @@
     "Modified: / 18-09-2006 / 20:35:37 / cg"
     "Modified: / 10-10-2018 / 14:14:00 / sr"
     "Modified: / 22-02-2019 / 17:13:13 / Stefan Vogel"
-    "Modified: / 01-03-2019 / 16:09:38 / Claus Gittinger"
+    "Modified: / 27-03-2019 / 12:01:12 / Claus Gittinger"
 ! !
 
 
@@ -1929,10 +1943,17 @@
         ^ super displayOn:aGCOrStream
     ].
 
-    aGCOrStream nextPutAll:'ResourcePack for: '.
-    packsClassName printOn:aGCOrStream.
+    aGCOrStream nextPutAll:self class name.
+    packsClassName notNil ifTrue:[
+        aGCOrStream nextPutAll:' for: '.
+        packsClassName printOn:aGCOrStream.
+    ] ifFalse:[
+        aGCOrStream nextPutAll:' from: '.
+        packsFileName printOn:aGCOrStream.
+    ].
 
     "Modified: / 22-02-2017 / 17:00:31 / cg"
+    "Modified: / 27-03-2019 / 11:14:05 / Claus Gittinger"
 ! !
 
 !ResourcePack methodsFor:'statistics'!