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

REFLANG not working anymore? #280

Open
Skrattoune opened this issue Jul 21, 2023 · 1 comment
Open

REFLANG not working anymore? #280

Skrattoune opened this issue Jul 21, 2023 · 1 comment

Comments

@Skrattoune
Copy link

Which version of Django are you using?: 3.2
Which version of django-rosetta are you using?: 0.9.9
Have you looked trough recent issues and checked this isn't a duplicate? Yes

Hi, I was tempting to enable reflang in my project to facilitate the work of translators, but when testing the feature, the page throws me an error

error at /translations/files/project/de/0/
bad escape \l at position 0

The same occurs whatever the translation language I choose, whatever the django.po file I choose, and whatever the reference language I choose between 'fr' which is almost completely translated, and 'en' which is the original language to be translated

Am I missing something or is the functionality currently broken?

Detail of traceback:

Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py", line 1021, in parse_template
    this = chr(ESCAPES[this][1])

During handling of the above exception ('\\l'), another exception occurred:
...
  File "MyProject\venv\lib\site-packages\rosetta\views.py", line 57, in dispatch
    return super(RosettaBaseMixin, self).dispatch(*args, **kwargs)
  File "MyProject\venv\lib\site-packages\django\views\generic\base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "MyProject\venv\lib\site-packages\django\views\generic\base.py", line 159, in get
    context = self.get_context_data(**kwargs)
  File "MyProject\venv\lib\site-packages\rosetta\views.py", line 448, in get_context_data
    if self.ref_lang_po_file:
  File "MyProject\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "MyProject\venv\lib\site-packages\rosetta\views.py", line 578, in ref_lang_po_file
    ref_fn = re.sub(pattern, replacement, self.po_file_path)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\re.py", line 192, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\re.py", line 309, in _subx
    template = _compile_repl(template, pattern)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\re.py", line 300, in _compile_repl
    return sre_parse.parse_template(repl, pattern)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py", line 1024, in parse_template
    raise s.error('bad escape %s' % this, len(this))

Exception Type: error at /translations/files/project/de/0/
Exception Value: bad escape \l at position 0

with :

<html>
<body>
<!--StartFragment-->

addgroup | <function parse_template.<locals>.addgroup at 0x0DAF6030>
-- | --
c | 'l'
groupindex | {}
groups | []
lappend | <built-in method append of list object at 0x0DAD31E8>
literal | []
literals | []
pattern | re.compile('\\\\locale\\\\[a-z]{2}')
s | <sre_parse.Tokenizer object at 0x0DAE0A50>
sget | <bound method Tokenizer.get of <sre_parse.Tokenizer object at 0x0DAE0A50>>
source | '\\locale\\fr'
this | '\\l'

<!--EndFragment-->
</body>
</html>
@Skrattoune
Copy link
Author

Skrattoune commented Jul 24, 2023

OK, because the cause of the error seemed to be linked to a wrong number of slashes, I decided to test in prod ...

And reflang work very well in prod indeed!

I'm on a windows PC on dev ... so it seems that there is a need to fix this doubled slashes issue. I kind of remember that there was a template filter for that specific purpose, but I haven't been able to find it back

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

No branches or pull requests

1 participant