[gradebook2-dev] gb2 and dynamic localization

John Bush john.bush at rsmart.com
Thu Apr 14 23:09:28 PDT 2011


Ok, missed this email, but just confirmed the bytecode manipulation
and reflection are not part of the GWT client side support. So that
rules out any fancy stuff and confirms my dislike for javascript, but
I digress...

I tried implementing the I18nConstants interface to delegate to the
Dictionary and confirmed this works:

public class I18nConstantsImpl implements I18nConstants {
    Dictionary i18n;
    public I18nConstantsImpl(){
         i18n = Dictionary.getDictionary("I18nConstants");


    }
    public String actionActor() {
        return i18n.get("actionActor");
    }

    public String actionDateFieldLabel() {
        return i18n.get("actionActor");
    }

Then in the host html file, which is GradebookApplication.html you
need to define the Dictionary like this:

        <script>var I18nConstants = {
     actionActor: "gwt rocks",
	 actionDateFieldLabel: "gwt rocks",
	 actionDescriptionFieldLabel:"gwt rocks",
	 actionDetails: "gwt rocks",
	 actionEntityFieldLabel: "gwt rocks"

That's the bit I would replace with a call back to the server.  The
issue is without bytecode or reflection dynamically implementing the
I18nConstants interface is not going to be possible which would
require devs to maintain the interface and impl, which I don't like.
Need to think about this a little more, unless others have any idea. I
really would like to avoid a giant refactor that doesn't  seem
friendly, and would lead me to just push back on the requirements that
are causing me to evaluate this in the first place.



On Thu, Apr 14, 2011 at 7:29 PM, Thomas Amsler <tpamsler at ucdavis.edu> wrote:
> See inline comments bellow:
>
> On Thu, Apr 14, 2011 at 5:27 PM, John Bush <john.bush at rsmart.com> wrote:
>> I've been looking into a way to make gb2 integrate with the new
>> dynamic loading of bundle data available in 2.8.  See
>> https://jira.sakaiproject.org/browse/SAK-18678.
>>
>> I see GWT has another method other than the I18nConstants approach
>> that allows for server side localization:
>> http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/i18n/client/Dictionary.html
>
> Do you just want to use this approach on the server side? You mention
> above " ...allows for server side localization".
>
>>
>> >From looking at the code switching this out touch almost everything.
>
> We could try a refactor and see how bad it is.
>
>> So here's my crazy idea.
>>
>> Use javassist or some other byte code library to get around the fact
>> that this call can't really be extended:
>> (I18nMessages) GWT.create(I18nMessages.class);
>>
> Whatever tool/library you use, it would have to be able to build
> within the GWT JRE emulation subset:
>
> http://code.google.com/webtoolkit/doc/latest/RefJreEmulation.html
>
>
>> So basically I'd augment the class that GWT is generating and throw
>> away what it does and instead delegate all the calls to the
>> Dictionary, which can then look them up from the server.
>>
>> Crazy or possible, what do you think?  Going to play around with it a
>> little tomorrow.
>>
>> --
>> John Bush
>> 602-490-0470
>> _______________________________________________
>> gradebook2-dev mailing list
>> gradebook2-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/gradebook2-dev
>>
>



-- 
John Bush
602-490-0470


More information about the gradebook2-dev mailing list