Replace words in coder for translation

160 views
Skip to first unread message

flo.jul...@gmail.com

unread,
Mar 20, 2014, 6:28:05 AM3/20/14
to psychop...@googlegroups.com
Dear All,

for the reason that I have to translate my experiment in different languages, I have to change all the rating scale words into another language. Because I use 35 different rating scales, replacing them all by hand takes a long time.

So my question is: Is there a REPLACE FUNCTION in the coder of Psychopy? So for example that the coder replaces every written word (beruhigend) into (soothing)?

I tried it with this python command, but it didn't work:
str.replace(beruhigend, soothing)

I also tried this one:

str = "beruhigend";
print str.replace("beruhigend", "soothing");


Thanks and best regards,

Florian

Jonathan Peirce

unread,
Mar 20, 2014, 7:01:29 AM3/20/14
to psychop...@googlegroups.com
I'm afraid I never got around to adding find...replace into the coder.
Workarounds:
    - in Coder using Ctrl-G (find next) and Ctrl-V (paste) you can paste a replacement pretty quickly
    - open your file in some other editor (python files are plain text) and do the find/replace there

To replace text using code (e.g. during a run) I wonder if it's just that you used the name `str` for your variable. str is a python term for converting things to strings ( str(9) == '9' ). Try using a diff name:
   
    >>> x = "beruhigend"
    >>> print x.replace("beruhigend", "soothing")
    soothing

best wishes,
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/33d10d3d-dac9-4d21-bfa2-5b97951f0a1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.


flo.jul...@gmail.com

unread,
Mar 20, 2014, 10:32:26 AM3/20/14
to psychop...@googlegroups.com
Dear Jon,

thanks for your kind reply. Yes thats true. I just have to copy the whole script in an editor and replace there everything. That's much easier I think. Thank you very much.

Best regards,

Florian
Reply all
Reply to author
Forward
0 new messages