UserMessage.st
author Claus Gittinger <cg@exept.de>
Fri, 07 Sep 2001 17:58:03 +0200
changeset 5996 df75959d85f3
child 6008 7ac30515dddc
permissions -rw-r--r--
initial checkin

"{ Package: 'stx:libview' }"

Object subclass:#UserMessage
	instanceVariableNames:'defaultString key catalogID'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Internationalization'
!


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

!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.1 2001-09-07 15:58:03 cg Exp $'
! !