إضافة placeholders ديناميكية للتاريخ الميلادي والهجري مع دعم اللغتين العربية والإنجليزية
This commit is contained in:
parent
7322ff3450
commit
b3b542a290
|
|
@ -34,6 +34,25 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) {
|
|||
var self = this;
|
||||
this.$input = this.$('input.o_datepicker_input');
|
||||
this.$input_hijri = this.$('input.o_hijri');
|
||||
|
||||
// إضافة placeholders ديناميكية حسب اللغة
|
||||
var locale = this.options.locale || 'en';
|
||||
var userLang = (odoo.session_info && odoo.session_info.user_context && odoo.session_info.user_context.lang) || 'en_US';
|
||||
|
||||
// تحديد placeholders حسب اللغة
|
||||
var gregorianPlaceholder, hijriPlaceholder;
|
||||
if (locale === 'ar' || userLang.startsWith('ar')) {
|
||||
gregorianPlaceholder = 'التاريخ الميلادي';
|
||||
hijriPlaceholder = 'التاريخ الهجري';
|
||||
} else {
|
||||
gregorianPlaceholder = 'Gregorian Date';
|
||||
hijriPlaceholder = 'Hijri Date';
|
||||
}
|
||||
|
||||
// تطبيق placeholders على الحقول
|
||||
this.$input.attr('placeholder', gregorianPlaceholder);
|
||||
this.$input_hijri.attr('placeholder', hijriPlaceholder);
|
||||
|
||||
this.$input_hijri.click(function (e) {
|
||||
e.preventDefault();
|
||||
self.$input_hijri.calendarsPicker('show');
|
||||
|
|
@ -125,13 +144,19 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) {
|
|||
var value = this.value ? this.datewidget._formatClients(this.value) : '';
|
||||
var parsed_date = this.value ? this.datewidget._parseDate(this.value) : '';
|
||||
var hijri_value = parsed_date ? this.datewidget._convertGregorianToHijri(parsed_date) : '';
|
||||
|
||||
// إضافة labels توضيحية في وضع القراءة فقط
|
||||
var userLang = (odoo.session_info && odoo.session_info.user_context && odoo.session_info.user_context.lang) || 'en_US';
|
||||
var gregorianLabel = userLang.startsWith('ar') ? 'التاريخ الميلادي: ' : 'Gregorian Date: ';
|
||||
var hijriLabel = userLang.startsWith('ar') ? 'التاريخ الهجري: ' : 'Hijri Date: ';
|
||||
|
||||
$('<div>', {
|
||||
class: this.$el.attr('class'),
|
||||
text: value,
|
||||
text: gregorianLabel + value,
|
||||
}).appendTo($div);
|
||||
$('<div>', {
|
||||
class: this.$el.attr('class'),
|
||||
text: hijri_value,
|
||||
text: hijriLabel + hijri_value,
|
||||
}).appendTo($div);
|
||||
this.datewidget.appendTo('<div>').then(function () {
|
||||
self._replaceElement($div);
|
||||
|
|
|
|||
Loading…
Reference in New Issue