Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import translation memory fails if string contains \n #25

Closed
htgoebel opened this issue Dec 8, 2020 · 1 comment
Closed

Import translation memory fails if string contains \n #25

htgoebel opened this issue Dec 8, 2020 · 1 comment
Assignees
Labels
bug Something is broken.

Comments

@htgoebel
Copy link

htgoebel commented Dec 8, 2020

When trying to import a translation memory this fails with the following error message:

Failed to parse JSON file: 'Error reading config file {filename!r}:\n{error_msg}' does not match '^(.+)$'
Failed validating 'pattern' in schema['items']['properties']['source']: {'$id': '#/items/properties/source', 'default': '', 'examples': ['Hello'], 'pattern': '^(.+)$', 'title': 'The Source String', 'type': 'string'} 
On instance[79]['source']: 'Error reading config file {filename!r}:\n{error_msg}' 

As you can see, the string contains \n.

Additional information

  • When replacing the \n by a space, it fails with the next string containing a \n (which of course is the translated string).
  • This looks like pattern matching is missing option re.DOTALL.
  • Maybe it makes sense to change the pattern in the schema empty '' (empty string)

To Reproduce the bug

Steps to reproduce the behavior:

  1. Save attached file bug.json as /tmp/bug.json
  2. Go to '$PROJECT -> Manamge -> Translation memory'
  3. Scroll down to 'Import translation memory'
  4. Upload saved file (/tmp/bug.json)
  5. See error

Expected behavior

Importing translation memoires containing such strings passes and line-feed is preserved.

Server configuration and status

Weblate installation: self-hosted from PyPI

Weblate 4.3.2
weblate-language-data 2020.11

(Sorry, I don't have console access, So I can't run ./manage.py list_versions)

Weblate deploy checks

(Sorry, I don't have console access, So I can't run this command)

@nijel nijel transferred this issue from WeblateOrg/weblate Dec 8, 2020
@nijel nijel added the bug Something is broken. label Dec 8, 2020
@nijel nijel self-assigned this Dec 8, 2020
@nijel nijel closed this as completed in 0457924 Dec 8, 2020
@github-actions
Copy link

github-actions bot commented Dec 8, 2020

Thank you for your report, the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken.
Projects
None yet
Development

No branches or pull requests

2 participants