eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'UserMessage':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: UserMessage


Inheritance:

   Object
   |
   +--UserMessage

Package:
stx:libbasic
Category:
Interface-Internationalization
Version:
rev: 1.16 date: 2019/02/13 18:36:14
user: cg
file: UserMessage.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


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 or a package.
I.e.
    (YesNoBox classResources string:'continue')

can now also be written as:
    (#continue << YesNoBox) asString
    (#continue << #YesNoBox >> 'Continue really') asString

or, via the package as:
    (#continue << #stx:libwidg) asString

If there is no such catalog, or the key is not found, either the default message is generated:    
    (#continue << #foo >> 'Continue really') asString

or, if there is no default, the key itself is returned:
    (#continue << #foo) asString


Class protocol:

instance creation
o  key: aKeySymbol catalogID: aCatalogSymbol

o  key: aKeySymbol defaultString: aString


Instance protocol:

Compatibility-V'Age
o  bindWith: aString
return a copy of the receiver, where a '%1' escape is
replaced by aString.
This has been added for VisualAge compatibility.

usage example(s):

     'do you like %1 ?' bindWith:'smalltalk'

o  bindWith: string1 with: string2
return a copy of the receiver, where a '%1' escape is
replaced by string1 and '%2' is replaced by string2.
This has been added for VisualAge compatibility.

usage example(s):

     'do you prefer %1 or rather %2 ?'
	bindWith:'smalltalk' with:'c++'

o  bindWith: str1 with: str2 with: str3
return a copy of the receiver, where a '%1', '%2' and '%3' escapes
are replaced by str1, str2 and str3 respectively.
This has been added for VisualAge compatibility.

usage example(s):

     'do you prefer %1 or rather %2 (not talking about %3) ?'
	bindWith:'smalltalk' with:'c++' with:'c'

o  bindWith: str1 with: str2 with: str3 with: str4
return a copy of the receiver, where a '%1', '%2', '%3' and '%4' escapes
are replaced by str1, str2, str3 and str4 respectively.
This has been added for VisualAge compatibility.

usage example(s):

     'do you prefer %1 or rather %2 (not talking about %3 or even %4) ?'
	bindWith:'smalltalk' with:'c++' with:'c' with:'assembler'

o  bindWith: str1 with: str2 with: str3 with: str4 with: str5
return a copy of the receiver, where a '%1' .. '%5' escapes
are replaced by str1 .. str5 respectively.
This has been added for VisualAge compatibility.

o  bindWith: str1 with: str2 with: str3 with: str4 with: str5 with: str6
return a copy of the receiver, where a '%1' .. '%6' escapes
are replaced by str1 .. str6 respectively.
This has been added for VisualAge compatibility.

o  bindWith: str1 with: str2 with: str3 with: str4 with: str5 with: str6 with: str7
return a copy of the receiver, where a '%1' .. '%7' escapes
are replaced by str1 .. str7 respectively.
This has been added for VisualAge compatibility.

o  bindWithArguments: argumentsCollection
return a copy of the receiver, where a '%i' escape
is replaced by the corresponding string from the argument array.
'i' may be between 1 and 9 (i.e. a maximum of 9 placeholders is allowed),
or %(key); the argumentsCollection must then be a dictionary.
To get an integer-indexed placeHolder followed by another digit,
or an index > 9, you must use %(digit).
This has been added for VisualAge compatibility.

usage example(s):

     'do you prefer %1 or rather %2 (not talking about %3) ?'
        bindWithArguments:#('smalltalk' 'c++' 'c')

     'do you %(what) ?'
        bindWithArguments:(Dictionary new at:#'what' put:'understand'; yourself)

accessing
o  catalogID

o  catalogID: aCatalogSymbol

o  defaultString

o  defaultString: aString

o  key

o  key: aKeySymbol

o  key: aKeySymbol catalogID: aCatalogSymbol

o  key: aKeySymbol defaultString: aString

converting
o  asString
convert the user message to a string.
If there us no mapping for the user message -
for now: return the defaultString, ignoring the catalogID.

o  string

printing & storing
o  displayOn: aStream
what a kludge - Dolphin and Squeak mean: printOn: a stream;

o  printOn: aStream

special string converting
o  expandMacros

o  expandMacrosWith: arg1

o  expandPlaceholdersWith: argArrayOrDictionary

o  expandPlaceholdersWith: argArrayOrDictionary on: aStream

o  withCRs

utilities
o  << aSymbol
set the catalogID

o  >> aString
set the default string

usage example(s):

     (#theFooMessage << #myMessages >> 'cannot read subclass of metaclass') 

o  lookupInMessageCatalog
catalogID may be a block


Examples:


Use a class as catalog:
        self warn:(#continue << YesNoBox) asString
Use a class name as catalog:
        self warn:(#continue << #YesNoBox) asString
Some default text if the symbol is not present in the catalog:
        self warn:(#continue << #YesNoBox >> 'Default for continue') asString.
        self warn:(#continueRRRRRRR << #YesNoBox >> 'Default for continue') asString
Here we inherit from the top catalog:
        self information:(Time now printStringFormat:(#TIMEFORMAT << self >> 'Resolved via default %h:%m:%s') asString)
Can also use a package's catalog:
        self information:((#'WARN_RENAME' << #'stx:libtool' ) 
                          withCRs bindWith:'ARG1' with:'ARG2')
Lazy resolving the catalog in a block (if you generate the messages at startup and want to recognize language changes):
        self information:((#'WARN_RENAME' << [ Tools::NewSystemBrowser classResources ] ) 
                          withCRs bindWith:'ARG1' with:'ARG2')


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Wed, 10 Aug 2022 11:04:10 GMT