author | Stefan Vogel <sv@exept.de> |
Mon, 20 Dec 2010 14:34:54 +0100 | |
changeset 13175 | ea7102cce519 |
parent 12092 | 4e065b823c40 |
child 13364 | ca7da07b8bb2 |
permissions | -rw-r--r-- |
"{ 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 ^ '$Header: /cvs/stx/stx/libbasic/UserMessage.st,v 1.6 2009-10-02 00:08:10 cg Exp $' ! version_CVS ^ '$Header: /cvs/stx/stx/libbasic/UserMessage.st,v 1.6 2009-10-02 00:08:10 cg Exp $' ! !