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

Label/description handling @text strings when building a channel type, a channel or a discovery result #2546

Open
2 of 3 tasks
lolodomo opened this issue Oct 28, 2021 · 9 comments
Labels
i18n/l10n Internationalization/Localization

Comments

@lolodomo
Copy link
Contributor

lolodomo commented Oct 28, 2021

When building a channel type, a channel or a discovery result, it would be interesting to be able to pass a @text string referencing a property file for the label and for the description.
This will help binding internationalization.

@cweitkamp : as you are our specialist for i18n, do you thing this is doable and easy ?

  • Discovery result
  • Channel type
  • Channel
@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 29, 2021

For discovery results, we already have a search in property files so maybe it is just a bug if @text is not supported. Unfortunately I don't find immediately the class implementing the current behavior.

@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 29, 2021

Found for discovery

String key = I18nUtil.stripConstantOr(defaultLabel, () -> inferKey(discoveryResult, "label"));

So it should work in theory with @text.

Edit: the problem is when a binding uses DiscoveryResultBuilder.create rather than ThingDiscovered which is the case for mDNS or UPNP discovery for example.
Edit2; the core framework is then calling ThingDiscovered in such a case, so it should work.

@wborn wborn added the i18n/l10n Internationalization/Localization label Oct 29, 2021
@cweitkamp
Copy link
Contributor

IIRC discovery already supports translations. And I bet it was implemented by yourself back in the days (see eclipse-archived/smarthome#4177).

I am not sure about channel types. If a binding provides custom channel types there must be a registry implementation too. If so it should be responsible for correct localization. Same for channel group types.

Currently I do not have an idea how to handle channels. At best they should always use an already available channel type and inherit label/description/options and so on from it. I am aware that everything can be overwritten. Same for channel groups.

@lolodomo
Copy link
Contributor Author

lolodomo commented Oct 29, 2021

For discovery, using @text is not working, I will have to investigate a little more why and in what case exactly it fails.
If I use "@text/toto" as label, I see"@text/toto" In MainUI. It behaves as if the property is not found.

@lolodomo
Copy link
Contributor Author

It probably fails because MDNSDiscoveryService is a core service so properties are not searched in the binding bundle but in one core bundle.

lolodomo added a commit to lolodomo/openhab-core that referenced this issue Oct 29, 2021
Related to openhab#2546

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
cweitkamp pushed a commit that referenced this issue Nov 3, 2021
* mDNS / UPnP discovery internationalization

Related to #2546

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor Author

lolodomo commented Nov 17, 2021

Discovery is now OK.

Remains the creation of dynamic channel types and channels.

For channel type, I have the feeling I could use ChannelTypeI18nLocalizationService.

@J-N-K
Copy link
Member

J-N-K commented May 21, 2022

@lolodomo Are you still working on this?

@lolodomo
Copy link
Contributor Author

This is on my TODO list, but not very high to be honest.

@lolodomo
Copy link
Contributor Author

For channel types, I can confirm that ChannelTypeI18nLocalizationService .createLocalizedChannelType is the solution to localize channel types built dynamically.

splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this issue Jul 12, 2023
* mDNS / UPnP discovery internationalization

Related to openhab#2546

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
GitOrigin-RevId: 089b9d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n/l10n Internationalization/Localization
Projects
None yet
Development

No branches or pull requests

4 participants