Module: DjiMqttConnect::Translations
- Defined in:
- lib/dji_mqtt_connect/translations.rb
Overview
Class Method Summary collapse
- .aircraft_hms_event_code_message(code:, sensor_index:, component_index:) ⇒ Object
- .aircraft_in_the_sky_hms_event_code_message(code:, sensor_index:, component_index:) ⇒ Object
-
.battery_position(sensor_index) ⇒ Object
If the text contains “%battery_index” and sensor_index is 0, use “left” to replace “%battery_index”, otherwise, use “right” to replace.
-
.dock_charging_rod_position(sensor_index) ⇒ Object
If the text contains “%charging_rod_index”, when sensor_index is 0, replace “%charging_rod_index” with “front”.
-
.dock_cover_position(sensor_index) ⇒ Object
If the text contains “%dock_cover_index” and sensor_index is 0, use “left” to replace “%dock_cover_index”, otherwise, use “right” to replace.
- .dock_hms_event_code_message(code:, sensor_index:) ⇒ Object
- .failed_result_summary(result) ⇒ Object
- .load_translations! ⇒ Object
- .position_name(position) ⇒ Object
- .result_message(result) ⇒ Object
-
.result_summary(result) ⇒ Object
Message Summaries ###.
- .sys_product_status_summary(method, result: 0, **data) ⇒ Object
- .thing_product_dock_osd_summary(**data) ⇒ Object
- .thing_product_drone_osd_summary(**data) ⇒ Object
- .thing_product_events_reply_summary(method, result: 0, **data) ⇒ Object
- .thing_product_events_summary(method, result: 0, **data) ⇒ Object
- .thing_product_osd_summary(**data) ⇒ Object
- .thing_product_remote_osd_summary(**data) ⇒ Object
- .thing_product_requests_reply_summary(method, result: 0, **data) ⇒ Object
- .thing_product_requests_summary(method, result: 0, **data) ⇒ Object
- .thing_product_services_reply_summary(method, result: 0, **data) ⇒ Object
- .thing_product_services_summary(method, **data) ⇒ Object
- .thing_product_state_reply_summary(result: 0, **data) ⇒ Object
- .thing_product_state_summary(result: 0, **data) ⇒ Object
Class Method Details
.aircraft_hms_event_code_message(code:, sensor_index:, component_index:) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dji_mqtt_connect/translations.rb', line 24 def (code:, sensor_index:, component_index:) I18n.translate( "fpv_tip_#{code}", alarmid: code, index: sensor_index + 1, component_index: component_index + 1, battery_index: battery_position(sensor_index), scope: "dji_mqtt_connect.hms_event_codes", default: code ) end |
.aircraft_in_the_sky_hms_event_code_message(code:, sensor_index:, component_index:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dji_mqtt_connect/translations.rb', line 12 def (code:, sensor_index:, component_index:) I18n.translate( "fpv_tip_#{code}_in_the_sky", alarmid: code, index: sensor_index + 1, component_index: component_index + 1, battery_index: battery_position(sensor_index), scope: "dji_mqtt_connect.hms_event_codes", default: code ) end |
.battery_position(sensor_index) ⇒ Object
If the text contains “%battery_index” and sensor_index is 0, use “left” to replace “%battery_index”, otherwise, use “right” to replace.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/dji_mqtt_connect/translations.rb', line 56 def battery_position(sensor_index) case sensor_index when 0 position_name("left") when 1 position_name("right") else position_name("unknown") end end |
.dock_charging_rod_position(sensor_index) ⇒ Object
If the text contains “%charging_rod_index”, when sensor_index is 0, replace “%charging_rod_index” with “front”. When sensor_index is 1, use “back” instead. When sensor_index is 2, use “left” instead. When sensor_index is 3, use “right” instead.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/dji_mqtt_connect/translations.rb', line 80 def dock_charging_rod_position(sensor_index) case sensor_index when 0 position_name("front") when 1 position_name("back") when 2 position_name("left") when 3 position_name("right") else position_name("unknown") end end |
.dock_cover_position(sensor_index) ⇒ Object
If the text contains “%dock_cover_index” and sensor_index is 0, use “left” to replace “%dock_cover_index”, otherwise, use “right” to replace.
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/dji_mqtt_connect/translations.rb', line 68 def dock_cover_position(sensor_index) case sensor_index when 0 position_name("left") when 1 position_name("right") else position_name("unknown") end end |
.dock_hms_event_code_message(code:, sensor_index:) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dji_mqtt_connect/translations.rb', line 36 def (code:, sensor_index:) I18n.translate( "dock_tip_#{code}", alarmid: code, dock_cover_index: dock_cover_position(sensor_index), charging_rod_index: dock_charging_rod_position(sensor_index), scope: "dji_mqtt_connect.hms_event_codes", default: code ) end |
.failed_result_summary(result) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/dji_mqtt_connect/translations.rb', line 105 def failed_result_summary(result) I18n.t( "dji_mqtt_connect.failed_result_summary", result: result, result_message: (result) ) end |
.load_translations! ⇒ Object
8 9 10 |
# File 'lib/dji_mqtt_connect/translations.rb', line 8 def load_translations! I18n.load_path += Dir[File.(File.join(__dir__, "../../config/locales/*.yml"))] end |
.position_name(position) ⇒ Object
51 52 53 |
# File 'lib/dji_mqtt_connect/translations.rb', line 51 def position_name(position) I18n.translate(position, scope: "dji_mqtt_connect.position", default: position) end |
.result_message(result) ⇒ Object
47 48 49 |
# File 'lib/dji_mqtt_connect/translations.rb', line 47 def (result) I18n.translate(result, scope: "dji_mqtt_connect.result_codes", default: :default) end |
.result_summary(result) ⇒ Object
Message Summaries ###
97 98 99 100 101 102 103 |
# File 'lib/dji_mqtt_connect/translations.rb', line 97 def result_summary(result) I18n.t( "dji_mqtt_connect.result_summary", result: result, result_message: (result) ) end |
.sys_product_status_summary(method, result: 0, **data) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/dji_mqtt_connect/translations.rb', line 113 def sys_product_status_summary(method, result: 0, **data) return failed_result_summary(result) if result != 0 I18n.t( method, **data, scope: "dji_mqtt_connect.sys_product_status_summary", default: :default, method: method, result: result_summary(result) ) end |
.thing_product_dock_osd_summary(**data) ⇒ Object
156 157 158 |
# File 'lib/dji_mqtt_connect/translations.rb', line 156 def thing_product_dock_osd_summary(**data) I18n.t("dock", **data, scope: "dji_mqtt_connect.thing_product_osd_summary", default: :default) end |
.thing_product_drone_osd_summary(**data) ⇒ Object
160 161 162 |
# File 'lib/dji_mqtt_connect/translations.rb', line 160 def thing_product_drone_osd_summary(**data) I18n.t("drone", **data, scope: "dji_mqtt_connect.thing_product_osd_summary", default: :default) end |
.thing_product_events_reply_summary(method, result: 0, **data) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/dji_mqtt_connect/translations.rb', line 139 def thing_product_events_reply_summary(method, result: 0, **data) return failed_result_summary(result) if result != 0 I18n.t( method, **data, scope: "dji_mqtt_connect.thing_product_events_reply_summary", default: :default, method: method, result: result_summary(result) ) end |
.thing_product_events_summary(method, result: 0, **data) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/dji_mqtt_connect/translations.rb', line 126 def thing_product_events_summary(method, result: 0, **data) return failed_result_summary(result) if result != 0 I18n.t( method, **data, scope: "dji_mqtt_connect.thing_product_events_summary", default: :default, method: method, result: result_summary(result) ) end |
.thing_product_osd_summary(**data) ⇒ Object
152 153 154 |
# File 'lib/dji_mqtt_connect/translations.rb', line 152 def thing_product_osd_summary(**data) I18n.t("default", **data, scope: "dji_mqtt_connect.thing_product_osd_summary") end |
.thing_product_remote_osd_summary(**data) ⇒ Object
164 165 166 |
# File 'lib/dji_mqtt_connect/translations.rb', line 164 def thing_product_remote_osd_summary(**data) I18n.t("remote", **data, scope: "dji_mqtt_connect.thing_product_osd_summary", default: :default) end |
.thing_product_requests_reply_summary(method, result: 0, **data) ⇒ Object
181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/dji_mqtt_connect/translations.rb', line 181 def thing_product_requests_reply_summary(method, result: 0, **data) return failed_result_summary(result) if result != 0 I18n.t( method, **data, scope: "dji_mqtt_connect.thing_product_requests_reply_summary", default: :default, method: method, result: result_summary(result) ) end |
.thing_product_requests_summary(method, result: 0, **data) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/dji_mqtt_connect/translations.rb', line 168 def thing_product_requests_summary(method, result: 0, **data) return failed_result_summary(result) if result != 0 I18n.t( method, **data, scope: "dji_mqtt_connect.thing_product_requests_summary", default: :default, method: method, result: result_summary(result) ) end |
.thing_product_services_reply_summary(method, result: 0, **data) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/dji_mqtt_connect/translations.rb', line 204 def thing_product_services_reply_summary(method, result: 0, **data) return failed_result_summary(result) if result != 0 I18n.t( method, **data, scope: "dji_mqtt_connect.thing_product_services_reply_summary", default: :default, method: method, result: result_summary(result) ) end |
.thing_product_services_summary(method, **data) ⇒ Object
194 195 196 197 198 199 200 201 202 |
# File 'lib/dji_mqtt_connect/translations.rb', line 194 def thing_product_services_summary(method, **data) I18n.t( method, **data, scope: "dji_mqtt_connect.thing_product_services_summary", default: :default, method: method ) end |
.thing_product_state_reply_summary(result: 0, **data) ⇒ Object
229 230 231 232 233 234 235 236 237 |
# File 'lib/dji_mqtt_connect/translations.rb', line 229 def thing_product_state_reply_summary(result: 0, **data) return failed_result_summary(result) if result != 0 I18n.t( "dji_mqtt_connect.thing_product_state_reply_summary", **data, result: result_summary(result) ) end |
.thing_product_state_summary(result: 0, **data) ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/dji_mqtt_connect/translations.rb', line 217 def thing_product_state_summary(result: 0, **data) return failed_result_summary(result) if result != 0 I18n.t( "state", **data, scope: "dji_mqtt_connect.thing_product_state_summary", default: :default, result: result_summary(result) ) end |