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
Support I18n #2135
Support I18n #2135
Conversation
@@ -64,6 +64,7 @@ ARG LOGGER_LEVEL='' | |||
ENV LOGGER_LEVEL "$LOGGER_LEVEL" | |||
|
|||
WORKDIR /app | |||
RUN pybabel compile -d changedetectionio/translations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiling happens here
@@ -55,6 +57,12 @@ | |||
static_folder="static", | |||
template_folder="templates") | |||
|
|||
def get_locale(): | |||
# Debug i8n with simple trick | |||
#return 'ko' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to debug conveniently.
Co-authored-by: dgtlmoon <[email protected]>
Amazing! yeah first version doesnt need to have totally everything translated, as long as the basic UI has translations. What do you think is "nicer", a flag icon in the toolbar with a pop-up to choose another language? or some settings page option? (in the case they want to override it) |
btw, this super cool! thanks again, it is appreciated! |
@@ -0,0 +1,399 @@ | |||
# Translations template for PROJECT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Autogenerated file.
@@ -0,0 +1,402 @@ | |||
# Korean translations for PROJECT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Autogenerated file but translation by humans.
@dgtlmoon Yes, that is needed. EDIT: If you can, just change the language of the current page without going to another page, please. ex) english-edit page for somepage.com --> korean-edit page for somepage.com EDIT: language in url is also good.( |
@@ -342,8 +343,8 @@ def __call__(self, form, field): | |||
try: | |||
elementpath.select(tree, line.strip(), parser=XPath3Parser) | |||
except elementpath.ElementPathError as e: | |||
message = field.gettext('\'%s\' is not a valid XPath expression. (%s)') | |||
raise ValidationError(message % (line, str(e))) | |||
message = _("'{}' is not a valid XPath expression. ({})") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with wrong xpath syntax and worked. But am I right?
I'm totally unaware of the field.gettext
. If it is come from wtforms, the gettext is from python builtin lib.
why closed? :( |
pybabel or babel has some bug for the specific feature and the bug applies on the many human languages. But I didn't checked but believe the bug exists over decades again. I won't delete this branch. You can use it freely. |
woha :( what was the bug? |
This video describes the bug. |
closes #2124
You can debug it with
curl http://192.168.1.134:8895/edit -X 'GET' -H 'Accept-Language: ko-kr,ko;'
But just follow this. #2135 (comment)
To create new language support,
pybabel init -i messages.pot -d translations -l es
(es is an example. See also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language)If you changed texts in html and so on, then run
pybabel extract -F babel.cfg -k _l -o messages.pot . && pybabel update -i messages.pot -d translations
inchangedetectionio
dir. and translate text.Todos
flash()
EDIT:
pybabel extract -F babel.cfg -k _l -o messages.pot . && pybabel update -i messages.pot -d translations
EDIT: add tasks
See also: https://stackoverflow.com/questions/12555692/flask-babel-translations-de-lc-messages-messages-po-is-marked-as-fuzzy-skip