Commit Graph

64 Commits

Author SHA1 Message Date
epenet
5df7092f41 Improve formatting in core files (#135256)
* Adjust core files formatting

* Adjust translations script
2025-01-10 09:08:37 +01:00
Abílio Costa
4776865584 Add unit translations for github integration (#130538)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-11-20 18:43:17 +01:00
Erik Montnemery
771575cfc5 Make statistics validation create issue registry issues (#122595)
* Make statistics validation create issue registry issues

* Disable creating issue about outdated MariaDB version in tests

* Use call_soon_threadsafe instead of run_callback_threadsafe

* Update tests

* Fix flapping test

* Disable creating issue about outdated SQLite version in tests

* Implement agreed changes

* Add translation strings for issue titles

* Update test
2024-09-25 11:11:11 +02:00
epenet
01be5d5f6b Move fixtures to decorators in core tests (#119675) 2024-06-14 13:32:42 +02:00
epenet
38a6e666a7 Add missing return type to some test functions (#119665) 2024-06-14 08:26:45 +02:00
Erik Montnemery
6c15351c18 Add support for common references in strings.json (#118783)
* Add support for common references in strings.json

* Update tests
2024-06-07 20:59:26 +02:00
epenet
37fc16d7b6 Fix incorrect patch type hint in main conftest (#118461) 2024-06-02 15:34:30 +02:00
J. Nick Koston
87989a88cd Remove translation and icon component path functions (#118214)
These functions have been stripped down to always return
the same path so there was no longer a need to have a
function for this. This is left-over cleanup from
previous refactoring.
2024-05-27 10:35:52 +02:00
Erik Montnemery
acc78b26f7 Rename some translation helper tests (#117248) 2024-05-11 14:17:53 +01:00
J. Nick Koston
d7aa24fa50 Only load translations for an integration once per test session (#117118) 2024-05-11 12:00:02 +09:00
J. Nick Koston
33412dd9f6 Remove unused legacy state translations (#112023)
* Remove unused state translations

There have been replaced with entity translations
https://github.com/home-assistant/developers.home-assistant/pull/1557
https://github.com/home-assistant/core/pull/82701

* nothing does merging anymore

* useless dispatch

* remove

* remove platform code from hassfest

* preen

* Update homeassistant/helpers/translation.py

* ruff

* fix merge

* check is impossible now since we already know if translations exist or not

* keep the function for now

* remove unreachable code since we filter out `.` before now

* reduce

* reduce

* fix merge conflict (again)
2024-04-14 07:13:17 -04:00
Joost Lekkerkerker
6bb4e7d62c Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Sid
00ec7f11f0 Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2024-03-19 09:01:07 +01:00
J. Nick Koston
08416974c9 Avoid trying to load translations for integrations that have none (#112683) 2024-03-08 14:21:44 -10:00
Marc Mueller
a6b842f818 Add empty line after module docstring (2) [other] (#112738) 2024-03-08 19:16:38 +01:00
J. Nick Koston
982c8f8f4a Fix incorrect scope on checking files to load in translations (#112457)
discovered in https://github.com/home-assistant/core/pull/112295#discussion_r1513505710

We only checked if the last language had files to load
instead of all of them. The checks for each language
are the same because the only reason we would skip
a language is a missing/broken integration or the integration
is a single file. Both of these loop conditions are always
the same reguardless of the language so the check worked
2024-03-05 23:46:24 -05:00
J. Nick Koston
fbabbc8f92 Limit legacy state translations to custom components (#112295)
* Limit legacy state translations to custom components

We were trying to load **thousands** of `*.light.json`, `*.switch.json` files at run time that did not exist.

There have been replaced with entity translations: https://github.com/home-assistant/developers.home-assistant/pull/1557 https://github.com/home-assistant/core/pull/82701

https://github.com/home-assistant/core/pull/112023 will completely remove them, but
for now we will only load them for custom components to reduce the number
of files having to be examined

* reduce

* reduce

* reduce

* reduce

* comment

* coverage

* try to remove empty dict in loaded_translations fallback when missing
2024-03-05 17:27:45 -05:00
J. Nick Koston
dd80157dc7 Load translations at setup time if they were not loaded at bootstrap (#110921) 2024-02-24 11:31:25 -10:00
J. Nick Koston
9ce1ec414e Reduce overhead to load multiple languages in translations (#111028)
* Reduce overhead to load multiple languages in translations

Instead of loading in a task, we now group everything
to be loaded into a single executor job

* fixes

* fixes

* fixes

* fixes

* fixes

* update tests

* add missing coverage (was existing)
2024-02-20 21:52:28 -05:00
J. Nick Koston
16653ff5d0 Group loading of translations for integrations to reduce executor jobs at startup (#110674) 2024-02-17 21:08:55 -06:00
J. Nick Koston
9bc130c131 Ensure translations for other integrations can be loaded if one integration fails (#110748)
* load failure

* merge
2024-02-17 21:01:36 -05:00
J. Nick Koston
2cb0249f0a Add filter to translation event listeners to avoid creating tasks (#110732) 2024-02-16 12:13:23 -06:00
J. Nick Koston
37897ee384 Move late import of config flows in loader to load time (#110688)
* Move late import of config flows in loader to load time

There does not seem to be any reason to import the
generated flows late. Import them at load time
with the rest of the generated files

* tests
2024-02-16 07:55:12 +01:00
Piotr Machowski
a2f4e99994 Add state_translated function to jinja templates (#96906)
* Add state_translated jinja function

* Add tests for load_state_translations_to_cache and get_cached_translations

* Cleanup state_translated template

* Add tests for state_translated jinja function

* Apply black formatting

* Improve code quality

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Apply suggestions from code review

* Prevent invalid components from loading translations

* Refactor loading translations to cache

* Adjust code issues

* Update homeassistant/helpers/translation.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Refactor listeners that trigger translation loading

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Apply suggestions from code review

* Adjust invalid function calls, fix code styling

* Adjust code quality

* Extract async_translate_state function

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Apply suggestions from code review

* Fix tests

* Fix tests

---------

Co-authored-by: Piotr Machowski <PiotrMachowski@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-02-10 10:47:56 +01:00
Franck Nijhof
01372024f5 Add icon translations support (#103294)
Co-authored-by: Robert Resch <robert@resch.dev>
Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
2024-01-19 16:56:56 +01:00
Erik Montnemery
8a9f9b94ef Fix call to async_setup_component in translation test (#107807) 2024-01-11 10:09:32 -10:00
Michael
eb01998395 Add support for placeholders in entity name translations (#104453)
* add placeholder support to entity name translation

* add negativ tests

* make property also available via description

* fix doc string in translation_placeholders()

* fix detection of placeholder

* validate placeholders for localized strings

* add test

* Cache translation_placeholders property

* Make translation_placeholders uncondotionally return dict

* Fall back to unsubstituted name in case of mismatch

* Only replace failing translations with English

* Update snapshots

* Blow up on non stable releases

* Fix test

* Update entity.py

---------

Co-authored-by: Erik <erik@montnemery.com>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-01-03 17:34:47 +01:00
Erik Montnemery
84e74e4c74 Reverse component path (#104087)
* Reverse component path

* Update translations helper

* Fix

* Revert incorrect change of PLATFORM_FORMAT

* Fix use of PLATFORM_FORMAT in tts

* Fix ios
2023-12-05 08:43:58 +01:00
Franck Nijhof
f9919bb7cf Add pre-defined entity name translations (#89792) 2023-03-16 21:10:20 +01:00
Franck Nijhof
f32b7859b8 Restructure translations for entity components (#89702) 2023-03-16 12:16:08 +01:00
epenet
5f25b71df7 Add type hints to core tests (#88478) 2023-02-20 11:42:56 +01:00
epenet
c98b4e3204 Add typing to tests with single hass argument (2) (#87675)
* Add typing to tests with single hass argument (2)

* a few more
2023-02-08 08:51:43 +01:00
epenet
59ca7780fa Add typing to tests with single hass argument (#87631) 2023-02-07 15:01:16 +01:00
epenet
4142f0d15d Add return type to tests without arguments (#87613)
* Add return type to tests without arguments

* Black

* Cancel fixture amends
2023-02-07 14:20:06 +01:00
Franck Nijhof
939eef3b28 Remove translations from Core (#87543)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-02-06 15:06:43 +01:00
Franck Nijhof
5e81d28116 Update black to 23.1.0 (#87188) 2023-02-02 18:35:24 +01:00
Franck Nijhof
e50a531cd9 Code styling tweaks to the tests - Part 2 (#86662)
Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
2023-01-26 01:23:53 +01:00
J. Nick Koston
61cc9f5288 Consolidate executor jobs when loading integration manifests (#75176) 2022-07-14 13:06:08 -07:00
J. Nick Koston
a614ddca28 Support requesting translations for multiple integrations in a single request (#71979) 2022-05-17 01:23:11 -05:00
Paulus Schoutsen
3213091b8d Add integration type (#68349) 2022-03-20 20:38:13 -07:00
Paulus Schoutsen
a4d9019ffc Refactor persistent notification to no longer route all data via a service (#57157)
* Convert persistent notification tests to async

* Create/dismiss persistent notifications in exposed functions, not service calls

* Fix notify persistent_notification

* Remove setting up persistent_notification

* Drop more setups

* Empty methods

* Undeprecate sync methods because too big task

* Fix setup clearing notifications

* Fix a bunch of tests

* Fix more tests

* Uno mas

* Test persistent notification events

* Clean up stale comment

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-10-07 12:58:00 +02:00
Joakim Sørensen
2f10f59717 Block custom integrations with missing or invalid version (#49916) 2021-05-17 15:48:41 +02:00
Franck Nijhof
65cf2fcb6f Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
J. Nick Koston
c7f35b20fb Make all translations cacheable (#42892) 2020-11-09 22:36:45 +01:00
J. Nick Koston
5ca4b4cd0f Set the translations cache under the lock (#42470) 2020-10-27 22:02:38 +01:00
Paulus Schoutsen
276f3afb00 Do async_setup_platform in background (#36244)
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-05-31 22:18:30 -07:00
Paulus Schoutsen
b3201523aa Fix translation merging for custom components without translations (#35032) 2020-05-01 11:34:09 -07:00
Paulus Schoutsen
ec47216388 Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -07:00
Paulus Schoutsen
e9ff1940d6 Translation fixes and tweaks (#34489)
Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>
2020-04-21 17:57:21 -07:00
Joakim Sørensen
730a257f3c Rename translations dir for integrations (#34494) 2020-04-21 16:11:05 -07:00