Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New kendo artifact #155

Closed
solomax opened this issue Feb 12, 2015 · 27 comments
Closed

New kendo artifact #155

solomax opened this issue Feb 12, 2015 · 27 comments

Comments

@solomax
Copy link
Contributor

solomax commented Feb 12, 2015

I believe it might be useful to have artifact like wicket-jqueryui-kendo-culture to have all up-to-date "language" files in one place.

This artifact should have one "anchor class" (for ex. KengoGlobalizationAnchor.java) with no methods and JS files with kendo locales.

In this case one can use code like:
public static void renderTelericLocale(IHeaderResponse response, Locale l) {
response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(KengoGlobalizationAnchor.class
, String.format("kendo.culture.%s.min.js", l.toLanguageTag()))));
}

to localize kendo widgets

@sebfz1
Copy link
Owner

sebfz1 commented Feb 12, 2015

Hi Maxim,

I will do it shortly!
Alternate question: does Locale#toLanguageTag actually exists?

Best regards,
Sebastien

@martin-g
Copy link
Collaborator

It is in JDK 1.7+

@solomax
Copy link
Contributor Author

solomax commented Feb 12, 2015

Yes :) but java7 only

I'm afraid your LocaleUtils.getLangageCode method will produce wrong result for locale like "en" (without country)

@sebfz1
Copy link
Owner

sebfz1 commented Feb 12, 2015

Oh, thanks Martin & Maxim, because I don't have it my jdk1.7.0_65...
Yes, I was thinking about providing an helper too... So, if it is not supported in all jdk1.7x, I was figuring out to use LocaleUtils#getLangageCode, which is supposed to work even if there no "country" (actually it should be been named the "culture" here)...

/**
 * Gets the language-code (eg: xx-XX) from a given {@link Locale}
 * @param locale the {@link Locale}
 * @return the language-code
 */
public static String getLangageCode(Locale locale)
{
    if (!Strings.isEmpty(locale.getCountry()))
    {
        return String.format("%s-%s", locale.getLanguage(), locale.getCountry());
    }

    return locale.getLanguage();
}

Best regards,
Sebastien

@martin-g
Copy link
Collaborator

I believe the method is there since 1.7.0_0. It should be in _65 as well.

@sebfz1
Copy link
Owner

sebfz1 commented Feb 12, 2015

Well, my eclipse project was pointing to a old jre (but it was supposed to be 7). I changed to jdk1.7.0_65 and I've got it! :) Thanks!

@sebfz1
Copy link
Owner

sebfz1 commented Feb 12, 2015

Should be able to commit today (javadoc todo). Usage will be the following:

@Override
public void renderHead(IHeaderResponse response)
{
    super.renderHead(response);

    response.render(JavaScriptHeaderItem.forReference(new KendoGlobalizeResourceReference(Locale.FRENCH))); // wicket7.x
    // response.render(JavaScriptHeaderItem.forReference(new KendoGlobalizeResourceReference(KendoCulture.FR_FR)));
    // response.render(JavaScriptHeaderItem.forReference(new KendoGlobalizeResourceReference("fr-FR"))); // or fr only
}

@solomax
Copy link
Contributor Author

solomax commented Feb 12, 2015

Great!
I like it :)

@sebfz1 sebfz1 closed this as completed in 6b96922 Feb 12, 2015
@sebfz1
Copy link
Owner

sebfz1 commented Feb 12, 2015

Oops, bad commit, correcting this asap...

sebfz1 pushed a commit that referenced this issue Feb 12, 2015
@sebfz1
Copy link
Owner

sebfz1 commented Feb 12, 2015

Deployed 6.19.1-SNAPSHOT
Deployed 7.0.0-SNAPSHOT

Additional note about new KendoGlobalizeResourceReference(Locale.FRENCH)));

  • wicket7.x will use locale#toLanguageTag()
  • wicket6.x will use LocaleUtils#getLangageCode(locale)

@solomax
Copy link
Contributor Author

solomax commented Feb 12, 2015

Thanks a lot!
Will try to test ASAP :)))

@solomax
Copy link
Contributor Author

solomax commented Feb 13, 2015

Everything works as expected :))
Thanks a lot!

@solomax
Copy link
Contributor Author

solomax commented Feb 16, 2015

Hello Sebastien,
what are your plans on releasing 6.19.1? ;)

@sebfz1
Copy link
Owner

sebfz1 commented Feb 16, 2015

Hi Maxim,

Well, if you need it, I have to release it this week...

Best regards,
Sebastien

@solomax
Copy link
Contributor Author

solomax commented Feb 16, 2015

There is no rush actually, for 6.19 based version we are using ant for build and it doesn't work very well with maven snapshots.
And I would like to commit my changes, cause otherwise I'll forget about them :(
If you can release next week it will be perfect for me :)

@sebfz1
Copy link
Owner

sebfz1 commented Feb 16, 2015

I will do it asap (this week) otherwise you will not have it before 2/3 weeks!.. (if you see what I mean... ;))

@solomax
Copy link
Contributor Author

solomax commented Feb 16, 2015

great!
Thanks one more time :)

@sebfz1
Copy link
Owner

sebfz1 commented Feb 21, 2015

Hi Maxim,

6.19.1 has been released, and 7.0.0-SNAPSHOT redeployed.
Hope all will be ok, I won't be available next 2 weeks...

Enjoy!
Sebastien.

@solomax
Copy link
Contributor Author

solomax commented Feb 23, 2015

Thanks a lot Sebastien!

@Patrick1701
Copy link
Contributor

Hi Sebastien,
is this already featured for JQueryUI by using JQueryGlobalizeResourceReference.get() as HeaderItem?

kind regards
Patrick

@sebfz1
Copy link
Owner

sebfz1 commented Jul 14, 2015

Hi Patrick,

Sorry, just saw this question. The answer is "almost" :)

JQueryGlobalizeResourceReference already embeed globalize.js and is automatically added to header items... as soon as he user set it explicitly in JQueryLibrarySettings, like this:

// Application#init()
JQueryLibrarySettings settings = new JQueryLibrarySettings();
settings.setJQueryGlobalizeReference(JQueryGlobalizeResourceReference.get());

this.setJavaScriptLibrarySettings(settings);

Best regards,
Sebastien.

@Patrick1701
Copy link
Contributor

Ah, ok, thanx... :)

Minor additonal question.
All these settings made in Application#init(), don't mean the jquery/kendo ui header items (scripts etc) are always rendered to pages, it means they are only rendered, if at least one jquery/kendo-ui component is present on page, because components take care for that, right?

If I want them always being avaliable (for instance to feature a support of direct/hardcoded calls to jquery/kendo-ui javascript effects direct from my page-markup) I need to add them somewhere in my (border) page hierarchy manually like:

MyBasePage
...
    @Override
    public void renderHead(HtmlHeaderContainer container) {
        super.renderHead(container);
        IHeaderResponse response = container.getHeaderResponse();

        //JQueryUI / always present
        response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(JQueryUIResourceReference.get())));

        //KendoUI / always present
        response.render(JavaScriptHeaderItem.forReference(KendoUILibrarySettings.get().getJavaScriptReference()));

    }

Is it correct? :)

kind regards
Patrick

@martin-g
Copy link
Collaborator

s/renderHead(HtmlHeaderContainer/renderHead(IHeaderResponse/

If you need them at every page then you can use org.apache.wicket.Application#getHeaderContributorListeners().add(...)

@Patrick1701
Copy link
Contributor

Hi Martin,
great, thanx a lot...

Patrick

@Patrick1701
Copy link
Contributor

Hi Sebastien,
currently I'm upgrading to Wicket 6.20 and I would like integrate this feature.

Does it just provide the header contribution of the particular i18n culture file, or does it also enables the current culture by locale on js-client-side?
Is it mandatory to implement some script execution, which calls kendo.setCulture('xyz')?

best regards
Patrick

@sebfz1
Copy link
Owner

sebfz1 commented Aug 31, 2015

Hi Patrick,

Nice to see you arround!

Does it just provide the header contribution

Nope, it provide the resource reference for the given language/culture, up to you to contribute to the header:

@Override
public void renderHead(IHeaderResponse response)
{
    super.renderHead(response);

    // response.render(JavaScriptHeaderItem.forReference(new KendoGlobalizeResourceReference("fr"))); // or fr-FR
    // response.render(JavaScriptHeaderItem.forReference(new KendoGlobalizeResourceReference(KendoCulture.FR_FR)));
    // response.render(JavaScriptHeaderItem.forReference(new KendoGlobalizeResourceReference(Locale.FRENCH)));
}

Is it mandatory to implement some script execution, which calls kendo.setCulture('xyz')?

Yes, exactly. Or if a (Wicket Kendo UI) component already support #setCulture or a Locale you can use it directly, like for the DatePicker:

// Constructor, which use Locale and Kendo UI Globalization
new DatePicker("datepicker", Model.of(new Date()), Locale.FRANCE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants