48
48
import org .openhab .core .config .discovery .AbstractThingHandlerDiscoveryService ;
49
49
import org .openhab .core .config .discovery .DiscoveryResult ;
50
50
import org .openhab .core .config .discovery .DiscoveryResultBuilder ;
51
+ import org .openhab .core .i18n .LocaleProvider ;
52
+ import org .openhab .core .i18n .TranslationProvider ;
51
53
import org .openhab .core .thing .Thing ;
52
54
import org .openhab .core .thing .ThingStatus ;
53
55
import org .openhab .core .thing .ThingTypeUID ;
54
56
import org .openhab .core .thing .ThingUID ;
55
57
import org .osgi .service .component .annotations .Component ;
58
+ import org .osgi .service .component .annotations .Reference ;
56
59
import org .osgi .service .component .annotations .ServiceScope ;
57
60
import org .slf4j .Logger ;
58
61
import org .slf4j .LoggerFactory ;
@@ -83,6 +86,16 @@ public FreeboxOsDiscoveryService() {
83
86
DISCOVERY_TIME_SECONDS );
84
87
}
85
88
89
+ @ Reference (unbind = "-" )
90
+ public void bindTranslationProvider (TranslationProvider translationProvider ) {
91
+ this .i18nProvider = translationProvider ;
92
+ }
93
+
94
+ @ Reference (unbind = "-" )
95
+ public void bindLocaleProvider (LocaleProvider localeProvider ) {
96
+ this .localeProvider = localeProvider ;
97
+ }
98
+
86
99
@ Override
87
100
protected void startBackgroundDiscovery () {
88
101
stopBackgroundDiscovery ();
@@ -162,7 +175,7 @@ private void discoverPhone(ThingUID bridgeUID) {
162
175
ThingUID thingUID = new ThingUID (THING_TYPE_CALL , bridgeUID , "calls" );
163
176
logger .debug ("Adding new Call thing {} to inbox" , thingUID );
164
177
DiscoveryResult discoveryResult = DiscoveryResultBuilder .create (thingUID ).withBridge (bridgeUID )
165
- .withLabel ("Phone Calls " ).build ();
178
+ .withLabel ("@text/discovery.call.label " ).build ();
166
179
thingDiscovered (discoveryResult );
167
180
}
168
181
}
@@ -181,7 +194,8 @@ private void discoverHosts(ThingUID bridgeUID, List<LanHost> lanHosts) {
181
194
bridgeUID , mac .toHexString (false ));
182
195
logger .debug ("Adding new Freebox Network Host {} to inbox" , thingUID );
183
196
DiscoveryResultBuilder builder = DiscoveryResultBuilder .create (thingUID ).withBridge (bridgeUID )
184
- .withLabel (lanHost .getPrimaryName ().orElse ("Network Device %s" .formatted (macString )))
197
+ .withLabel (lanHost .getPrimaryName ()
198
+ .orElse ("@text/discovery.network-device.label [ \" %s\" ]" .formatted (macString )))
185
199
.withTTL (300 ).withProperty (Thing .PROPERTY_MAC_ADDRESS , macString )
186
200
.withRepresentationProperty (Thing .PROPERTY_MAC_ADDRESS );
187
201
thingDiscovered (builder .build ());
@@ -201,7 +215,8 @@ private void discoverVM(ThingUID bridgeUID, List<LanHost> lanHosts) {
201
215
logger .debug ("Adding new VM Device {} to inbox" , thingUID );
202
216
DiscoveryResult discoveryResult = DiscoveryResultBuilder .create (thingUID ).withBridge (bridgeUID )
203
217
.withRepresentationProperty (Thing .PROPERTY_MAC_ADDRESS )
204
- .withLabel ("%s (VM)" .formatted (vm .name ())).withProperty (ClientConfiguration .ID , vm .id ())
218
+ .withLabel ("@text/discovery.vm.label [ \" %s\" ]" .formatted (vm .name ()))
219
+ .withProperty (ClientConfiguration .ID , vm .id ())
205
220
.withProperty (Thing .PROPERTY_MAC_ADDRESS , mac .toColonDelimitedString ()).build ();
206
221
thingDiscovered (discoveryResult );
207
222
});
@@ -219,7 +234,7 @@ private void discoverRepeater(ThingUID bridgeUID, List<LanHost> lanHosts) {
219
234
220
235
ThingUID thingUID = new ThingUID (THING_TYPE_REPEATER , bridgeUID , Integer .toString (repeater .id ()));
221
236
DiscoveryResult discoveryResult = DiscoveryResultBuilder .create (thingUID ).withBridge (bridgeUID )
222
- .withLabel ("Repeater %s " .formatted (repeater .name ()))
237
+ .withLabel ("@text/discovery.repeater.label [ \" %s \" ] " .formatted (repeater .name ()))
223
238
.withProperty (Thing .PROPERTY_MAC_ADDRESS , mac .toColonDelimitedString ())
224
239
.withProperty (ClientConfiguration .ID , repeater .id ())
225
240
.withRepresentationProperty (Thing .PROPERTY_MAC_ADDRESS ).build ();
0 commit comments