# HG changeset patch # User Claus Gittinger # Date 1573764256 -3600 # Node ID 2c48933f35cba2e10e447974ec1cb1b6f1e72717 # Parent a2f591cb84051cb58a107b3ffad64a7b49048add #FEATURE by exept class: ShowMeHowItWorks class definition added: #pronounce:as: #translate: removed: #possiblyTranslate: comment/format in: #showing:saying:do: changed: #doStream:from: class: ShowMeHowItWorks class added: #example2 comment/format in: #example diff -r a2f591cb8405 -r 2c48933f35cb ShowMeHowItWorks.st --- a/ShowMeHowItWorks.st Thu Nov 14 12:22:17 2019 +0100 +++ b/ShowMeHowItWorks.st Thu Nov 14 21:44:16 2019 +0100 @@ -8,7 +8,7 @@ instanceVariableNames:'application opStream streamStack lastComponentName lastComponent lastResult voice translate language verifying closeApplicationWhenFinished defaultComponentWaitTime ui - theShowFile defaultElementTimeout applicationStack' + theShowFile defaultElementTimeout applicationStack pronunciations' classVariableNames:'IntroShownCount DebugMode StartLabel' poolDictionaries:'' category:'Interface-Help' @@ -57,7 +57,25 @@ (showing: 'Enter a value (or expression) into "receiver" field' do:( enter: '100' )) - + ) +! + +example2 + ShowMeHowItWorks do:#( + language: 'de' + (pronounce:'feature' as:'fiedscher') + (pronounce:'suite' as:'swied') + (pronounce:'expecco' as:'expecko') + (pronounce:'read me' as:'ried mie') + (pronounce:'python' as:'paiton') + (pronounce:'jenkins' as:'dschengkins') + show:'jenkins' + show:'dies ist ein neues feature' + show:'suite' + show:'expecco' + show:'read me' + show:'python' + show:'node' ) ! @@ -329,6 +347,15 @@ application := applicationStack removeLast. ! +pronounce:word as:pronunciation + + + pronunciations isNil ifTrue:[ + pronunciations := OrderedDictionary new. + ]. + pronunciations at:word put:pronunciation +! + pushApplication:newApplicationOrName @@ -493,6 +520,14 @@ |sentence| sentence := (sentenceOrNil ? xLatedMessage) copy withCRs replaceAny:c'\t' with:(Character space). sentence := sentence copy withCRs replaceAny:c'\n\r' with:(Character space). + sentence := sentence asLowercase. + pronunciations notNil ifTrue:[ + pronunciations keysAndValuesDo:[:word :pronounced | + (sentence includesString:word) ifTrue:[ + sentence := sentence copyReplaceString:word withString:pronounced + ] + ] + ]. self tell:sentence. talkDone signal ] fork. @@ -2414,13 +2449,13 @@ Display shiftDown ifTrue:[ (IntroShownCount ? 0) > 3 ifFalse:[ - self tell:(self class classResources string:'You pressed the SHIFT key.'). + self tell:(self translate:'You pressed the SHIFT key.'). ]. - self tell:(self class classResources string:'Do you want to stop the show?'). + self tell:(self translate:'Do you want to stop the show?'). (Dialog confirm:(resources stringWithCRs:'Stop the demonstration?')) ifTrue:[ - self tell:(self possiblyTranslate:'OK,'). - self tell:(self class classResources string:(self randomThankYou)). + self tell:(self translate:'OK,'). + self tell:(self translate:(self randomThankYou)). ^ AbortOperationRequest raise ]. ]. @@ -2462,14 +2497,8 @@ "Modified: / 23-07-2019 / 11:48:45 / Claus Gittinger" ! -possiblyTranslate:aString - |xLatedMessage| - - translate ifTrue:[ - xLatedMessage := self class classResources stringWithCRs:aString. - ^ xLatedMessage - ]. - ^ aString +translate:aString + ^ self class classResources stringWithCRs:aString. ! ! !ShowMeHowItWorks::ItemInView class methodsFor:'documentation'!