Bug 169977 - LibreLogo programs with loops don't run in Spanish language and others because REPCOUNT translation
Summary: LibreLogo programs with loops don't run in Spanish language and others becaus...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.2.8.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: LibreLogo
  Show dependency treegraph
 
Reported: 2025-12-14 21:03 UTC by Carlos R. Esp
Modified: 2026-02-08 09:50 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos R. Esp 2025-12-14 21:03:51 UTC
Description:
When using LibreLogo in Spanish (or other languages like Afrikaans or Catalan or Croatian), any user's program including a loop (that is, any REPEAT, FOR or WHILE translated to the corresponding language) cannot be executed and shows an error dialog because the first translation of the REPCOUNT variable in these languages is composed of more than one word ("conteo.veces" in Spanish for example) and LibreLogo doesn't accept this.

Steps to Reproduce:
1.Open a new empty document in Writer and enable the Logo toolbar.
2.Change the default language of the document to Spanish (or one of the failing ones) if it's not already the default (Tools - Options > Languages and Locales - General > Default languages for documents).
3.Press the Run button for inserting an example program with a loop and run it.

Actual Results:
An error dialog is shown and the program is not executed.

Expected Results:
The program is executed and the turtle draws a figure.


Reproducible: Always


User Profile Reset: No

Additional Info:
Removing any loop (and REPCOUNT occurrences if any) from the user's code will allow you to run LibreLogo programs, provided that you don't need loops.

Current languages failing because REPCOUNT having dots or spaces are Spanish, Afrikaans, Breton, Catalan, Catalan-valencian, Croatian, Guarani and Oriya.

The error displayed depends on the particular translation and the current behaviour of the transpiler, but it does not describe the problem.

This bug can be fixed by changing the translations (for example, in Spanish you could change the REPCOUNT property translation from conteo.veces to conteoveces|conteo.veces) or better can be fixed by changing the program for accepting this kind of variable names by using internally a different name for the REPCOUNT variable (a name composed by only one word).

I reproduced this bug in at least 3 Linux installations, even in an old Fedora 20 and now in Debian 13, so it's been failing since more than 10 years ago, and I'm pretty sure that it's failing in other operating systems too. By debugging the script in my machine I managed to fix it by changing the translation of REPCOUNT included in the script, but we can devise a better fix by changing the script for accepting any translation having dots (or even spaces).
Comment 1 Julien Nabet 2025-12-19 20:24:19 UTC
The translation is here:
https://translations.documentfoundation.org/translate/libo_ui-master/librelogosourcepythonpath/es/?checksum=627b05b79b041731&q=note%3ApA442&sort_by=-priority%2Cposition

Adolfo: could we just use "conteoveces" instead or do you have something better in mind?
Comment 2 Carlos R. Esp 2025-12-20 16:55:55 UTC
Hello Julien,

Thanks for your attention.

First, does someone know if changing the REPCOUNT translation will also change automatically the translations written in the code of LibreLogo.py? Because in languages with variants and only one generic translation in LibreLogo (like Spanish), the interpreter uses these internal translations instead, so LibreLogo.py should be updated too if we change the translation.

Second, I developed a solution for all the failing languages without changing any translation, for you to discuss:

    repcount = a['REPCOUNT'].split('|')[0]
    repcount = re.sub("[ .']", '_', repcount) # INSERT THIS LINE
    loopi = itertools.count()
    ...
    [r"(?<!:)\b(?:%s)\b" % a['FOR'], "\nfor"],
    [r"(?<!:)\b(?:%s)\b" % a['REPCOUNT'], repcount], # INSERT THIS LINE
    [r"(?<!:)\b(?:%s)\b" % a['REPEAT'], "\n__repeat__"],
    [r"(?<!:)\b(?:%s)\b" % a['BREAK'], "\nbreak"],
    [r"(?<!:)\b(?:%s)\b" % a['CONTINUE'], "\ncontinue"],
    [r"(?<!:)\b(?:%s)\b" % a['REPCOUNT'], repcount], # REMOVE THIS LINE
    [r"(?<!:)\b(?:%s)\b" % a['IF'], "\nif"],

The first change affects the languages with a REPCOUNT translation including spaces (like Croatian or Oriya), dots (like Spanish) or apostrophes (Guarani), and makes an internal substitution of characters rejected by the interpreter with "_" and also prevents that a part of the name be replaced in posterior subtitutions (this happens in Spanish when "conteo" of "conteo.veces" is replaced by "len", and will not happen if "conteo_veces" or "conteoveces" were found).

The second change is for the languages with a REPCOUNT translation wich is composed with the first translation of REPEAT (like Afrikaans, Catalan, Catalan-Valencian and Guarani), and causes that the occurrences of the translation of REPCOUNT be replaced before REPEAT, avoiding another error that prevents the users of these other languages to write loops in LibreLogo.

I found another language, Kazakh, that has the same translation in REPCOUNT than in REPEAT, preventing the use of the counter REPCOUNT in LibreLogo programs in this language but unaffected by my proposal.

Translating the Spanish REPCOUNT will fix LibreLogo loops in Spanish, which is great, but this proposal could fix it in Spanish and in these languages too without changing translations. Please consider it.
Comment 3 Carlos R. Esp 2026-02-07 23:57:40 UTC
Hello,

I have submitted a patch to review with the changes I explained:

https://gerrit.libreoffice.org/c/core/+/198892 librelogo: support creative REPCOUNT translations

Thank you.