HACS custom integration - Config Flow strings are not loading

Hi, I tried to create a Core integration but it got declined because of unstable 3rd party API.
I am in the process of submitting the integration to HACS instead, however I’m having a weird issue.

When I copied the files manually to the custom_components folder, everything looks/works fine, my config flow loads the placeholders of the fields and shows the errors as it should, no worries.

After that I created a repo and moved all the integration files there, updated docs/readme/manifest (according to the docs) and added the integration via HACS as a custom repository.

The issue is that the Config Flow does not show ANY strings this way. Just blank string fields.
When I try to trigger an incorrect flow, it errors out correctly, however it still doesn’t show any error messages.

Other than that I think it works correctly - it updates entities, loads messages and whatnot. It’s just that the strings are missing.

Examples:

The flow when the integration is copied in custom_components:
image

The flow when using the integration through HACS:
image

Hi, i had the same issue the other day when working on my integration, it was a pain to figure out as well.
On custom integrations it seems like you need a folder titled “translations”, and have a copy of strings.json in there called en.json (or any other language you might want).
I believe the strings.json gets completely ignored but still needs to be there?

I can see the strings.json in the original PR on the HA github, and you use this syntax:

[%key:common::config_flow::error::cannot_connect%]

I personally haven’t managed to make that work, either, so i ended up writing literal strings.
Here’s an example of what the file structure should look like: https://github.com/home-assistant/example-custom-config/tree/master/custom_components/detailed_hello_world_push

I believe this all has to do with custom integrations not having access to the translations of the core integrations. The docs say that lokalize strings should work, so if anyone knows how to get those to work on custom integrations I’d love to know as well.
https://developers.home-assistant.io/docs/internationalization/custom_integration

Side note: be sure to do a hard refresh of your browser while testing changes.

1 Like

I’m not using that syntax, I changed it to hardcoded strings and I did multiple hard refreshes - still no luck.

However I don’t have a folder called translations and I don’t have the en.json file, I’m used to this being autogenerated and .gitignore’d.

I will add it and see how it goes, thank you.

Nobody/nothing will autogenerate the translations for your custom component :wink:
As said above, you need both strings.json and translations/<lang>.json, including en.json, which is a copy of strings.json if you used english.

2 Likes

Correct. That was my issue, now everything works as intended!

Thank you!