mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-01-10 02:04:26 +01:00
Bug fixed: plurals failed on other locales
This commit is contained in:
@@ -278,9 +278,11 @@ public class ProximityService extends BleMulticonnectProfileService implements P
|
||||
final int numberOfManagedDevices = managedDevices.size();
|
||||
if (numberOfManagedDevices == 1) {
|
||||
final String name = getDeviceName(managedDevices.get(0));
|
||||
builder.setContentText(getResources().getQuantityString(R.plurals.proximity_notification_text_nothing_connected, numberOfManagedDevices, name));
|
||||
// We don't use plurals here, as we only have the default language and 'one' is not in every language (versions differ in %d or %s)
|
||||
// and throw an exception in e.g. in Chinese
|
||||
builder.setContentText(getString(R.string.proximity_notification_text_nothing_connected_one_disconnected, name));
|
||||
} else {
|
||||
builder.setContentText(getResources().getQuantityString(R.plurals.proximity_notification_text_nothing_connected, numberOfManagedDevices, numberOfManagedDevices));
|
||||
builder.setContentText(getString(R.string.proximity_notification_text_nothing_connected_number_disconnected, numberOfManagedDevices));
|
||||
}
|
||||
} else {
|
||||
// There are some proximity tags connected
|
||||
@@ -289,9 +291,9 @@ public class ProximityService extends BleMulticonnectProfileService implements P
|
||||
final int numberOfConnectedDevices = connectedDevices.size();
|
||||
if (numberOfConnectedDevices == 1) {
|
||||
final String name = getDeviceName(connectedDevices.get(0));
|
||||
text.append(getResources().getQuantityString(R.plurals.proximity_notification_summary_text, numberOfConnectedDevices, name));
|
||||
text.append(getString(R.string.proximity_notification_summary_text_name, name));
|
||||
} else {
|
||||
text.append(getResources().getQuantityString(R.plurals.proximity_notification_summary_text, numberOfConnectedDevices, numberOfConnectedDevices));
|
||||
text.append(getString(R.string.proximity_notification_summary_text_number, numberOfConnectedDevices));
|
||||
}
|
||||
|
||||
// If there are some disconnected devices, also print them
|
||||
@@ -302,14 +304,14 @@ public class ProximityService extends BleMulticonnectProfileService implements P
|
||||
for (final BluetoothDevice device : managedDevices) {
|
||||
if (!isConnected(device)) {
|
||||
final String name = getDeviceName(device);
|
||||
text.append(getResources().getQuantityString(R.plurals.proximity_notification_text_nothing_connected, numberOfDisconnectedDevices, name));
|
||||
text.append(getString(R.string.proximity_notification_text_nothing_connected_one_disconnected, name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (numberOfDisconnectedDevices > 1) {
|
||||
text.append(", ");
|
||||
// If there are more, just write number of them
|
||||
text.append(getResources().getQuantityString(R.plurals.proximity_notification_text_nothing_connected, numberOfDisconnectedDevices, numberOfDisconnectedDevices));
|
||||
text.append(getString(R.string.proximity_notification_text_nothing_connected_number_disconnected, numberOfDisconnectedDevices));
|
||||
}
|
||||
builder.setContentText(text);
|
||||
}
|
||||
|
||||
@@ -32,19 +32,11 @@
|
||||
<string name="proximity_action_silent">Silent</string>
|
||||
<string name="proximity_default_device_name">Proximity Tag</string>
|
||||
|
||||
<plurals name="proximity_notification_text_nothing_connected">
|
||||
<item quantity="one">%s is disconnected.</item>
|
||||
<item quantity="few">%d tags are disconnected.</item>
|
||||
<item quantity="many">%d tags are disconnected.</item>
|
||||
<item quantity="other">%d tags are disconnected.</item>
|
||||
</plurals>
|
||||
<string name="proximity_notification_text_nothing_connected_one_disconnected">%s is disconnected.</string>
|
||||
<string name="proximity_notification_text_nothing_connected_number_disconnected">%d is disconnected.</string>
|
||||
<string name="proximity_notification_text">%s connected</string>
|
||||
<plurals name="proximity_notification_summary_text">
|
||||
<item quantity="one">%s is connected.</item>
|
||||
<item quantity="few">%d tags connected.</item>
|
||||
<item quantity="many">%d tags connected.</item>
|
||||
<item quantity="other">%d tags connected.</item>
|
||||
</plurals>
|
||||
<string name="proximity_notification_summary_text_name">%s is connected.</string>
|
||||
<string name="proximity_notification_summary_text_number">%d is connected.</string>
|
||||
<string name="proximity_notification_linkloss_alert">%s is getting away!</string>
|
||||
|
||||
<string name="proximity_devices_title">YOUR TAGS</string>
|
||||
|
||||
Reference in New Issue
Block a user