- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.2k
 
Introducing description placeholders for service action translations #2844
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||
| --- | ||||||
| author: Jan Bouwhuis | ||||||
| authorURL: https://github.com/jbouwh | ||||||
| authorImageURL: https://avatars.githubusercontent.com/u/7188918?s=96&v=4 | ||||||
| title: Introducing description placeholders for service action translations | ||||||
| --- | ||||||
| It is now possible to use translation placeholders for (custom) service actions. | ||||||
| 
     | 
||||||
| The [service action example](/docs/core/integration-quality-scale/rules/action-setup?_highlight=hass.services.async_register#example-implementation) now shows how to supply the available description place holders during the registration of the service action. | ||||||
| 
     | 
||||||
| URLs that are part of the service transaction should be moved out of the service descriptions and translation strings using the description placeholders. | ||||||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify terminology and destination for moving URLs. Line 11 uses "service transaction," which is non-standard; services are not typically called "transactions." Additionally, the phrasing "moved out of...using" obscures where URLs should go. Revise to clarify that URLs belong in description placeholders. -URLs that are part of the service transaction should be moved out of the service descriptions and translation strings using the description placeholders.
+Move URLs from service descriptions and translation strings into description placeholders.This revision uses direct phrasing per documentation guidelines and clarifies the intended action. 📝 Committable suggestion
 
        Suggested change
       
    
 🤖 Prompt for AI Agents | 
||||||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -22,9 +22,10 @@ The example below is a snippet where the service action is registered in the `as | |
| In this example, the service call requires a configuration entry id as parameter. | ||
| This is used to first fetch the configuration entry, and then check if it is loaded. | ||
| If the configuration entry does not exist or the configuration entry that we found is not loaded, we raise a relevant error which is shown to the user. | ||
| Optional description placeholders can be supplied. | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Expand explanation to introduce what description placeholders are. Line 25 introduces description placeholders but provides no context about their purpose. Readers will encounter the term before the code example and need to understand why they're useful (e.g., for translations and externalized configuration). Revise to be more informative. -Optional description placeholders can be supplied.
+Supply description placeholders to enable translation of service parameters—for example, to reference external resources like documentation URLs that need to be localized or updated independently of the service description.Alternatively, combine the explanation with the code block introduction: -Optional description placeholders can be supplied.
-
-`__init__py`:
```python {13-20} showLineNumbers
+`__init__py`:
+
+Use the `description_placeholders` parameter to supply translatable values, such as URLs:
+
```python {13-20} showLineNumbersEither approach makes the feature's purpose clear before the code example. 🤖 Prompt for AI Agents | 
||
| 
     | 
||
| `__init__py`: | ||
| ```python {13-19} showLineNumbers | ||
| ```python {13-20} showLineNumbers | ||
| async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: | ||
| """Set up my integration.""" | ||
| 
     | 
||
| 
        
          
        
         | 
    @@ -43,6 +44,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: | |
| async_get_schedule, | ||
| schema=SERVICE_GET_SCHEDULE_SCHEMA, | ||
| supports_response=SupportsResponse.ONLY, | ||
| description_placeholders={"example_url": "https://schedule.example.com"} | ||
| ) | ||
| ``` | ||
| 
     | 
||
| 
          
            
          
           | 
    ||
Uh oh!
There was an error while loading. Please reload this page.