ResourcePack.st
changeset 8226 adf1e33ba70d
parent 7931 008b8b3ec14e
child 8428 c9c7226373a5
--- a/ResourcePack.st	Fri Nov 24 13:59:27 2017 +0100
+++ b/ResourcePack.st	Mon Nov 27 15:33:55 2017 +0100
@@ -835,130 +835,132 @@
 localAt:aKey
     "translate a string.
      Some special 'intelligence' has been added:
-	if no value for aKey is found,
-	  lookup aKey with first character caseChanged and change the results first characters case.
-	  or aKey is '(...)', then lookup ... wrap () around the result.
-	  or aKey is '[...]', then lookup ... wrap [] around the result.
-	  or aKey is '{...}', then lookup ... wrap {} around the result.
-	  or aKey starts with a '\', then lookup aKey without '\' and prepend '\' to the result.
-	  or aKey ends with a '\', then lookup aKey without '\' and append '\' to the result.
-	  or aKey ends with a ':', then lookup aKey without ':' and append ':' to the result.
-	  or aKey ends with a '=', then lookup aKey without '=' and append '=' to the result.
-	  or aKey ends with a '.', then lookup aKey without '.' and append '.' to the result.
-	  or aKey ends with a ',', then lookup aKey without ',' and append ',' to the result.
-	  or aKey ends with a '?', then lookup aKey without '?' and append '?' to the result.
-	  or aKey ends with a '!!', then lookup aKey without '!!' and append '!!' to the result.
-	  or aKey ends with a ' ', then lookup aKey without ' ' and append ' ' to the result.
-	  or aKey ends with a ' ...', then lookup aKey without ' ...' and append '...' to the result.
-	  or aKey ends with a '...', then lookup aKey without '...' and append '...' to the result.
-	  or aKey includes '&', then lookup aKey without '&'.
+        if no value for aKey is found,
+          lookup aKey with first character caseChanged and change the results first characters case.
+          or aKey is '(...)', then lookup ... wrap () around the result.
+          or aKey is '[...]', then lookup ... wrap [] around the result.
+          or aKey is '{...}', then lookup ... wrap {} around the result.
+          or aKey starts with a '\', then lookup aKey without '\' and prepend '\' to the result.
+          or aKey starts with a '*', then lookup aKey without '*' and prepend '*' to the result.
+          or aKey ends with a '\', then lookup aKey without '\' and append '\' to the result.
+          or aKey ends with a ':', then lookup aKey without ':' and append ':' to the result.
+          or aKey ends with a '=', then lookup aKey without '=' and append '=' to the result.
+          or aKey ends with a '.', then lookup aKey without '.' and append '.' to the result.
+          or aKey ends with a ',', then lookup aKey without ',' and append ',' to the result.
+          or aKey ends with a '?', then lookup aKey without '?' and append '?' to the result.
+          or aKey ends with a '!!', then lookup aKey without '!!' and append '!!' to the result.
+          or aKey ends with a '*', then lookup aKey without '*' and append '*' to the result.
+          or aKey ends with a ' ', then lookup aKey without ' ' and append ' ' to the result.
+          or aKey ends with a ' ...', then lookup aKey without ' ...' and append '...' to the result.
+          or aKey ends with a '...', then lookup aKey without '...' and append '...' to the result.
+          or aKey includes '&', then lookup aKey without '&'.
 
      This means, that only a single translation is required to provide local translations for
      things like
