Creation locale-aware Sikuli scripts

Asked by Andrey Brindeyev

Hi!

I'm on Mac and almost every program interface depends on user's locale.

I recently switched to en_US locale from ru_RU and discovered that my Sikuli script stopped worked since iTunes interface changed from Russian to English.

What is the best practices to write Sikuli scripts in Python to support several languages?

I'm trying to avoid lots if () else () in my code and want to support several locales.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

Put everything, that is needed for a locale environment into a separate .sikuli and import that as needed.

an example:

--- locale1.sikuli
img1 = "some captured image language1.png"
text1 = "some text language1"

--- locale2.sikuli
img1 = "some captured image language2.png"
text1 = "some text language2"

--- main.sikuli
from locale1 import *
if exists(img1):
    click getLastMatch()
else:
    print text1; exit(1)

The docs apply: Reusing scripts and images and about SIKULI_IMAGE_PATH

Revision history for this message
Andrey Brindeyev (abrindeyev) said :
#2

Thanks RaiMan, that solved my question.