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

Add language selector #6

Merged
merged 1 commit into from
Dec 21, 2023
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
15 changes: 15 additions & 0 deletions ckanext/kepa/assets/css/kepa.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ckanext/kepa/assets/css/kepa.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions ckanext/kepa/assets/scss/kepa.scss
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,16 @@
color: black;
text-shadow: none;
}

.language {
border-left: none !important;
height: 30px;
}

.lang-select {
width: 60px;
}

.list-unstyled{
@include center-flex;
}
3 changes: 3 additions & 0 deletions ckanext/kepa/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
{% block header_account_container_content %} {% if c.userobj %}
<div class="account avatar authed" data-module="me" data-me="{{ c.userobj.id }}">
<ul class="list-unstyled">
<div class="language">
{% snippet "snippets/language_selector.html" %}
</div>
{% block header_account_logged %} {% if c.userobj.sysadmin %}
<li>
<a href="{{ h.url_for('admin.index') }}" title="{{ _('Sysadmin settings') }}">
Expand Down
16 changes: 16 additions & 0 deletions ckanext/kepa/templates/snippets/language_selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% set current_lang = request.environ.CKAN_LANG %}
<form class="lang-select" action="{% url_for 'util.internal_redirect' %}" data-module="select-switch" method="POST">
{{ h.csrf_input() }}
<div class="form-group">
<select id="field-lang-select" name="url" data-module="autocomplete" data-module-dropdown-class="lang-dropdown" data-module-container-class="lang-container">
{% for locale in h.get_available_locales() %}
<option value="{% url_for h.current_url(), locale=locale.short_name %}" {% if locale.short_name == current_lang %}selected="selected"{% endif %}>
{{ locale.short_name or locale.english_name }}
</option>
{% endfor %}
</select>
</div>
<button class="btn btn-default d-none " type="submit">{{ _('Go') }}</button>
</form>


Loading