This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-01-18 13:09:10

roman64
Scratcher
Registered: 2007-03-26
Posts: 12

Translating keyname German-English

Hello scratcher,

I found a strange in the <when[  ]key pressed> brick.

I start a project in german and use <when[Leertaste]key pressed> to start an action on the <space> key. When I now switch to English, name of the key does not translate.
But: This happens only in the beginning. When I switch then name manually from 'Leertaste' to 'space', the rountine behaves normal.

Why is it a problem?

My son uploaded his first game in SRATCH, where the main character should fight (what else?) when the space bar is pressed. Works fine on local PC, but in online version the sprite reacted on every key (arrow up, left etc) except for the 'space'.
sad

I assume during upload there is also some translation of the keys, which did not work for the 'Leertaste'.

Nevertheless: You doa great Job with Scrtach, both the program and the website.

Roman

Offline

 

#2 2008-01-18 13:19:13

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Translating keyname German-English

Hi Roman,

hmm, I just tried switching the languages back and forth in Scratch using the "when <space> key pressed" block, and everything worked fine for me. Could you perhaps post a link to your son's online-project, so someone might have a look at it?


Jens Mönig

Offline

 

#3 2008-01-20 10:54:20

johnm
Scratcher
Registered: 2007-03-08
Posts: 100+

Re: Translating keyname German-English

Hi, roman64.

I think there is a bug in the translation of key names. I will investigate.

  -- John

Offline

 

#4 2008-01-20 15:10:54

roman64
Scratcher
Registered: 2007-03-26
Posts: 12

Re: Translating keyname German-English

Hi Jens and John,

I made two simple programs to show the bug. When you hit space, the cat should say hello, but it doesn't.

In http://scratch.mit.edu/projects/roman64/84206
I pulled the <when[  ]key pressed> to the programs part of the object and did *not* touch the key selector (because it already shows Leertaste which I want to use).

In the second version
http://scratch.mit.edu/projects/roman64/84209

I selected 'Leertaste' in the pulldown menu of the <when[  ]key pressed>. This one works. I cannot see any difference in the programs, when I look on them in scratch. Hopefully the gurus can.

Seems to be a problem with the initial value/name of the selected key.

Roman

OT: Gruß nach Herrenberg, wir sind in S-Feuerbach.

Offline

 

#5 2008-01-21 02:54:35

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Translating keyname German-English

Hi Roman,

I've had a look at your two projects. It seems you've discovered a genuine bug in Scratch, resulting out of the key-pressed event hat's initial state. Since John's already investigating it help is already on the way. Thanks for posting this!


Jens Mönig

Offline

 

#6 2008-01-21 09:14:57

johnm
Scratcher
Registered: 2007-03-08
Posts: 100+

Re: Translating keyname German-English

Hi, Roman.

Which version of Scratch did you use to create those projects? (You can find the version by clicking on the "extras" button and selecting "about...")

There was a bug in Scratch 1.2 involving the translation of named keys (space and arrow keys) that was fixed in Scratch 1.2.1. So if are still using Scratch 1.2, just download the latest version and the problem should disappear. (If you are running on Windows, you can just download and run the Scratch installer.)

You may need to open projects that use named keys in the new version of Scratch, re-select the key from the pull-down menu, and save them again.

Let me know if this fixes your problems.

  -- John

Offline

 

#7 2008-01-21 16:02:15

roman64
Scratcher
Registered: 2007-03-26
Posts: 12

Re: Translating keyname German-English

Hi John,

can you reproduce the bug in the two online versions of my example ?

My installation is "Scratch 1.2.1 (6-Dec-07)". The scratch.image file is from 06-12-2007, 17:47.

I downloaded the 'files only' version and unzipped the entire archive to my default programs folder. The subdirectory structure was maintained. As default, Scratch is started in German. Platform is Windows XP Home (german), Java version is 1.6.0.

Meanwhile I tested switching the language of Scratch on an untouched "If key pressed" hat in other languages and found the "space"-bug also in e.g. italian, spanish, dutch, catalan. I suppose this behaviour of the IDE and the online version is somehow related.

After all, for me the bug is not severe, because a simple work around is to click the 'when key pressed' hat and confirm the key name 'Leertaste' manually. Then everything seems to work.
But I am afraid, beginners might be confused, why to do this, when the brick already shows the key name they want to use.

Good luck for scratching
Roman

Offline

 

#8 2008-01-21 20:59:25

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Translating keyname German-English

roman64, as I understand it, the bug in the earlier version is stored in the .sb file, so that the new version of scratch will see the problem if the .sb file is old.

The right fix is for the scratch interpreter to fix up buggy .sb files, but that apparently was not done in v1.2.1.  (Maybe in v1.3?)

Do you have any .sb files created by v1.2.1 that have the bug?

Offline

 

#9 2008-01-22 03:51:22

roman64
Scratcher
Registered: 2007-03-26
Posts: 12

Re: Translating keyname German-English

The two minimalistic examples (see previous post) are entirely done with my current 1.2.1. installation. New Project -> dragging two bricks -> share, nothing complicated.

The difference between the two is that in V1 I took the 'when key pressed' hat from the shelf and did not touch the key name selector. Result: Does not work online, does not translate local

In V2 I clicked the 'key name selector' of the brick and confirmed 'Leertaste'. Result: Works online, translates local.

I can reproduce this behaviour in my installation in german as well as in e.g. italian or spanish language setting.

As mentioned earlier: I assume the bug is not the translation itself, but a 'not completly correct' initialisation of the hat when dragged from the shelf and Scratch is in one of these strange, foreign, old europe languages like german  wink  (wild guess: setting of the 'key name' attribute during creation of the object in squeak ?). This seems to be corrected, when the key name selector is touched.
Somehow the internal status of the brick is different, when dragged from the repository to the script area, showing 'Leertaste' and setting the key name via the selector to 'Leertaste', which is not obvious for an unexperienced user.

Happy scratching
Roman

Offline

 

#10 2008-01-22 06:54:23

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Translating keyname German-English

Hi John,

I think it's a real bug in the 'initialize' method of 'KeyEventHatMorph'. There is a cascade that goes:

Code:

    scriptNameMorph _ ChoiceArgMorph new getOptionsSelector: #keyNames;
             options: ScriptableScratchMorph new keyNames;
             choice: 'space' localized.

The problem here is that the 'space'-string is translated before it is assigned. However the receiving ChoiceArgMorph needs to get and keep <choice> in generic English internally, producing its own separate, translated copy for display in the labelMorph afterwards.

When I just remove the keyword "localized" everything works as expected again, both in Squeak and in the java player, it also fixes the re-translation issue of otherwise untouched KeyEventHatMorphs that Roman observed.


Jens Mönig

Offline

 

#11 2008-01-22 15:13:09

roman64
Scratcher
Registered: 2007-03-26
Posts: 12

Re: Translating keyname German-English

I have the feeling, you translated my words directly to Smalltalk/Squeak.
Hopefully the 'key pressed' block is the only one, which suffers from this glitch.

Roman

Offline

 

#12 2008-01-23 07:00:26

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Translating keyname German-English

roman64 wrote:

I have the feeling, you translated my words directly to Smalltalk/Squeak.

Yup, that's the beauty of it  smile


Jens Mönig

Offline

 

#13 2008-01-25 04:22:49

roman64
Scratcher
Registered: 2007-03-26
Posts: 12

Re: Translating keyname German-English

[blocks]
The <key[Leertaste]pressed?> block from the Sensing group seems to have the same bug. It does not translate if untouched.

Roman

[/blocks]

Offline

 

#14 2008-01-25 06:51:20

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Translating keyname German-English

Aha, this one's a bit harder to find. It seems to be a bug in the 'defaultArgsFor: blockSpec' method of 'ScriptableScratchMorph'. Somewhere in that method it says:

Code:

#keyPressed: = sel ifTrue: [defaultArgs _ Array with: 'space' localized].

again, the the 'localized' keyword shouldn't be there, because the argument will eventually be translated within the ChoiceArgMorph itself, and needs to be kept in English internally.

Thanks for checking this, Roman!


Jens Mönig

Offline

 

Board footer