ApplicationModel.st
changeset 4155 406dd6f034d6
parent 4154 3aff5b534471
child 4156 956b7cf8c1be
equal deleted inserted replaced
4154:3aff5b534471 4155:406dd6f034d6
  4110     "translate aString to the current language.
  4110     "translate aString to the current language.
  4111      We use the resources as default.
  4111      We use the resources as default.
  4112      Subclasses may redefine this to use another mechanism"
  4112      Subclasses may redefine this to use another mechanism"
  4113 
  4113 
  4114     aString isNil ifTrue:[^ nil]. 
  4114     aString isNil ifTrue:[^ nil]. 
       
  4115     aString isEmpty ifTrue:[^ '']. 
  4115     ^ self resources stringWithCRs:aString
  4116     ^ self resources stringWithCRs:aString
  4116 
  4117 
  4117     "Modified: / 27-02-2017 / 13:50:46 / cg"
  4118     "Modified: / 27-02-2017 / 13:50:46 / cg"
       
  4119     "Modified: / 09-08-2018 / 15:09:00 / Claus Gittinger"
  4118 !
  4120 !
  4119 
  4121 
  4120 translateString:aString with:anArgument
  4122 translateString:aString with:anArgument
  4121     "translate aString to the current language.
  4123     "translate aString to the current language.
  4122      We use the resources as default.
  4124      We use the resources as default.
  4123      Subclasses may redefine this to use another mechanism"
  4125      Subclasses may redefine this to use another mechanism"
  4124 
  4126 
  4125     ^ self resources stringWithCRs:aString with:anArgument
  4127     ^ self resources stringWithCRs:aString with:anArgument
  4126 
  4128 
  4127     "Created: / 25-11-2016 / 09:54:32 / cg"
  4129     "Created: / 25-11-2016 / 09:54:32 / cg"
       
  4130 !
       
  4131 
       
  4132 translateString:aString with:argument1 with:argument2
       
  4133     "translate aString to the current language.
       
  4134      We use the resources as default.
       
  4135      Subclasses may redefine this to use another mechanism"
       
  4136 
       
  4137     ^ self resources stringWithCRs:aString with:argument1 with:argument2
       
  4138 
       
  4139     "Created: / 09-08-2018 / 15:08:11 / Claus Gittinger"
       
  4140 !
       
  4141 
       
  4142 translateString:aString withArguments:anArgumentVector
       
  4143     "translate aString to the current language.
       
  4144      We use the resources as default.
       
  4145      Subclasses may redefine this to use another mechanism"
       
  4146 
       
  4147     ^ self resources stringWithCRs:aString withArguments:anArgumentVector
       
  4148 
       
  4149     "Created: / 09-08-2018 / 14:53:55 / Claus Gittinger"
  4128 ! !
  4150 ! !
  4129 
  4151 
  4130 !ApplicationModel methodsFor:'user interaction & notifications'!
  4152 !ApplicationModel methodsFor:'user interaction & notifications'!
  4131 
  4153 
  4132 beep
  4154 beep
  4152 
  4174 
  4153 information:aString
  4175 information:aString
  4154     "like Object's information, but translates the string via the
  4176     "like Object's information, but translates the string via the
  4155      resourcePack, thus giving a translated string automatically"
  4177      resourcePack, thus giving a translated string automatically"
  4156 
  4178 
  4157     self information:aString translate:true
  4179     self informationTranslated:aString
  4158 
  4180 
  4159     "Created: / 20-05-1998 / 03:48:43 / cg"
  4181     "Created: / 20-05-1998 / 03:48:43 / cg"
  4160     "Modified: / 25-11-2016 / 09:55:53 / cg"
  4182     "Modified: / 25-11-2016 / 09:55:53 / cg"
  4161     "Modified: / 01-06-2018 / 12:51:23 / Claus Gittinger"
  4183     "Modified: / 09-08-2018 / 14:51:32 / Claus Gittinger"
  4162 !
  4184 !
  4163 
  4185 
  4164 information:aString translate:aBoolean
  4186 information:aString translate:aBoolean
  4165     "like Object's information, but translates the string via the
  4187     "like Object's information, but translates the string via the
  4166      resourcePack, thus giving a translated string automatically"
  4188      resourcePack, thus giving a translated string automatically"
  4167 
  4189 
  4168     super information:(aBoolean
  4190     self informationUntranslated:(aBoolean
  4169                     ifTrue:[ (self translateString:(aString?'')) withCRs ]
  4191                     ifTrue:[ self translateString:(aString?'') ]
  4170                     ifFalse:[ aString ])
  4192                     ifFalse:[ aString ])
  4171 
  4193 
  4172     "Created: / 01-06-2018 / 12:51:06 / Claus Gittinger"
  4194     "Created: / 01-06-2018 / 12:51:06 / Claus Gittinger"
  4173     "Modified: / 02-08-2018 / 16:42:39 / Claus Gittinger"
  4195     "Modified: / 09-08-2018 / 14:47:38 / Claus Gittinger"
       
  4196 !
       
  4197 
       
  4198 information:aString with:anArgument
       
  4199     "like Object's information, but translates the string via the
       
  4200      resourcePack, thus giving a translated string automatically"
       
  4201 
       
  4202     self informationTranslated:aString with:anArgument
       
  4203 
       
  4204     "Created: / 09-08-2018 / 14:50:55 / Claus Gittinger"
       
  4205 !
       
  4206 
       
  4207 information:aString with:anArgument translate:aBoolean
       
  4208     "like Object's information, but translates the string via the
       
  4209      resourcePack, thus giving a translated string automatically"
       
  4210 
       
  4211     self informationUntranslated:
       
  4212             (aBoolean
       
  4213                 ifTrue:[ self translateString:(aString?'') with:anArgument ]
       
  4214                 ifFalse:[ aString ])
       
  4215 
       
  4216     "Created: / 09-08-2018 / 14:51:06 / Claus Gittinger"
       
  4217 !
       
  4218 
       
  4219 information:aString with:argument1 with:argument2
       
  4220     "like Object's information, but translates the string via the
       
  4221      resourcePack, thus giving a translated string automatically"
       
  4222 
       
  4223     self informationTranslated:aString with:argument1 with:argument2
       
  4224 
       
  4225     "Created: / 09-08-2018 / 15:07:28 / Claus Gittinger"
       
  4226 !
       
  4227 
       
  4228 informationHolder
       
  4229     "applications which want to show this in some info-area at the bottom
       
  4230      should redefine this to return a value holder or action-block"
       
  4231      
       
  4232     ^ [:infoUntranslated | super information:infoUntranslated]
       
  4233 
       
  4234     "Created: / 09-08-2018 / 14:48:45 / Claus Gittinger"
  4174 !
  4235 !
  4175 
  4236 
  4176 informationTranslated:aString
  4237 informationTranslated:aString
  4177     "like Object's information, but translates the string via the
  4238     "like Object's information, but translates the string via the
  4178      resourcePack, thus giving a translated string automatically"
  4239      resourcePack, thus giving a translated string automatically"
  4179 
  4240 
  4180     self information:(self translateString:aString)
  4241     self informationUntranslated:(self translateString:aString)
  4181 
  4242 
  4182     "Created: / 25-11-2016 / 09:59:47 / cg"
  4243     "Created: / 25-11-2016 / 09:59:47 / cg"
       
  4244     "Modified: / 09-08-2018 / 14:47:41 / Claus Gittinger"
  4183 !
  4245 !
  4184 
  4246 
  4185 informationTranslated:aString with:anArgument
  4247 informationTranslated:aString with:anArgument
  4186     "like Object's information, but translates the string via the
  4248     "like Object's information, but translates the string via the
  4187      resourcePack, thus giving a translated string automatically"
  4249      resourcePack, thus giving a translated string automatically"
  4188 
  4250 
  4189     self information:(self translateString:aString with:anArgument)
  4251     self informationUntranslated:(self translateString:aString with:anArgument)
  4190 
  4252 
  4191     "Created: / 25-11-2016 / 10:01:32 / cg"
  4253     "Created: / 25-11-2016 / 10:01:32 / cg"
       
  4254     "Modified: / 09-08-2018 / 14:47:45 / Claus Gittinger"
       
  4255 !
       
  4256 
       
  4257 informationTranslated:aString with:argument1 with:argument2
       
  4258     "like Object's information, but translates the string via the
       
  4259      resourcePack, thus giving a translated string automatically"
       
  4260 
       
  4261     self informationUntranslated:(self translateString:aString with:argument1 with:argument2)
       
  4262 
       
  4263     "Created: / 09-08-2018 / 15:07:50 / Claus Gittinger"
       
  4264 !
       
  4265 
       
  4266 informationUntranslated:aString
       
  4267     "applications which want to show this in some info-area at the bottom
       
  4268      may redefine this or the informationHolder message."
       
  4269      
       
  4270     self informationHolder value:aString
       
  4271 
       
  4272     "Created: / 09-08-2018 / 14:47:06 / Claus Gittinger"
  4192 !
  4273 !
  4193 
  4274 
  4194 notify:aString
  4275 notify:aString
  4195     "like Object's notify, but translates the string via the
  4276     "like Object's notify, but translates the string via the
  4196      resourcePack, thus giving a translated string automatically"
  4277      resourcePack, thus giving a translated string automatically"
  4197 
  4278 
  4198     super notify:(self translateString:aString) withCRs
  4279     super notify:(self translateString:aString)
  4199 
  4280 
  4200     "Created: / 20.5.1998 / 01:14:52 / cg"
  4281     "Created: / 20-05-1998 / 01:14:52 / cg"
  4201     "Modified: / 13.11.2001 / 20:10:12 / cg"
  4282     "Modified: / 13-11-2001 / 20:10:12 / cg"
       
  4283     "Modified: / 09-08-2018 / 14:52:27 / Claus Gittinger"
  4202 !
  4284 !
  4203 
  4285 
  4204 openDocumentationFile:aFilename
  4286 openDocumentationFile:aFilename
  4205     HTMLDocumentView notNil ifTrue:[
  4287     HTMLDocumentView notNil ifTrue:[
  4206         HTMLDocumentView 
  4288         HTMLDocumentView 
  4241 warn:aString translate:aBoolean
  4323 warn:aString translate:aBoolean
  4242     "like Object's warn, but optionally translates the string via the
  4324     "like Object's warn, but optionally translates the string via the
  4243      resourcePack, thus giving a translated string automatically"
  4325      resourcePack, thus giving a translated string automatically"
  4244 
  4326 
  4245     super warn:(aBoolean
  4327     super warn:(aBoolean
  4246                     ifTrue:[ (self translateString:aString) withCRs ]
  4328                     ifTrue:[ (self translateString:aString) ]
  4247                     ifFalse:[ aString ]).
  4329                     ifFalse:[ aString ]).
       
  4330 
       
  4331     "Modified: / 09-08-2018 / 14:52:46 / Claus Gittinger"
  4248 !
  4332 !
  4249 
  4333 
  4250 warn:aString with:arg
  4334 warn:aString with:arg
  4251     "like Object's warn, but translates the string via the
  4335     "like Object's warn, but translates the string via the
  4252      resourcePack, thus giving a translated string automatically"
  4336      resourcePack, thus giving a translated string automatically"
  4284 
  4368 
  4285     |translatedString stream|
  4369     |translatedString stream|
  4286 
  4370 
  4287     translatedString := self translateString:aString.
  4371     translatedString := self translateString:aString.
  4288     stream := TextStream on:(translatedString species new:translatedString size + (argArray size * 10)).
  4372     stream := TextStream on:(translatedString species new:translatedString size + (argArray size * 10)).
  4289     translatedString withCRs expandPlaceholdersWith:argArray on:stream.
  4373     translatedString expandPlaceholdersWith:argArray on:stream.
  4290 
  4374 
  4291     self warn:(stream contents) translate:false.
  4375     self warn:(stream contents) translate:false.
       
  4376 
       
  4377     "Modified: / 09-08-2018 / 14:53:11 / Claus Gittinger"
  4292 !
  4378 !
  4293 
  4379 
  4294 withCursor:aCursor do:aBlock
  4380 withCursor:aCursor do:aBlock
  4295     "evaluate aBlock, showing aCursor in my topView and all of its subviews.
  4381     "evaluate aBlock, showing aCursor in my topView and all of its subviews.
  4296      Return the value of aBlock."
  4382      Return the value of aBlock."