Skip to content

Commit

Permalink
Language flag icons in language dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
rnixx committed May 26, 2024
1 parent b9b27e4 commit dad2a95
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 8 deletions.
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ The sources are in a GIT DVCS with its main branches at
`github <http://github.com/conestack/cone.app>`_.


Third Party Resources
=====================

- https://github.com/jquery/jquery
- https://github.com/twbs/bootstrap
- https://github.com/HatScripts/circle-flags


Copyright
=========

Expand Down
13 changes: 9 additions & 4 deletions TODO.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
TODO
====

- Dropdowns - do we need <div class="dropdown-item" /> wrappers? causes
rendering problems in all sorts of dropdowns.

- Contextmenu - wrong html semantics. ul in ul.
- Live search.
- Table actions sorting.
- SCSS splitting.
- Reduce CSS class noise and add some custom rules to SCSS files.
- Check if we can retrieve Bootstrap sources other than including in this repo
for development.
- Translation widget.
- Referencebrowser widget.
- Treibstoff styles.
16 changes: 15 additions & 1 deletion src/cone/app/browser/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from cone.app.browser.utils import make_query
from cone.app.browser.utils import make_url
from cone.app.browser.utils import node_icon
from cone.app.browser.utils import request_property
from cone.app.interfaces import IApplicationNode
from cone.app.interfaces import ILayout
from cone.app.interfaces import INavigationLeaf
Expand Down Expand Up @@ -492,6 +493,7 @@ def make_query(self, lang=None):
return make_query(**params)


# XXX: complete list
language_names = {
'en': _('lang_en', default='English'),
'de': _('lang_de', default='German'),
Expand All @@ -510,11 +512,23 @@ class Language(LanguageTile):
def show(self):
return bool(cfg.available_languages)

@request_property
def current_lang(self):
return negotiate_locale_name(self.request)

@property
def flag(self):
return make_url(
self.request,
node=self.model.root['resources'],
resource='/'.join(['cone', 'flags', f'{self.current_lang}.svg'])
)

@property
def languages(self):
languages = list()
localizer = get_localizer(self.request)
current = negotiate_locale_name(self.request)
current = self.current_lang
for lang in cfg.available_languages:
target = make_url(
self.request,
Expand Down
1 change: 1 addition & 0 deletions src/cone/app/browser/static/cone/flags/de.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/cone/app/browser/static/cone/flags/en.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/cone/app/browser/static/cone/flags/fr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/cone/app/browser/static/cone/flags/it.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions src/cone/app/browser/templates/language.pt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
justify-content-end-sm-center align-items-center"
data-bs-toggle="dropdown">
<a href="#"
class="nav-link d-inline-block px-0 px-md-3">
<span i18n:translate="language">Language</span>
class="nav-link d-inline-block px-0 px-md-2">
<img src="${context.flag}"
width="20"
height="20"
alt="language"
i18n:attributes="alt" />
<span class="caret"></span>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/cone/app/browser/templates/personaltools.pt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
justify-content-end-sm-center align-items-center"
data-bs-toggle="dropdown">
<a href="#"
class="nav-link d-inline-block px-0 px-md-3">
class="nav-link d-inline-block px-0 px-md-2">
<span tal:content="context.user">Admin</span>
<span class="caret"></span>
</a>
Expand Down

0 comments on commit dad2a95

Please sign in to comment.