UserMessage.st
author Claus Gittinger <cg@exept.de>
Mon, 10 Dec 2001 17:30:04 +0100
changeset 6267 10016cc16511
parent 6117 013cab950016
child 6591 586fb5c604ba
permissions -rw-r--r--
pass name of API/C wrap function

"{ 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

! !

!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
    |class str|

    "/ for now - only handle the case that the catalogID is
    "/ a classes name; in that case, ask its resourcePack.

    class := Smalltalk at:catalogID.
    class notNil ifTrue:[
        ^ class classResources string:key default:defaultString
    ].
    ^ nil

    "
     (#'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 )
    "
! !

!UserMessage class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/UserMessage.st,v 1.3 2001-10-26 08:12:18 cg Exp $'
! !