"{ Package: 'stx:libbasic' }"
Object subclass:#UserMessage
instanceVariableNames:'defaultString key catalogID'
classVariableNames:''
poolDictionaries:''
category:'Interface-Internationalization'
!
!UserMessage class methodsFor:'documentation'!
documentation
"
added for vw5i compatibility, which accesses messageCatalogs
via:
(#key << #catalogID >> 'defaultMessage')
which creates an instance of UserMessage.
Currently, this is a dummy operation in ST/X, however it is mapped onto
the resource mechanism, if the given catalogID is the name of a class;
i.e.
(YesNoBox classResources string:'continue')
can now also be written as:
(#continue << #YesNoBox)
"
! !
!UserMessage class methodsFor:'instance creation'!
key:aKeySymbol catalogID:aCatalogSymbol
^ self new key:aKeySymbol catalogID:aCatalogSymbol
!
key:aKeySymbol defaultString:aString
^ self new key:aKeySymbol defaultString:aString
! !
!UserMessage methodsFor:'accessing'!
catalogID
^ catalogID
!
catalogID:aCatalogSymbol
catalogID := aCatalogSymbol
!
defaultString
^ defaultString
!
defaultString:aString
defaultString := aString
!
key
^ key
!
key:aKeySymbol
key := aKeySymbol.
!
key:aKeySymbol catalogID:aCatalogSymbol
key := aKeySymbol.
catalogID := aCatalogSymbol
!
key:aKeySymbol defaultString:aString
key := aKeySymbol.
defaultString := aString
! !
!UserMessage methodsFor:'converting'!
asString
"for now: return the defaultString, ignoring the catalogID."
|str|
str := self lookupInMessageCatalog.
str notNil ifTrue:[ ^ str ].
defaultString notNil ifTrue:[
^ defaultString
].
^ key asString
!
expandMacros
^ self asString expandMacros
!
expandMacrosWith:arg1
^ self asString expandMacrosWith:arg1
!
string
^ self asString
! !
!UserMessage methodsFor:'printing & storing'!
displayString
|stream|
stream := '' writeStream.
key storeOn:stream.
stream nextPutAll:' << '.
catalogID storeOn:stream.
defaultString notNil ifTrue:[
stream nextPutAll:' >> '.
defaultString storeOn:stream.
].
^ stream contents.
! !
!UserMessage methodsFor:'utilities'!
<< aSymbol
"set the catalogID"
self catalogID:aSymbol
!
>> aString
"set the default string"
self defaultString:aString
"
(#theFooMessage << #myMessages >> 'cannot read subclass of metaclass')
"
!
lookupInMessageCatalog
|messageCatalog|
"/ for now - handle the case that the catalogID is
"/ a classes name; in that case, ask its resourcePack.
catalogID isSymbol ifTrue:[
messageCatalog := Smalltalk at:catalogID.
] ifFalse:[
messageCatalog := catalogID.
].
messageCatalog isBehavior ifTrue:[
messageCatalog := messageCatalog classResources.
].
messageCatalog isNil ifTrue:[
defaultString isNil ifTrue:[
^ 'Non-existant message (%1<<%2)' bindWith:key with:catalogID printString.
].
^ defaultString.
].
^ messageCatalog at:key ifAbsent:defaultString.
"
(#'WARN_RENAME' << #BrowserView >> 'A class named %1 already exists (in ''%2'')\\that class will no longer be visible (i.e. removed) if you continue.\\Continue ?' )
(#'WARN_RENAME' << #BrowserView)
(#'WARN_RENAME' << BrowserView classResources)
(#dontKnow << #nonExistantMessageCatalog) asString
"
! !
!UserMessage class methodsFor:'documentation'!
version
^ '$Id: UserMessage.st 10480 2009-12-02 21:30:55Z vranyj1 $'
!
version_CVS
^ '§Header: /cvs/stx/stx/libbasic/UserMessage.st,v 1.6 2009/10/02 00:08:10 cg Exp §'
! !