Closed hloe0xff closed 4 years ago
Hi @hloe0xff , don't worry about questioning everything! :)
Can you be more specific? The entire templating system just uses unicode internally and decode/encode from and to utf-8. Never had problems with chinese characters for instance.
Are the strings coming from the route? Are directly written in template? Are they a python string inside the template ({{="foo"}}
)? Are you using the translator ({{=T("foo")}}
)?
Also regarding regexes, what do you want to do? I can't reply correctly without more information :)
@gi0baro, i mean text directly written in template. No, i don't use a translator, where i may read about it?. But with tranlator i get error about invalid syntax.
I'm write in template next code: <caption>Русский текст!!! --- Russian text!!!</caption>
Template encoding is UTF-8. Result on a attached picture. I'm using PyCharm IDE if is this important.
About regexes. For example, i want extract substring from any variable or string.
@hloe0xff can you please try to change that line with:
<caption>{{="Русский текст!!!"}}</caption>
Hello @gi0baro!
Next code <caption>{{="Русский текст!!!"}}</caption>
, render page:
@hloe0xff I can't reproduce your issue. Added this code to the bloggy example in index.html
:
<p>py {{="Русский текст!!!"}}</p>
<p>translator {{=current.T("Русский текст!!!")}}</p>
<p>html Русский текст!!!</p>
Here is the result:
python version? browser?
@gi0baro Win7 + Python 3.6.5 + Latest Google Chrome
Super strange. Maybe is dependant on the encoding of your file-system but should use utf8 anyway. Can you try adding this line to your app:
app.config.templates_escape = 'all'
and see if anything changes?
from weppy import App
app = App(__name__)
app2 = app.module(__name__, name='app2', url_prefix='app2')
app.config.templates_escape = 'all'
@app.route('/', methods='get')
def index():
return dict(title='index')
@app2.route('/', methods='get')
def app2_index():
return dict(title='app2 index')
if __name__ == '__main__':
app.run(debug=True)
@gi0baro, no changes.
Hi, @gi0baro!
Sorry for your lost time. I launch my project on a linux based operating system, and russian text shows correctly.
Project:
from weppy import App
app = App(__name__)
app.config.templates_escape = 'all'
@app.route('/')
def index():
return dict(text='texxxt')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
Template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>Привет, Мир!!!</h1>
<p>py {{="Русский текст!!!"}}</p>
<p>translator {{=current.T("Русский текст!!!")}}</p>
<p>html Русский текст!!!</p>
<p>{{="Русский текст!!!"}}</p>
</body>
</html>
@hloe0xff No worries! At least now I know it's a windows related issue. Will try to look at it.
@gi0baro good luck and thank you for your products!
Hi, @gi0baro !
I'm cannot find nothing about regular expressions in templates, and when i create template with utf-8 encoding and write russian text, i cannot see a valid text on template rendering. Does weppy framework supports these features?
Sorry, if i ask stupid questions, and my english.
Thank you.