Dataedit : translate buttons Add and Delete

29 views
Skip to first unread message

Fred

unread,
Apr 17, 2014, 8:57:02 AM4/17/14
to webl...@googlegroups.com
Hello,

in the dataedit.lisp file the function

dataedit-update-operations should be modified
to allow translation.

Bellow what i suggest.

The actual code :

(defmethod dataedit-update-operations (obj &key
                                   (delete-fn #'dataedit-delete-items-flow)
                                   (add-fn #'dataedit-add-items-flow))
  "Should be used to update operations the widget supports.

'delete-fn' - a function to be called when delete action is invoked.
'add-fn' - a function to be called when add action is invoked."
  (setf (dataseq-item-ops obj)
        (remove 'delete (dataseq-item-ops obj)
                :key #'car :test #'string-equal))
  (setf (dataseq-common-ops obj)
        (remove 'add (dataseq-common-ops obj)
                :key #'car :test #'string-equal))
  (when (and (dataedit-allow-delete-p obj)
             (> (dataseq-data-count obj) 0))
    (pushnew (cons 'delete delete-fn)
             (dataseq-item-ops obj)
             :key #'car))
  (when (dataedit-allow-add-p obj)
    (pushnew `(add . ,add-fn)
             (dataseq-common-ops obj)
             :key #'car)))

New code :

(defmethod dataedit-update-operations (obj &key
(delete-fn #'dataedit-delete-items-flow)
(add-fn #'dataedit-add-items-flow))
"Should be used to update operations the widget supports.

'delete-fn' - a function to be called when delete action is invoked.
'add-fn' - a function to be called when add action is invoked."
(setf (dataseq-item-ops obj)
(remove 'delete (dataseq-item-ops obj)
:key #'car :test #'string-equal))
(setf (dataseq-common-ops obj)
(remove 'add (dataseq-common-ops obj)
:key #'car :test #'string-equal))
(when (and (dataedit-allow-delete-p obj)
(> (dataseq-data-count obj) 0))
(pushnew (cons (widget-translate obj :delete-items) delete-fn)
(dataseq-item-ops obj)
:key #'car))
(when (dataedit-allow-add-p obj)
(pushnew (cons (widget-translate obj :add-new-item) add-fn)
(dataseq-common-ops obj)
:key #'car)))



(defmethod widget-translation-table append ((obj dataedit-mixin) &rest args)
(list*
(cons :add-new-item "Add")
(cons :delete-items "Delete")
(cons :choose-items-for-deletion-message
(format nil
(translate "Please select ~A to delete.")
(translate
(humanize-name (dataseq-data-class obj))
:plural-p t
:accusative-form-p t)))
(append
(loop for count-keyword in (locale-number-forms (current-locale))
collect
(cons
(concatenate-keywords :items-deleted-message- count-keyword)
(format nil
(translate
"Deleted ~~A ~A."
:preceding-gender (determine-gender (humanize-name (dataseq-data-class obj)))
:preceding-count count-keyword)
(translate
(humanize-name (dataseq-data-class obj))
:items-count count-keyword
:accusative-form-p t))))
(loop for count-keyword in (locale-number-forms (current-locale))
collect
(cons
(concatenate-keywords :items-delete-question-for- count-keyword)
(format nil
(translate "Delete ~~A ~A?")
(translate
(humanize-name (dataseq-data-class obj))
:items-count count-keyword
:accusative-form-p t))))
(loop for (key . val) in (widget-translation-table 'do-confirmation :confirmation-type :yes/no)
collect (cons (concatenate-keywords :do-confirmation- key) val)))))


What's your opinion ?


Thnaks.

Best Regards.


o_z

unread,
Jun 24, 2014, 3:14:51 PM6/24/14
to webl...@googlegroups.com
My opinion is your fix is good. Thanks ! I've added it to Weblocks source

четверг, 17 апреля 2014 г., 15:57:02 UTC+3 пользователь Fred написал:
Reply all
Reply to author
Forward
0 new messages