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

Fix translatability #244

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 89 additions & 58 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2693,12 +2693,19 @@
"en": "Camera",
"nl": "Camera"
},
"capabilitiesOptions": {
"alarm_motion": {
"title": {
"en": "Motion Detected"
}
}
},
"id": "camera",
"settings": [
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every camera."
"en": "NOTE: Some settings are not supported by every camera."
},
"children": [
{
Expand Down Expand Up @@ -2967,7 +2974,7 @@
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every circuit breaker."
"en": "NOTE: Some settings are not supported by every circuit breaker."
},
"children": [
{
Expand Down Expand Up @@ -3194,7 +3201,7 @@
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every device."
"en": "NOTE: Some settings are not supported by every device."
},
"children": [
{
Expand Down Expand Up @@ -3276,7 +3283,7 @@
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every dimmer."
"en": "NOTE: Some settings are not supported by every dimmer."
},
"children": [
{
Expand Down Expand Up @@ -3577,24 +3584,32 @@
"value": false
},
{
"id": "fan_direction",
"type": "dropdown",
"type": "group",
"label": {
"en": "Fan direction"
"en": "NOTE: Some settings are not supported by every device."
},
"value": "forward",
"values": [
{
"id": "forward",
"label": {
"en": "Forward"
}
},
"children": [
{
"id": "backward",
"id": "fan_direction",
"type": "dropdown",
"label": {
"en": "Backward"
}
"en": "Fan direction"
},
"value": "forward",
"values": [
{
"id": "forward",
"label": {
"en": "Forward"
}
},
{
"id": "backward",
"label": {
"en": "Backward"
}
}
]
}
]
},
Expand Down Expand Up @@ -3665,17 +3680,25 @@
"id": "garage_door",
"settings": [
{
"id": "tr_timecon",
"type": "number",
"type": "group",
"label": {
"en": "Door travel time"
},
"hint": {
"en": "The time it takes for the door to open or close."
"en": "NOTE: Some settings are not supported by every device."
},
"units": {
"en": "seconds"
}
"children": [
{
"id": "tr_timecon",
"type": "number",
"label": {
"en": "Door travel time"
},
"hint": {
"en": "The time it takes for the door to open or close."
},
"units": {
"en": "seconds"
}
}
]
},
{
"id": "deviceSpecification",
Expand Down Expand Up @@ -4154,7 +4177,7 @@
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every light."
"en": "NOTE: Some settings are not supported by every light."
},
"children": [
{
Expand Down Expand Up @@ -5018,39 +5041,47 @@
"id": "siren",
"settings": [
{
"id": "alarm_volume",
"type": "dropdown",
"type": "group",
"label": {
"en": "Alarm volume level"
},
"hint": {
"en": "The volume level of the siren."
"en": "NOTE: Some settings are not supported by every device."
},
"value": "middle",
"values": [
{
"id": "low",
"label": {
"en": "Low"
}
},
{
"id": "middle",
"label": {
"en": "Middle"
}
},
{
"id": "high",
"label": {
"en": "High"
}
},
"children": [
{
"id": "mute",
"id": "alarm_volume",
"type": "dropdown",
"label": {
"en": "Muted"
}
"en": "Alarm volume level"
},
"hint": {
"en": "The volume level of the siren."
},
"value": "middle",
"values": [
{
"id": "low",
"label": {
"en": "Low"
}
},
{
"id": "middle",
"label": {
"en": "Middle"
}
},
{
"id": "high",
"label": {
"en": "High"
}
},
{
"id": "mute",
"label": {
"en": "Muted"
}
}
]
}
]
},
Expand Down Expand Up @@ -5123,7 +5154,7 @@
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every socket."
"en": "NOTE: Some settings are not supported by every socket."
},
"children": [
{
Expand Down
19 changes: 2 additions & 17 deletions drivers/camera/TuyaCameraConstants.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
// TODO make translatable
import TRANSLATIONS from './translations.json';
// Map from setting id to human-readable label
export const CAMERA_SETTING_LABELS = {
motion_switch: 'Motion Detection',
motion_tracking: 'Motion Tracking',
decibel_switch: 'Sound Detection',
cry_detection_switch: 'Crying Baby Detection',
pet_detection: 'Pet Detection',
motion_sensitivity: 'Motion Sensitivity',
decibel_sensitivity: 'Sound Sensitivity',
basic_nightvision: 'Night Mode',
basic_device_volume: 'Device Volume',
basic_anti_flicker: 'Anti-Flicker',
basic_osd: 'Video Timestamp',
basic_flip: 'Flip Video',
basic_indicator: 'Status Indicator',
alarm_timeout: 'Alarm Timeout',
} as const;
export const CAMERA_SETTING_LABELS = TRANSLATIONS.setting_labels;

// Capabilities that are simple commands/statuses
export const SIMPLE_CAMERA_CAPABILITIES = {
Expand Down
9 changes: 8 additions & 1 deletion drivers/camera/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
"en": "Camera",
"nl": "Camera"
},
"capabilities": ["alarm_motion", "alarm_sound", "alarm_crying_child", "alarm_pet"]
"capabilities": ["alarm_motion", "alarm_sound", "alarm_crying_child", "alarm_pet"],
"capabilitiesOptions": {
"alarm_motion": {
"title": {
"en": "Motion Detected"
}
}
}
}
2 changes: 1 addition & 1 deletion drivers/camera/driver.settings.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every camera."
"en": "NOTE: Some settings are not supported by every camera."
},
"children": [
{
Expand Down
9 changes: 0 additions & 9 deletions drivers/camera/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,6 @@ module.exports = class TuyaOAuth2DriverCamera extends TuyaOAuth2Driver {
}
}

// Match title to other camera alarms
if (props.capabilities.includes('alarm_motion')) {
props.capabilitiesOptions['alarm_motion'] = {
title: {
en: 'Motion Detected',
},
};
}

return props;
}
};
18 changes: 18 additions & 0 deletions drivers/camera/translations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"setting_labels": {
"motion_switch": { "en": "Motion Detection" },
"motion_tracking": { "en": "Motion Tracking" },
"decibel_switch": { "en": "Sound Detection" },
"cry_detection_switch": { "en": "Crying Baby Detection" },
"pet_detection": { "en": "Pet Detection" },
"motion_sensitivity": { "en": "Motion Sensitivity" },
"decibel_sensitivity": { "en": "Sound Sensitivity" },
"basic_nightvision": { "en": "Night Mode" },
"basic_device_volume": { "en": "Device Volume" },
"basic_anti_flicker": { "en": "Anti-Flicker" },
"basic_osd": { "en": "Video Timestamp" },
"basic_flip": { "en": "Flip Video" },
"basic_indicator": { "en": "Status Indicator" },
"alarm_timeout": { "en": "Alarm Timeout" }
}
}
7 changes: 3 additions & 4 deletions drivers/circuit_breaker/TuyaCircuitBreakerConstants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import TRANSLATIONS from './translations.json';

export const CIRCUIT_BREAKER_CAPABILITIES_MAPPING = {
switch: 'onoff',
cur_current: 'measure_current',
Expand All @@ -24,7 +26,4 @@ export type TuyaCircuitBreakerSettings = {
relay_status: 'power_on' | 'power_off' | 'last';
};

export const CIRCUIT_BREAKER_SETTING_LABELS = {
child_lock: 'Child Lock',
relay_status: 'Turn On Behavior',
} as const;
export const CIRCUIT_BREAKER_SETTING_LABELS = TRANSLATIONS.setting_labels;
2 changes: 1 addition & 1 deletion drivers/circuit_breaker/driver.settings.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every circuit breaker."
"en": "NOTE: Some settings are not supported by every circuit breaker."
},
"children": [
{
Expand Down
6 changes: 6 additions & 0 deletions drivers/circuit_breaker/translations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"setting_labels": {
"child_lock": { "en": "Child Lock" },
"relay_status": { "en": "Turn On Behavior" }
}
}
8 changes: 3 additions & 5 deletions drivers/curtain/TuyaCurtainConstants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import TRANSLATIONS from './translations.json';

export const CURTAIN_CAPABILITY_MAPPING = {
control: 'windowcoverings_state',
mach_operate: 'windowcoverings_state',
Expand All @@ -21,8 +23,4 @@ export type TuyaCurtainSettings = {
control_back_mode: 'forward' | 'back'; // inverse
};

export const CURTAIN_SETTING_LABELS = {
opposite: 'Inverse direction',
control_back: 'Inverse direction',
control_back_mode: 'Inverse direction',
};
export const CURTAIN_SETTING_LABELS = TRANSLATIONS.setting_labels;
2 changes: 1 addition & 1 deletion drivers/curtain/driver.settings.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every device."
"en": "NOTE: Some settings are not supported by every device."
},
"children": [
{
Expand Down
7 changes: 7 additions & 0 deletions drivers/curtain/translations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"setting_labels": {
"opposite": { "en": "Inverse direction" },
"control_back": { "en": "Inverse direction" },
"control_back_mode": { "en": "Inverse direction" }
}
}
15 changes: 3 additions & 12 deletions drivers/dimmer/TuyaDimmerConstants.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
// TODO make translatable
import TRANSLATIONS from './translations.json';

// Map from setting id to human-readable label
export const DIMMER_SETTING_LABELS = {
brightness_min_1: 'Minimum Brightness 1',
brightness_max_1: 'Maximum Brightness 1',
brightness_min_2: 'Minimum Brightness 2',
brightness_max_2: 'Maximum Brightness 2',
brightness_min_3: 'Minimum Brightness 3',
brightness_max_3: 'Maximum Brightness 3',
led_type_1: 'Lamp Type 1',
led_type_2: 'Lamp Type 2',
led_type_3: 'Lamp Type 3',
} as const;
export const DIMMER_SETTING_LABELS = TRANSLATIONS.setting_labels;

export const SIMPLE_DIMMER_CAPABILITIES = {
read_write: ['switch_led_1', 'bright_value_1', 'switch_led_2', 'bright_value_2', 'switch_led_3', 'bright_value_3'],
Expand Down
2 changes: 1 addition & 1 deletion drivers/dimmer/driver.settings.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type": "group",
"label": {
"en": "CAUTION: Some settings are not supported by every dimmer."
"en": "NOTE: Some settings are not supported by every dimmer."
},
"children": [
{
Expand Down
Loading
Loading