Problem/Motivation

When I attempt to translate https://localize.drupal.org/translate/languages/tr/translate?sid=2718592, I get the error: "Missing variable(s) :API-specification-compliant". However, : is not a variable in this case.

Steps to reproduce

Visit https://localize.drupal.org/translate/languages/tr/translate?sid=2718592, translate it and save it.

Proposed resolution

I'm not an expert, but I think : should be escaped properly.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

CommentFileSizeAuthor
#4 Ekran Resmi 2024-09-05 11.51.17.png40.75 KBkartagis
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kartagis created an issue. See original summary.

gábor hojtsy’s picture

Project: Drupal core » Localization server
Version: 11.x-dev » 3.0.x-dev
Component: jsonapi.module » Code

Moving the localization server which is where the error shows up. Can you not save it or "just" an error shows up but you can still save it?

kartagis’s picture

No I can't save it and the page it's on at all.

kartagis’s picture

StatusFileSize
new40.75 KB

Also, please see this, it's treated as a variable.

fmb’s picture

  • @kartagis what module does this string come from?
  • I think the whole :API-specification-compliant pattern should be present in the translation.
kartagis’s picture

It's coming from the jsonapi core module. I agree that the pattern should exist, but it seems we need a different aproach to parse it or distinguish the colon from a placeholder in this case.

guiu.rocafort.ferrer’s picture

I was not able to replicate this issue in a local environment:

I used main branch from drupal-infrastructure gitlab repository,
I used 3.0.x-dev branch for l10n_server module.

The string id i tried to translate, and had no problem is the #2718592

fmb’s picture

Issue tags: +Novice
fmb’s picture

String 5052 (Audio File Info) does not have this issue. In string 2718592, the "JSON:API-specification-compliant" is partly interpreted as a replacement token (:API-specification-compliant), apparently because of the colon. If you can replicate this bug, it might be related to the regexp in the TranslateForm::validateForm() method.

guiu.rocafort.ferrer’s picture

The string id i wrote in the comment #7 was wrong, i did not realise the id in my local setup is different than the one in localize.drupal.org, so İ updated the comment accordingly.

Sorry about that.

kartagis’s picture

Of course it has no issues Guiu, because it doesn't have a colon. I suspect all strings that have colon will have this issue.

kartagis’s picture

It is most interesting Guiu, you had no problem with the Spanish translation and yet I had problem with the Turkish translation.

guiu.rocafort.ferrer changed the visibility of the branch 3472254-wrongly-parsed-sentence to hidden.

guiu.rocafort.ferrer’s picture

Status: Active » Needs review

We found out that the code was treating JSON:XXXXXX as a variable, this is a general problem where it is interpreting JSON:API as a variable name, when it is actually the drupal core submodule name.

I added an exception to the regular expression checking the variables, that would ignore any value starting with "JSON:" from being interpreted as a variable.

guiu.rocafort.ferrer’s picture

@fmb I have checked that in the frontend the variables are not incorrectly hightlighted by the javascript code.

fmb’s picture

Version: 3.0.x-dev » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)

Thanks Guiu! According to my tests, this does not disrupt the translation form.

This now needs to be backported to 7.x-1.x-dev.

kartagis’s picture

Status: Patch (to be ported) » Needs work

When will this take effect? Because I'm still getting the exact same error, leaving me unable to save. Maybe that string has to be re-exported? Also, if you look at https://regex101.com/r/GLn0cs/1, that pattern doesn't match. Then again, I might be doing something wrong.

fmb’s picture

Status: Needs work » Patch (to be ported)

@kartagis for now, the fix was applied to the 3.0.x branch of the l10n_server module, which is currently under development. The next step is to backport it to the older 7.x-1.x branch, which is still the live version (i.e. the one in use on localize.drupal.org).

It is a good thing that JSON:API does not match, it means it will not be mistaken as a replacement token.

guiu.rocafort.ferrer’s picture

Status: Patch (to be ported) » Needs review

I have applied the changes in a new merge request to 7.x-1.x (3472254-wrongly-parsed-sentence-7.x).

fmb’s picture

Status: Needs review » Fixed

Thanks Guiu! I successfully tested this on a development Drupal 7 instance. Failing tests are not related to this change. @drumm, could you deploy this onto the live instance (localize.drupal.org)?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

kartagis’s picture

I don't know if I should file a new ticket because I'm getting a similar error, so... This time the error is Missing variable(s): @extension and this is the string.

fmb’s picture

What is the translation you are trying to save?

kartagis’s picture

It's 3037500.