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

Add kendo ui localization message files to kendo culture artifact #193

Closed
Patrick1701 opened this issue Aug 31, 2015 · 16 comments
Closed

Add kendo ui localization message files to kendo culture artifact #193

Patrick1701 opened this issue Aug 31, 2015 · 16 comments

Comments

@Patrick1701
Copy link
Contributor

Hi Sebastien,
this would be a great enhancement of your new kendo culture artifact. :-D

http://docs.telerik.com/kendo-ui/framework/localization/overview

kind regards
Patrick

@sebfz1
Copy link
Owner

sebfz1 commented Aug 31, 2015

Hi Patrick, do you figure out setting the kendo culture globally as soon as a culture artifact is added/used?

@Patrick1701
Copy link
Contributor Author

Yes, I did... implemented a custom JavaScriptContentHeaderItem

    class SetCultureScriptHeaderItem extends JavaScriptContentHeaderItem{
        private static final long serialVersionUID = 1L;

        //OnDomReady did not work

        public SetCultureScriptHeaderItem() {
            super(String.format("kendo.culture('%s')", LocaleUtils.getLangageCode(Session.get().getLocale())), "kendo-culture", null);
        }

        @Override
        public Iterable<? extends HeaderItem> getDependencies() {
            List<HeaderItem> dependencies = new ArrayList<>();
            dependencies.add((JavaScriptHeaderItem.forReference(new KendoGlobalizeResourceReference(Session.get().getLocale()))));
            return dependencies;
        }
    }

@sebfz1
Copy link
Owner

sebfz1 commented Aug 31, 2015

Hi Patrick,

Thanks, I like this way!
If you would like to do a contribution:

  • rename SetCultureScriptHeaderItem to KendoCultureHeaderItem
  • move the class to wicket-kendo-ui-culture (close to KendoCulture)
  • add a 2nd #ctor with Locale
  • change default #ctor to call this(Session.get().getLocale())
  • javadoc
  • reformatting using supplied settings (well... this one is optional ;))
  • commit using this issue number (#193)

Thanks in advance? :P

Best regards,
Sebastien

@Patrick1701
Copy link
Contributor Author

If you would like to do a contribution:

Yes, I can do this... :-)

But, just a short question... this is not what I mean with #193...
Did you mix something up?

Patrick

@sebfz1
Copy link
Owner

sebfz1 commented Aug 31, 2015

#193 is this current issue, if you put a commit message like Added KendoCultureHeaderItem; fixes #193 then it will reference this issue and automatically close it when I will merge it...

@Patrick1701
Copy link
Contributor Author

I think, we are talking about different things...

The feature request I've created with #193 (this one) does not aim to have a kendo.culture('%s') script.
What I would like to have as feature is, your new kendo artifact should (in future) also provide and support kendo localization message files
See:
http://docs.telerik.com/kendo-ui/framework/localization/overview

I think you mixed this up, with the question I asked at the morning in the closed #155.

If I use 193 as commit message for your suggestion contributing KendoCultureHeaderItem (what I still want to do) this commit message would be wrong in sense of vcs history documentation.

The chat we currently have, is wrong at this place/issue.

Patrick

@sebfz1
Copy link
Owner

sebfz1 commented Aug 31, 2015

Hi Patrick,

You definitely choose the good day confuse myself! ;)

My first comment/question was about what you figured out (what I was supposed to understand with the link you provided), but reading at the subject again... well now I've got it ! :)

Ok, I will integrate this...

Thanks & best regards,
Sebastien.

@Patrick1701
Copy link
Contributor Author

Sorry, as well... I will pay some more attention not to asked different questions at the same time, concerning different issues which are somehow similar... :-P

If its ok for you, I will open an new issue to me for my contribution of KendoCultureHeaderItem?

@sebfz1
Copy link
Owner

sebfz1 commented Aug 31, 2015

Sorry, as well...

No worry :)

If its ok for you, I will open an new issue to me for my contribution of KendoCultureHeaderItem?

Yes that's better, because the other thread/issue is already closed...

Thanks,
Sebastien.

@martin-g
Copy link
Collaborator

change default #ctor to call this(Session.get().getLocale())

This concerns me a bit.
Session#get() is actually getOrCreate().
It will be better to use Request#getLocale() if there is no Session.

@sebfz1
Copy link
Owner

sebfz1 commented Aug 31, 2015

Hi Martin, thanks ! You are definitely right !
So, either we remove it, up to the user to supply the locale, either we have a Request and/or Session arg, up to the user to ensure it exists before the call. Because I think it is not the responsibily of this class to create a session...

@Patrick1701
Copy link
Contributor Author

Could be this call save?

    public KendoCultureHeaderItem() {
        this(RequestCycle.get().getRequest().getLocale());
    }

@Patrick1701
Copy link
Contributor Author

If yes, this would break a feature I need.
After a successfull login our system sets a user into a custom UserSession.
We use an UserSession.getLocale() override to get the current locale from the user (setting), not the one from the browser. So our locale is session-specific, not request-specific...

@sebfz1
Copy link
Owner

sebfz1 commented Aug 31, 2015

IMO, nope. I would prefer the Request arg option... And/or the Session,
this way the user has all posibilities... Furthermore, with a default ctor
like that, the user don't know from where we get the locale, this can lead
to confusion...

@martin-g
Copy link
Collaborator

Actually it is not a problem.
Session.get() will create a temporary Session. It will not bind an HttpSession.
IMO it is OK to use #get(), unless you do some heavy things in YourSession ctor or in YourApp#newSession().

@sebfz1
Copy link
Owner

sebfz1 commented Dec 29, 2015

Implemented; usage is the following:

public class MyApplication extends WebApplication
{
    public void init()
    {
        super.init();

        this.getHeaderContributorListenerCollection().add(new KendoMessageHeaderContributor(KendoMessage.FR_FR));
    }
}

public class MyPage extends WebPage
{
    public void renderHead(IHeaderResponse response)
    {
        super.renderHead(response);

        response.render(new KendoMessageHeaderItem(KendoMessage.FR_FR));
    }
}

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

3 participants