From 0037bb63fe66f340fc0a0695fd04cd63f0c03c0e Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sat, 20 Jul 2019 10:52:12 +0000 Subject: [PATCH] Add translation example --- README.md | 1 + custom_components/blueprint/.translations/sensor.nb.json | 5 +++++ custom_components/blueprint/sensor.py | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 custom_components/blueprint/.translations/sensor.nb.json diff --git a/README.md b/README.md index 4d84672..8d70f32 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ File | Purpose `.github/ISSUE_TEMPLATE/issue.md` | Template for issues `.github/settings.yml` | Probot settings to control the repository settings. `.vscode/taks.json` | Tasks for the devcontainer. +`custom_components/blueprint/.translations/sensor.nb.json` | [Translation files.](https://developers.home-assistant.io/docs/en/next/internationalization_custom_component_localization.html#translation-strings) `custom_components/blueprint/__init__.py` | The component file for the integration. `custom_components/blueprint/binary_sensor.py` | Binary sensor platform for the integration. `custom_components/blueprint/const.py` | A file to hold shared variables/constants for the entire integration. diff --git a/custom_components/blueprint/.translations/sensor.nb.json b/custom_components/blueprint/.translations/sensor.nb.json new file mode 100644 index 0000000..ed34ceb --- /dev/null +++ b/custom_components/blueprint/.translations/sensor.nb.json @@ -0,0 +1,5 @@ +{ + "state": { + "Some sample static text.": "Eksempel tekst." + } +} \ No newline at end of file diff --git a/custom_components/blueprint/sensor.py b/custom_components/blueprint/sensor.py index 05fa2a4..7eb53cb 100644 --- a/custom_components/blueprint/sensor.py +++ b/custom_components/blueprint/sensor.py @@ -29,7 +29,7 @@ class BlueprintSensor(Entity): # Check the data and update the value. if updated.get("static") is None: - self._state = self._status + self._state = self._state else: self._state = updated.get("static")