-	'search'
-	'search:'
-	'search...'
+        'search'
+        'search:'
+        'search...'
     "
 
     |val alternativeKey usedKey idx first last|
 
     val := super at:aKey ifAbsent:nil.
     val notNil ifTrue:[
-	^ val value
+        ^ val value
     ].
 
     (aKey isString and:[aKey notEmpty]) ifTrue:[
-	first := aKey first.
-	last := aKey last.
+        first := aKey first.
+        last := aKey last.
 
-	"/ try with case-first swapped...
-	first isLetter ifTrue:[
-	    alternativeKey := first isUppercase
-				ifTrue:[aKey asLowercaseFirst]
-				ifFalse:[aKey asUppercaseFirst].
-	    val := super at:alternativeKey ifAbsent:nil.
-	    val notNil ifTrue:[
-		first isUppercase ifTrue:[
-		    ^ val asUppercaseFirst
-		].
-		^ val asLowercaseFirst.
-	    ].
-	].
+        "/ try with case-first swapped...
+        first isLetter ifTrue:[
+            alternativeKey := first isUppercase
+                                ifTrue:[aKey asLowercaseFirst]
+                                ifFalse:[aKey asUppercaseFirst].
+            val := super at:alternativeKey ifAbsent:nil.
+            val notNil ifTrue:[
+                first isUppercase ifTrue:[
+                    ^ val asUppercaseFirst
+                ].
+                ^ val asLowercaseFirst.
+            ].
+        ].
 
-	((first == $( and:[last == $) ])
-	or:[ (first == $[ and:[last == $] ])
-	or:[ (first == ${ and:[last == $} ]) ]]) ifTrue:[
-	    usedKey := aKey copyFrom:2 to:aKey size-1.
+        ((first == $( and:[last == $) ])
+        or:[ (first == $[ and:[last == $] ])
+        or:[ (first == ${ and:[last == $} ]) ]]) ifTrue:[
+            usedKey := aKey copyFrom:2 to:aKey size-1.
 
-	    val := self localAt:usedKey.        "/ recursion
-	    val notNil ifTrue:[^ first asString,val,last asString].
-	].
+            val := self localAt:usedKey.        "/ recursion
+            val notNil ifTrue:[^ first asString,val,last asString].
+        ].
 
-	last == $. ifTrue:[
-	    (aKey endsWith:' ...') ifTrue:[
-		usedKey := aKey copyButLast:4.
+        last == $. ifTrue:[
+            (aKey endsWith:' ...') ifTrue:[
+                usedKey := aKey copyButLast:4.
 
-		val := self localAt:usedKey.        "/ recursion
-		val notNil ifTrue:[^ val , ' ...'].
-	    ].
-	    (aKey endsWith:'...') ifTrue:[
-		usedKey := aKey copyButLast:3.
+                val := self localAt:usedKey.        "/ recursion
+                val notNil ifTrue:[^ val , ' ...'].
+            ].
+            (aKey endsWith:'...') ifTrue:[
+                usedKey := aKey copyButLast:3.
 
-		val := self localAt:usedKey.        "/ recursion
-		val notNil ifTrue:[^ val , '...'].
-	    ].
-	].
+                val := self localAt:usedKey.        "/ recursion
+                val notNil ifTrue:[^ val , '...'].
+            ].
+        ].
 
-	first isSeparator ifTrue:[
-	    usedKey := aKey withoutLeadingSeparators.
+        first isSeparator ifTrue:[
+            usedKey := aKey withoutLeadingSeparators.
 
-	    val := self localAt:usedKey.        "/ recursion
-	    val notNil ifTrue:[^ (aKey copyTo:(aKey size - usedKey size)), val]. "/ prepend the stripped separators
-	].
-	last isSeparator ifTrue:[
-	    usedKey := aKey withoutTrailingSeparators.
+            val := self localAt:usedKey.        "/ recursion
+            val notNil ifTrue:[^ (aKey copyTo:(aKey size - usedKey size)), val]. "/ prepend the stripped separators
+        ].
+        last isSeparator ifTrue:[
+            usedKey := aKey withoutTrailingSeparators.
 
-	    val := self localAt:usedKey.        "/ recursion
-	    val notNil ifTrue:[^ val, (aKey copyFrom:usedKey size + 1)].      "/ append the stripped separators
-	].
+            val := self localAt:usedKey.        "/ recursion
+            val notNil ifTrue:[^ val, (aKey copyFrom:usedKey size + 1)].      "/ append the stripped separators
+        ].
 
-	('*:=.?!!,-><\' includes:last) ifTrue:[
-	    aKey size >= 2 ifTrue:[
-		usedKey := aKey copyButLast:1.
+        ('*:=.?!!,-><\' includes:last) ifTrue:[
+            aKey size >= 2 ifTrue:[
+                usedKey := aKey copyButLast:1.
 
-		val := self localAt:usedKey.        "/ recursion
-		val notNil ifTrue:[^ val copyWith:last].
-	    ].
-	].
-	('*:=.?!!-><\' includes:first) ifTrue:[
-	    aKey size >= 2 ifTrue:[
-		usedKey := aKey copyFrom:2.
+                val := self localAt:usedKey.        "/ recursion
+                val notNil ifTrue:[^ val copyWith:last].
+            ].
+        ].
+        ('*:=.?!!-><\' includes:first) ifTrue:[
+            aKey size >= 2 ifTrue:[
+                usedKey := aKey copyButFirst:1.
 
-		val := self localAt:usedKey.        "/ recursion
-		val notNil ifTrue:[^ first asString , val].
-	    ].
-	].
+                val := self localAt:usedKey.        "/ recursion
+                val notNil ifTrue:[^ first asString , val].
+            ].
+        ].
 
-	(first == $( and:[last == $)]) ifTrue:[
-	    usedKey := aKey copyFrom:2 to:(aKey size - 1).
+        (first == $( and:[last == $)]) ifTrue:[
+            usedKey := aKey copyFrom:2 to:(aKey size - 1).
 
-	    val := self localAt:usedKey.        "/ recursion
-	    val notNil ifTrue:[^ '(' , val , ')'].
-	].
+            val := self localAt:usedKey.        "/ recursion
+            val notNil ifTrue:[^ '(' , val , ')'].
+        ].
 
-	(idx := aKey indexOf:$&) ~~ 0 ifTrue:[
-	    (aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[
-		usedKey := (aKey copyTo:idx-1) , (aKey copyFrom:idx+1).
-		val := self localAt:usedKey.    "/ recursion
-		val notNil ifTrue:[^ val].
-	    ].
-	].
+        (idx := aKey indexOf:$&) ~~ 0 ifTrue:[
+            (aKey at:idx+1 ifAbsent:nil) ~~ $& ifTrue:[
+                usedKey := (aKey copyTo:idx-1) , (aKey copyFrom:idx+1).
+                val := self localAt:usedKey.    "/ recursion
+                val notNil ifTrue:[^ val].
+            ].
+        ].
     ].
     ^ nil.
 
     "Created: / 18-09-2006 / 17:33:27 / cg"
-    "Modified: / 21-08-2007 / 21:18:12 / cg"
     "Modified: / 05-08-2010 / 16:52:32 / sr"
+    "Modified: / 27-11-2017 / 15:33:48 / cg"
 !
 
 name:aKey default:default