[ADD] web: add the language code in the translation widget

The planet icon is not very clear for translation feature.
Replace it with the code of the current language.

Task-id: 2028152
This commit is contained in:
Martin Trigaux
2019-08-13 14:12:17 +00:00
parent 2347b84c66
commit bdec8efabf
8 changed files with 11 additions and 3 deletions
+1
View File
@@ -246,6 +246,7 @@ class IrHttp(models.AbstractModel):
'lang_parameters': lang_params,
'modules': translations,
'multi_lang': len(request.env['res.lang'].sudo().get_installed()) > 1,
'lang': lang,
}
session_info.update({
+1
View File
@@ -793,6 +793,7 @@ class WebClient(http.Controller):
translations_per_module, lang_params = request.env["ir.translation"].get_translations_for_webclient(mods, lang)
body = json.dumps({
'lang': lang,
'lang_parameters': lang_params,
'modules': translations_per_module,
'multi_lang': len(request.env['res.lang'].sudo().get_installed()) > 1,
+1
View File
@@ -33,6 +33,7 @@ class Http(models.AbstractModel):
lang = user_context.get("lang")
translations_per_module, lang_params = request.env['ir.translation'].get_translations_for_webclient(mods, lang)
translation_cache = {
'lang': lang,
'lang_parameters': lang_params,
'modules': translations_per_module,
'multi_lang': len(request.env['res.lang'].sudo().get_installed()) > 1,
+2 -1
View File
@@ -13,7 +13,8 @@ var TranslationDataBase = Class.extend(/** @lends instance.TranslationDataBase#
"time_format": '%H:%M:%S',
"grouping": [],
"decimal_point": ".",
"thousands_sep": ","};
"thousands_sep": ",",
"code": "en_US"};
},
set_bundle: function(translation_bundle) {
var self = this;
@@ -41,9 +41,11 @@ var TranslatableFieldMixin = {
*/
_renderTranslateButton: function () {
if (_t.database.multi_lang && this.field.translate && this.res_id) {
var lang = _t.database.parameters.code.split('_')[0].toUpperCase();
return $('<button>', {
type: 'button',
'class': 'o_field_translate fa fa-globe btn btn-link',
'data-code': lang,
})
.on('click', this._onTranslate.bind(this));
}
+2 -1
View File
@@ -578,10 +578,11 @@
.o_field_translate {
padding: 0;
cursor: pointer;
width: 12px !important;
width: 35px !important;
vertical-align: top;
&::before { // seems to be useful for some old browser
position: relative;
content: attr(data-code);
}
}
@@ -82,7 +82,7 @@
// Translate icon
.o_field_translate {
margin-left: -15px;
margin-left: -35px;
}
// Specific style classes
@@ -833,6 +833,7 @@ class IrTranslation(models.Model):
"name", "direction", "date_format", "time_format",
"grouping", "decimal_point", "thousands_sep", "week_start"])[0]
lang_params['week_start'] = int(lang_params['week_start'])
lang_params['code'] = lang
# Regional languages (ll_CC) must inherit/override their parent lang (ll), but this is
# done server-side when the language is loaded, so we only need to load the user's lang.