grails-commons-translation
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Plugin to manage fields translations on Grails
grails-commons-translation
==========================

Plugin to manage fields translations on Grails

This plugin allow to create multilanguage fields in Grails.

To add translation filed to a domain class, in domain class import Translation class

    org.gg.grails.plugin.commons.translation
  
After add for every mylti language field,
one transient field with the name you want, and one hasMany relation
with the name FIELD_NAMETranslations,

so for example :  "title":

    def title
    static hasMany = [
        titleTranslations : Translations
    ]

now for save tranlation on domain instance, you must use "translationService", 
inside a controller or directly in the domain class.
In both case, you have to call translationService before validation.
For instance in controller, you can have:

    translationService.add(domainInstance,'title')
        if (!domainInstance.hasErrors() && domainInstance.save(flush: true)) { ..
    }
  
In domain class you can call service in the beforeValidation hook 

    def beforeValidate() {
        translationService.add(this,'title')
    }

add method at this time, verify if at lest one of field translations have value,
otherwise invalidate domain class, adding error 'default.blank.message' to transient field, "title" in this case

add method have also optional paramenter leght , 

    translationService.add(this,'title',34) 
  
which verify text to be shorter than lenght,
else adds to filed 'default.maxsize.message' error



本源码包内暂不包含可直接显示的源代码文件,请下载源码包。