Skip to content

Commit

Permalink
Merge pull request #890 from nicozanf/i18n
Browse files Browse the repository at this point in the history
Fix crash on dashboard i18n
  • Loading branch information
nicozanf authored Jul 7, 2024
2 parents 830e3ef + 4b55f3a commit f2ae31c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
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.

0 comments on commit f2ae31c

Please sign in to comment.