[gradebook2-dev] gb2 and dynamic localization

John Bush john.bush at rsmart.com
Fri Apr 15 17:24:34 PDT 2011


I have the code generation piece working, finally found some time
today.  Just need to do the server side stuff to tie into Sakai's
ResourceLoader, that is the easy part, will have something next week
to get some feedback on.

On Fri, Apr 15, 2011 at 3:53 PM, Thomas Amsler <tpamsler at ucdavis.edu> wrote:
> Good find. GWT is pretty amazing. I am looking forward to seeing your solution.
> -- Thomas
>
> On Thu, Apr 14, 2011 at 11:53 PM, John Bush <john.bush at rsmart.com> wrote:
>> ok, this is getting more interesting, apparently GWT deferfed binding
>> has a way to plug a java code generator into the framework.  If I'm
>> understanding this correctly, that means the calls to
>> GWT.create(I18nConstants.class) I could catch and generate the Impl
>> using the GeneratorContext, which appears to be a reflection
>> implementation of sorts.  Ok, GWT is freakin cool.
>>
>> I think this might actually work.  So basically I catch these create()
>> calls with one of these generators, and then generate a impl that
>> makes calls the dictionary which avoid having to maintain anything
>> other than the interface.  Then I just make a server side component
>> that builds up the javascript to populate the Dictionary.  Very cool,
>> I think this might work, will try it out tomorrow.
>>
>> see http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsDeferred.html
>>
>>
>> On Thu, Apr 14, 2011 at 11:09 PM, John Bush <john.bush at rsmart.com> wrote:
>>> 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
>>>
>>
>>
>>
>> --
>> John Bush
>> 602-490-0470
>>
>



-- 
John Bush
602-490-0470


More information about the gradebook2-dev mailing list