#REFACTORING by cg
class: ApplicationModel
added:
#information:with:
#information:with:translate:
#information:with:with:
#informationHolder
#informationTranslated:with:with:
#informationUntranslated:
#translateString:with:with:
#translateString:withArguments:
comment/format in: #information:
changed:
#information:translate:
#informationTranslated: (send #informationUntranslated: instead of #information:)
#informationTranslated:with: (send #informationUntranslated: instead of #information:)
#notify:
#translateString:
#warn:translate:
#warn:withArguments:
--- a/ApplicationModel.st Thu Aug 02 17:47:30 2018 +0200
+++ b/ApplicationModel.st Thu Aug 09 15:09:11 2018 +0200
@@ -4112,9 +4112,11 @@
Subclasses may redefine this to use another mechanism"
aString isNil ifTrue:[^ nil].
+ aString isEmpty ifTrue:[^ ''].
^ self resources stringWithCRs:aString
"Modified: / 27-02-2017 / 13:50:46 / cg"
+ "Modified: / 09-08-2018 / 15:09:00 / Claus Gittinger"
!
translateString:aString with:anArgument
@@ -4125,6 +4127,26 @@
^ self resources stringWithCRs:aString with:anArgument
"Created: / 25-11-2016 / 09:54:32 / cg"
+!
+
+translateString:aString with:argument1 with:argument2
+ "translate aString to the current language.
+ We use the resources as default.
+ Subclasses may redefine this to use another mechanism"
+
+ ^ self resources stringWithCRs:aString with:argument1 with:argument2
+
+ "Created: / 09-08-2018 / 15:08:11 / Claus Gittinger"
+!
+
+translateString:aString withArguments:anArgumentVector
+ "translate aString to the current language.
+ We use the resources as default.
+ Subclasses may redefine this to use another mechanism"
+
+ ^ self resources stringWithCRs:aString withArguments:anArgumentVector
+
+ "Created: / 09-08-2018 / 14:53:55 / Claus Gittinger"
! !
!ApplicationModel methodsFor:'user interaction & notifications'!
@@ -4154,51 +4176,111 @@
"like Object's information, but translates the string via the
resourcePack, thus giving a translated string automatically"
- self information:aString translate:true
+ self informationTranslated:aString
"Created: / 20-05-1998 / 03:48:43 / cg"
"Modified: / 25-11-2016 / 09:55:53 / cg"
- "Modified: / 01-06-2018 / 12:51:23 / Claus Gittinger"
+ "Modified: / 09-08-2018 / 14:51:32 / Claus Gittinger"
!
information:aString translate:aBoolean
"like Object's information, but translates the string via the
resourcePack, thus giving a translated string automatically"
- super information:(aBoolean
- ifTrue:[ (self translateString:(aString?'')) withCRs ]
+ self informationUntranslated:(aBoolean
+ ifTrue:[ self translateString:(aString?'') ]
ifFalse:[ aString ])
"Created: / 01-06-2018 / 12:51:06 / Claus Gittinger"
- "Modified: / 02-08-2018 / 16:42:39 / Claus Gittinger"
+ "Modified: / 09-08-2018 / 14:47:38 / Claus Gittinger"
+!
+
+information:aString with:anArgument
+ "like Object's information, but translates the string via the
+ resourcePack, thus giving a translated string automatically"
+
+ self informationTranslated:aString with:anArgument
+
+ "Created: / 09-08-2018 / 14:50:55 / Claus Gittinger"
+!
+
+information:aString with:anArgument translate:aBoolean
+ "like Object's information, but translates the string via the
+ resourcePack, thus giving a translated string automatically"
+
+ self informationUntranslated:
+ (aBoolean
+ ifTrue:[ self translateString:(aString?'') with:anArgument ]
+ ifFalse:[ aString ])
+
+ "Created: / 09-08-2018 / 14:51:06 / Claus Gittinger"
+!
+
+information:aString with:argument1 with:argument2
+ "like Object's information, but translates the string via the
+ resourcePack, thus giving a translated string automatically"
+
+ self informationTranslated:aString with:argument1 with:argument2
+
+ "Created: / 09-08-2018 / 15:07:28 / Claus Gittinger"
+!
+
+informationHolder
+ "applications which want to show this in some info-area at the bottom
+ should redefine this to return a value holder or action-block"
+
+ ^ [:infoUntranslated | super information:infoUntranslated]
+
+ "Created: / 09-08-2018 / 14:48:45 / Claus Gittinger"
!
informationTranslated:aString
"like Object's information, but translates the string via the
resourcePack, thus giving a translated string automatically"
- self information:(self translateString:aString)
+ self informationUntranslated:(self translateString:aString)
"Created: / 25-11-2016 / 09:59:47 / cg"
+ "Modified: / 09-08-2018 / 14:47:41 / Claus Gittinger"
!
informationTranslated:aString with:anArgument
"like Object's information, but translates the string via the
resourcePack, thus giving a translated string automatically"
- self information:(self translateString:aString with:anArgument)
+ self informationUntranslated:(self translateString:aString with:anArgument)
"Created: / 25-11-2016 / 10:01:32 / cg"
+ "Modified: / 09-08-2018 / 14:47:45 / Claus Gittinger"
+!
+
+informationTranslated:aString with:argument1 with:argument2
+ "like Object's information, but translates the string via the
+ resourcePack, thus giving a translated string automatically"
+
+ self informationUntranslated:(self translateString:aString with:argument1 with:argument2)
+
+ "Created: / 09-08-2018 / 15:07:50 / Claus Gittinger"
+!
+
+informationUntranslated:aString
+ "applications which want to show this in some info-area at the bottom
+ may redefine this or the informationHolder message."
+
+ self informationHolder value:aString
+
+ "Created: / 09-08-2018 / 14:47:06 / Claus Gittinger"
!
notify:aString
"like Object's notify, but translates the string via the
resourcePack, thus giving a translated string automatically"
- super notify:(self translateString:aString) withCRs
-
- "Created: / 20.5.1998 / 01:14:52 / cg"
- "Modified: / 13.11.2001 / 20:10:12 / cg"
+ super notify:(self translateString:aString)
+
+ "Created: / 20-05-1998 / 01:14:52 / cg"
+ "Modified: / 13-11-2001 / 20:10:12 / cg"
+ "Modified: / 09-08-2018 / 14:52:27 / Claus Gittinger"
!
openDocumentationFile:aFilename
@@ -4243,8 +4325,10 @@
resourcePack, thus giving a translated string automatically"
super warn:(aBoolean
- ifTrue:[ (self translateString:aString) withCRs ]
+ ifTrue:[ (self translateString:aString) ]
ifFalse:[ aString ]).
+
+ "Modified: / 09-08-2018 / 14:52:46 / Claus Gittinger"
!
warn:aString with:arg
@@ -4286,9 +4370,11 @@
translatedString := self translateString:aString.
stream := TextStream on:(translatedString species new:translatedString size + (argArray size * 10)).
- translatedString withCRs expandPlaceholdersWith:argArray on:stream.
+ translatedString expandPlaceholdersWith:argArray on:stream.
self warn:(stream contents) translate:false.
+
+ "Modified: / 09-08-2018 / 14:53:11 / Claus Gittinger"
!
withCursor:aCursor do:aBlock