[Add] Language Flag For Website
This commit is contained in:
parent
aa7a8326a3
commit
a575531420
@ -335,6 +335,33 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template id="language_flags" name="Language Flags">
|
||||||
|
<li
|
||||||
|
t-if="(request and request.is_frontend_multilang and len(languages) > 1) or (website and (editable or translatable))"
|
||||||
|
class="dropdown language_dropdown">
|
||||||
|
<a href="#" class="dropdown-toggle language_flag" data-toggle="dropdown">
|
||||||
|
<t t-foreach="website.language_ids" t-as="lg">
|
||||||
|
<t t-if="request.context.get('lang') == lg.code">
|
||||||
|
<img t-att-src="website.image_url(lg, 'lang_flag')" height="30"
|
||||||
|
width="30" t-att-title="lg.name" />
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
<span class="caret"></span>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu" role="menu" style="min-width: 80px;">
|
||||||
|
<li t-foreach="website.language_ids" t-as="lg">
|
||||||
|
<a
|
||||||
|
t-att-href="url_for(request.httprequest.path + '?' + keep_query(), lang=lg.code)"
|
||||||
|
t-att-data-default-lang="(editable or translatable) and 'true' if website and lg.code == website.default_lang_code else None"
|
||||||
|
t-att-data-lang="lg.code" t-att-data-lang_dir="lg.direction" class="js_change_lang">
|
||||||
|
<img t-att-src="website.image_url(lg, 'lang_flag')" height="30" width="30" t-att-title="lg.code" />
|
||||||
|
<t t-esc="lg.name.split('/').pop()"/>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template id="footer_default" inherit_id="website.footer_custom" customize_show="True" name="Automatic Footer">
|
<template id="footer_default" inherit_id="website.footer_custom" customize_show="True" name="Automatic Footer">
|
||||||
<xpath expr="//div[@id='footer']" position="replace" >
|
<xpath expr="//div[@id='footer']" position="replace" >
|
||||||
<div id="footer" class="container hidden-print" t-if='not no_footer'>
|
<div id="footer" class="container hidden-print" t-if='not no_footer'>
|
||||||
|
@ -25,6 +25,7 @@ class Lang(models.Model):
|
|||||||
_disallowed_datetime_patterns = list(tools.DATETIME_FORMATS_MAP)
|
_disallowed_datetime_patterns = list(tools.DATETIME_FORMATS_MAP)
|
||||||
_disallowed_datetime_patterns.remove('%y') # this one is in fact allowed, just not good practice
|
_disallowed_datetime_patterns.remove('%y') # this one is in fact allowed, just not good practice
|
||||||
|
|
||||||
|
image = fields.Binary(string='Language Flag')
|
||||||
name = fields.Char(required=True)
|
name = fields.Char(required=True)
|
||||||
code = fields.Char(string='Locale Code', required=True, help='This field is used to set/get locales for user')
|
code = fields.Char(string='Locale Code', required=True, help='This field is used to set/get locales for user')
|
||||||
iso_code = fields.Char(string='ISO code', help='This ISO code is the name of po files to use for translations')
|
iso_code = fields.Char(string='ISO code', help='This ISO code is the name of po files to use for translations')
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<field name="iso_code"/>
|
<field name="iso_code"/>
|
||||||
<field name="translatable"/>
|
<field name="translatable"/>
|
||||||
|
<newline />
|
||||||
|
<field name="image" widget='image'></field>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="direction"/>
|
<field name="direction"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user