Conversation
Only the page renderer needs to translate texts but the proposed solution could easily be enhanced to provide translation to any widget renderer if needed. |
I chose dynamic policy for referenced services added but I am not sure if I should rather use static policy ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally makes sense to me. I left some comments inline.
@resetnow any further thoughts?
@@ -12,6 +12,8 @@ | |||
<implementation class="org.eclipse.smarthome.ui.basic.internal.render.PageRenderer"/> | |||
|
|||
<reference bind="setItemUIRegistry" cardinality="1..1" interface="org.eclipse.smarthome.ui.items.ItemUIRegistry" name="ItemUIRegistry" policy="dynamic" unbind="unsetItemUIRegistry"/> | |||
<reference bind="setLocaleProvider" cardinality="1..1" interface="org.eclipse.smarthome.core.i18n.LocaleProvider" name="LocaleProvider" policy="dynamic" unbind="unsetLocaleProvider"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you expected: they should all be static!
Especially as they are "1..1", the "dynamic" makes no sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SJKA: why is it defined like that with dynamic policy for ItemUIRegistry ? Is it something I should fix ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please fix it. It makes no sense.
protected void activate(ComponentContext context) { | ||
this.bundleContext = context.getBundleContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can change the signature to activate(BundleContext context)
and you will get it directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
|
||
protected String localizeText(String key) { | ||
String result = ""; | ||
if (this.i18nProvider != null && this.locale != null && I18nUtil.isConstant(key)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can they be null
? You specified a "1..1" relation, so you can rely on them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was in case the referenced services were not yet loaded. But ok, I will suppress the null test as they will be there if I use a static policy.
@@ -66,10 +75,28 @@ public ItemUIRegistry getItemUIRegistry() { | |||
return itemUIRegistry; | |||
} | |||
|
|||
public void setLocaleProvider(LocaleProvider localeProvider) { | |||
this.locale = localeProvider.getLocale(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep the localeProvider and call localeProvider.getLocale()
whenever you need it. Otherwise you won't notice if the user changes the locale settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes ense. I realize we have the same mistake elsewhere, sometimes introduced by myself !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. We are going to need a proper templating system sometime in the future, or at least a simple wrapper around String.replace.
Fixes #4327 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Done. All review comments taken into account. |
Thanks! |
Fixes #4327
Signed-off-by: Laurent Garnier lg.hc@free.fr