Skip to content

Instantly share code, notes, and snippets.

@hazho
Last active March 3, 2022 02:04
Show Gist options
  • Save hazho/5fd17fa7a5fa5e5eec1a47817c08d65a to your computer and use it in GitHub Desktop.
Save hazho/5fd17fa7a5fa5e5eec1a47817c08d65a to your computer and use it in GitHub Desktop.
Multi-language(bidirection)
<!DOCTYPE html>
{% load wagtailadmin_tags i18n navigation_tags site_tags wagtailcore_tags %}
{% wagtail_site as current_site %}
{% get_current_language as LANGUAGE_CODE %}
{% get_current_language_bidi as LANGUAGE_BIDI %}
<html class="no-js" lang="{{ LANGUAGE_CODE }}" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">
<head>
<!-- option1 -->
<!-- if you like the language control all UI Use this -->
<style>
:root {
{% if LANGUAGE_CODE == "ar" %}font-size:14px;unicode-bidi: plaintext; {% else %} font-size:16px; {% endif %}
}
nav {width: 17.5rem; min-width: 17.5rem; max-width: 17.5rem}
{% block extra_style %}{% endblock extra_style %}
</style>
<!-- option2 -->
<!-- if you like the language control the certain elements/sections Use this -->
<style>
:root {
{% if LANGUAGE_CODE == "ar" %}unicode-bidi: plaintext;{% endif %}
font-size:16px;
}
nav {
{% if LANGUAGE_CODE == "ar" %}
width: 16.5rem; min-width: 16.5rem; max-width: 16.5rem
{% else %}
width: 17.5rem; min-width: 17.5rem; max-width: 17.5rem
{% endif %}
}
{% block extra_style %}{% endblock extra_style %}
</style>
...
</head>
...
...
WAGTAIL_I18N_ENABLED = True
LANGUAGES = WAGTAILADMIN_PERMITTED_LANGUAGES = WAGTAIL_CONTENT_LANGUAGES = WAGTAILFRONTENDCACHE_LANGUAGES = [
('en', 'English'),
('ar', 'Arabic')
]
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment