Skip to content

Commit

Permalink
[ES] Fix intents with untranslated state (#1770)
Browse files Browse the repository at this point in the history
* Adding Spanish untranslated changes

* Fixing after tests

* Fixing Spanish translation of under-zero temperatures for weather states
  • Loading branch information
davefx authored Dec 13, 2023
1 parent 85f4cc5 commit 62549af
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 31 deletions.
70 changes: 62 additions & 8 deletions responses/es/HassGetState.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ responses:
{% endif %}
{% endif %}
someone_yesno: |
{% if query.matched %}
{% else %}
No, está
{% if state.attributes.get("untranslated_state") == "not_home" %}
{{ state.state }}
{% else %}
en {{ state.state }}
{% endif %}
{% endif %}
any: |
{% if query.matched %}
{% set match = query.matched | map(attribute="name") | sort | list %}
Expand Down Expand Up @@ -54,11 +66,7 @@ responses:
{% else %}
{% set no_match = query.unmatched | map(attribute="name") | sort | list %}
{% if no_match | length > 4 %}
{% if state.domain == "person" %}
No, ni {{ no_match[:3] | join(", ni ") }} ni otros {{ (no_match | length - 3) }} están en {{slots.state}}
{% else %}
No, ni {{ no_match[:3] | join(", ni ") }} ni otros {{ (no_match | length - 3) }} dispositivos tienen ese estado
{% endif %}
No, ni {{ no_match[:3] | join(", ni ") }} ni otros {{ (no_match | length - 3) }} dispositivos tienen ese estado
{% else %}
{% if no_match | length == 1 %}
{% if state.domain == "person" %}
Expand All @@ -81,6 +89,36 @@ responses:
{% endif %}
{% endif %}
everybody: |
{% if not query.unmatched: %}
{% else %}
{% set no_match = query.unmatched | map(attribute="name") | sort | list %}
{% if no_match | length > 4 %}
No, ni {{ no_match[:3] | join(", ni ") }} ni otros {{ (no_match | length - 3) }} están
{% if state.attributes.get("untranslated_state") == "not_home" %}
{{ state.state }}
{% else %}
en {{ state.state }}
{% endif %}
{%- else -%}
{% if no_match | length == 1 %}
No, {{ no_match|first }} no está
{% else %}
No, ni
{% for name in no_match -%}
{% if not loop.first and not loop.last %}, ni {% elif loop.last and not loop.first %} ni {% endif -%}
{{ name }}
{%- endfor %} están
{% endif %}
{% if state.attributes.get("untranslated_state") == "not_home" %}
{{ state.state }}
{% else %}
en {{ state.state }}
{% endif %}
{% endif %}
{% endif %}
which: |
{% if not query.matched %}
Ningún dispositivo
Expand All @@ -96,12 +134,28 @@ responses:
{% endif %}
{% endif %}
who: |
{% if not query.matched %}
Nadie
{% else: %}
{% set match = query.matched | map(attribute="name") | sort | list %}
{% if match | length > 4 %}
{{ match[:3] | join(", ") }} y otros {{ (match | length - 3) }} más
{% else %}
{%- for name in match -%}
{% if not loop.first and not loop.last %}, {% elif loop.last and not loop.first %} y {% endif -%}
{{ name }}
{%- endfor -%}
{% endif %}
{% endif %}
how_many: |
{{ query.matched | length }}
where: |
{% if state == "not_home" %}
{{ slots.name | capitalize }} está fuera
{{ slots.name | capitalize }} está
{% if state.attributes.get("untranslated_state") == "not_home" %}
{{ state.state }}
{% else %}
{{ slots.name | capitalize }} está en {{ state.state }}
en {{ state.state }}
{% endif %}
7 changes: 6 additions & 1 deletion responses/es/HassGetWeather.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ responses:
'windy': 'Vientos',
'windy-variant': 'Vientos y nubes'
} %}
{{ weather_condition.get((state.state | string).lower(), "") }}, con una temperatura de {{ state.attributes.get('temperature') }} {{ state.attributes.get('temperature_unit') }}
{{ weather_condition.get((state.attributes.get('untranslated_state') | string).lower(), "") }}, con una temperatura de
{% if state.attributes.get('temperature') | int < 0 %}
{{ (state.attributes.get('temperature')|float |abs|string).rstrip('.0') }} {{ state.attributes.get('temperature_unit') }} bajo cero
{% else %}
{{ state.attributes.get('temperature') }} {{ state.attributes.get('temperature_unit') }}
{% endif %}
7 changes: 7 additions & 0 deletions sentences/es/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ lists:
- in: "cerrad(o|a)[s]"
out: "closed"

presence_states:
values:
- in: "casa"
out: "home"
- in: "fuera"
out: "not_home"

shopping_list_item:
wildcard: true

Expand Down
13 changes: 9 additions & 4 deletions sentences/es/person_HassGetState.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,37 @@ intents:
domain: person

- sentences:
- "[<dime> ]<se_encuentra> <name> [en] [el|la[s]|los] {presence_states:state}"
- "[<dime> ]<se_encuentra> <name> [en] [el|la[s]|los] {zone:state}"
response: one_yesno
response: someone_yesno
requires_context:
domain: person
slots:
domain: person

- sentences:
- "[<dime> ](<se_encuentra>|hay) alguien [en] [el|la[s]|los] {presence_states:state}"
- "[<dime> ](<se_encuentra>|hay) alguien [en] [el|la[s]|los] {zone:state}"
response: any
slots:
domain: person

- sentences:
- "[<dime> ]<se_encuentra>[n] (todos|todo el mundo) en [el|la[s]|los] {zone:state}"
response: all
- "[<dime> ]<se_encuentra>[n] (todos|todo el mundo) [en] [el|la[s]|los] {presence_states:state}"
- "[<dime> ]<se_encuentra>[n] (todos|todo el mundo) [en] [el|la[s]|los] {zone:state}"
response: everybody
slots:
domain: person

- sentences:
- "[<dime> ]quién[es] <se_encuentra>[n] [en] [el|la[s]|los] {presence_states:state}"
- "[<dime> ]quién[es] <se_encuentra>[n] [en] [el|la[s]|los] {zone:state}"
response: which
response: who
slots:
domain: person

- sentences:
- "[<dime> ]cuánta[s] (gente|personas) (hay|<se_encuentra>[n]) [en] [el|la[s]|los] {presence_states:state}"
- "[<dime> ]cuánta[s] (gente|personas) (hay|<se_encuentra>[n]) [en] [el|la[s]|los] {zone:state}"
response: how_many
slots:
Expand Down
28 changes: 22 additions & 6 deletions tests/es/_fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -711,29 +711,45 @@ entities:

- name: "Madrid"
id: "weather.madrid"
state: "rainy"
state:
in: "Lluvia y tormenta eléctrica"
out: "lightning-rainy"
attributes:
temperature: "18"
temperature_unit: "°C"
untranslated_state: "lightning-rainy"

- name: "Ávila"
id: "weather.avila"
state: "clear"
state:
in: "Despejado"
out: "clear"
attributes:
temperature: "-4"
temperature_unit: "°C"
untranslated_state: "clear"

- name: "José"
id: "person.jose"
state: "casa"
state:
in: "Casa"
out: "home"
attributes:
untranslated_state: "home"

- name: "Ada"
id: "person.ada"
state: "Trabajo"
state: "trabajo"
attributes:
untranslated_state: "trabajo"

- name: "Juan"
id: "person.john"
state: "not_home"
id: "person.juan"
state:
in: "Fuera"
out: "not_home"
attributes:
untranslated_state: "not_home"

- name: "Mercadona"
id: "todo.mercadona"
Expand Down
121 changes: 112 additions & 9 deletions tests/es/person_HassGetState.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tests:
slots:
domain: person
name: José
response: "José está en casa"
response: "José está en Casa"

- sentences:
- "dónde está Ada"
Expand All @@ -16,7 +16,16 @@ tests:
slots:
domain: person
name: Ada
response: "Ada está en Trabajo"
response: "Ada está en trabajo"

- sentences:
- "dónde está Juan"
intent:
name: HassGetState
slots:
domain: person
name: Juan
response: "Juan está Fuera"

- sentences:
- "está Ada en casa"
Expand All @@ -25,42 +34,136 @@ tests:
slots:
domain: person
name: Ada
state: casa
response: "No, está en Trabajo"
state: home
response: "No, está en trabajo"

- sentences:
- "está Juan en el Trabajo"
intent:
name: HassGetState
slots:
domain: person
name: Juan
state: trabajo
response: "No, está Fuera"

- sentences:
- "está José fuera"
intent:
name: HassGetState
slots:
domain: person
name: José
state: not_home
response: "No, está en Casa"

- sentences:
- "hay alguien en casa"
intent:
name: HassGetState
slots:
domain: person
state: casa
state: home
response: "Sí, José"

- sentences:
- "hay alguien en el Trabajo"
intent:
name: HassGetState
slots:
domain: person
state: trabajo
response: "Sí, Ada"

- sentences:
- "hay alguien fuera"
intent:
name: HassGetState
slots:
domain: person
state: not_home
response: "Sí, Juan"

- sentences:
- "está todo el mundo en casa"
- "están todos en casa"
intent:
name: HassGetState
slots:
domain: person
state: casa
response: "No, ni Ada ni Juan están en casa"
state: home
response: "No, ni Ada ni Juan están en Casa"

- sentences:
- "está todo el mundo en el Trabajo"
- "están todos en el trabajo"
intent:
name: HassGetState
slots:
domain: person
state: trabajo
response: "No, ni José ni Juan están en trabajo"

- sentences:
- "está todo el mundo fuera"
- "están todos fuera"
intent:
name: HassGetState
slots:
domain: person
state: not_home
response: "No, ni Ada ni José están Fuera"

- sentences:
- "quién está en casa"
intent:
name: HassGetState
slots:
domain: person
state: casa
state: home
response: "José"

- sentences:
- "quién está en el Trabajo"
intent:
name: HassGetState
slots:
domain: person
state: trabajo
response: "Ada"

- sentences:
- "quién está fuera"
intent:
name: HassGetState
slots:
domain: person
state: not_home
response: "Juan"

- sentences:
- "cuánta gente hay en casa"
intent:
name: HassGetState
slots:
domain: person
state: casa
state: home
response: "1"

- sentences:
- "cuánta gente hay en el Trabajo"
intent:
name: HassGetState
slots:
domain: person
state: trabajo
response: "1"

- sentences:
- "cuánta gente hay fuera"
intent:
name: HassGetState
slots:
domain: person
state: not_home
response: "1"
Loading

0 comments on commit 62549af

Please sign in to comment.