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

Fix crash on dashboard i18n #890

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/_dashboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,10 @@ def gitshow(project, commit):
@action.uses(Logged(session), "translations.html")
def translations(name):
"""returns a json with all translations for all languages"""
t = Translator(os.path.join(FOLDER, name, "translations"))
folder = os.path.join(FOLDER, name, "translations")
if not os.path.exists(folder):
os.makedirs(folder)
t = Translator(folder)
return t.languages


Expand Down
13 changes: 11 additions & 2 deletions docs/chapter-06.rst
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,17 @@ Now try create a file called ``translations/it.json`` which contains:
Set your browser preference to Italian: now the messages will be
automatically translated to Italian.

Notice there is UI for creating, updating, and updating translation files.
The UI is accessing via a button from the Dashboard.
Notice there is an UI in the Dashboard for creating, updating, and updating translation files.
It can be easily reached via the button ``i18n+p11n``:

.. image:: images/dashboard_i18n_btn.png

that leads to the following interface:

.. image:: images/dashboard_i18n_ui.png

More details can be found here: https://github.com/web2py/pluralize


If you want to force an action to use language defined somewhere else, for example from a session variable, you can do:

Expand Down
Binary file added docs/images/dashboard_i18n_btn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/dashboard_i18n_ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading