From f70dac0a61a6534940a44574cfb3cb88e3126ddc Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sat, 4 Jun 2022 00:52:32 -0700 Subject: [PATCH 1/2] Add application credentials translation documentation --- docs/core/platform/application_credentials.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/core/platform/application_credentials.md b/docs/core/platform/application_credentials.md index 7d465933..9fb81c0e 100644 --- a/docs/core/platform/application_credentials.md +++ b/docs/core/platform/application_credentials.md @@ -124,3 +124,29 @@ A `ClientCredential` represents a client credential provided by the user. | ------------- | ---- | ------------------------------------------------------------------------- | ----------- | | client_id | str | **Required** | The OAuth Client ID provided by the user. | | client_secret | str | **Required** | The OAuth Client Secret provided by the user. | + +## Translations + +Translations for Application Credentials are defined under the `application_credentials` key in the component translation file `strings.json`. As an example: + +```json +{ + "application_credentials": { + "description": "Navigate to the [developer console]({console_url}) to create credentials then enter them below.", + } +} +``` + +You may optionally add description placehlder keys that are added to the message by adding a new method in `application_credentials.py` like the following: + +```python +from homeassistant.core import HomeAssistant + +async def async_get_description_placeholders(hass: HomeAssistant) -> dict[str, str]: + """Return description placeholders for the credentials dialog.""" + return { + "console_url": "https://example.com/developer/console", + } +``` + +While developing locally, you will need to run `python3 -m script.translations develop` to see changes made to `strings.json` [More info on translating Home Assistant.](translations.md) \ No newline at end of file From 6d913e34f32e36bd93b5bc4200070b27227e8c70 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sat, 4 Jun 2022 09:05:12 -0700 Subject: [PATCH 2/2] Update docs/core/platform/application_credentials.md Co-authored-by: Martin Hjelmare --- docs/core/platform/application_credentials.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/platform/application_credentials.md b/docs/core/platform/application_credentials.md index 9fb81c0e..d63a3c5e 100644 --- a/docs/core/platform/application_credentials.md +++ b/docs/core/platform/application_credentials.md @@ -137,7 +137,7 @@ Translations for Application Credentials are defined under the `application_cred } ``` -You may optionally add description placehlder keys that are added to the message by adding a new method in `application_credentials.py` like the following: +You may optionally add description placeholder keys that are added to the message by adding a new method in `application_credentials.py` like the following: ```python from homeassistant.core import HomeAssistant