From caad458b48506e1c0b48886ec10c67aa932597d4 Mon Sep 17 00:00:00 2001 From: Ari Date: Mon, 29 Aug 2022 12:13:26 -0400 Subject: [PATCH] added some initial work on intl --- .../AutomationEditor/AutoInfoBox.tsx | 22 +-- .../src/components/AutomationEditor/index.tsx | 39 +++-- .../AutomationManager/Loaded/automationDB.ts | 28 ++-- .../AutomationManager/Loaded/index.tsx | 11 +- .../AutomationManager/Loaded/state.ts | 16 +- .../AutomationManager/MetadataBox/Tags.tsx | 10 +- .../AutomationManager/MetadataBox/index.tsx | 32 +++- .../AutomationManager/Sidebar/index.tsx | 12 +- .../components/AutomationManager/index.tsx | 64 +++++--- .../ConditionEditor/ConditionNodeBase.tsx | 4 + .../ConditionEditor/editorRender.tsx | 58 ++++--- .../CollectionNode/CollectionNodeElement.tsx | 15 +- .../SequenceNode/SequenceNodeElement.tsx | 15 +- webapp/src/components/DeviceEditor/index.tsx | 15 +- .../src/components/Inputs/Base/InputYaml.tsx | 8 +- webapp/src/components/Inputs/InputList.tsx | 18 ++- .../components/Inputs/InputMultiSelect.tsx | 13 +- .../NodeEditor/OptionManager/index.tsx | 10 +- webapp/src/components/NodeEditor/index.tsx | 24 +-- webapp/src/haService/index.ts | 30 +++- webapp/src/lang/eng.json | 148 +++++++++++++++++ webapp/src/lang/fra.json | 151 ++++++++++++++++++ 22 files changed, 588 insertions(+), 155 deletions(-) create mode 100644 webapp/src/lang/eng.json create mode 100644 webapp/src/lang/fra.json diff --git a/webapp/src/components/AutomationEditor/AutoInfoBox.tsx b/webapp/src/components/AutomationEditor/AutoInfoBox.tsx index de254d0..27443e7 100644 --- a/webapp/src/components/AutomationEditor/AutoInfoBox.tsx +++ b/webapp/src/components/AutomationEditor/AutoInfoBox.tsx @@ -10,6 +10,7 @@ import { AddIcon, TrashIcon } from "components/Icons"; import InputAutoText from "components/Inputs/InputAutoText"; import { TagDB } from "components/AutomationManager/TagDB"; import { ButtonIcon } from "components/Icons/ButtonIcons"; +import { useLang } from "lang"; export interface AutoInfoBoxProps { metadata: AutomationMetadata & Partial; @@ -26,6 +27,7 @@ export const AutoInfoBox: FC = ({ tagDB, }) => { // state + const langStore = useLang(); const [newTag, setNewTag] = useState<[string, string]>(["", ""]); const [[errorIndex, error], _setError] = useState<[number | "new", string]>([ -1, @@ -54,12 +56,12 @@ export const AutoInfoBox: FC = ({ ); const validTagName = (newName: string): string | undefined => { if (newName.length <= 0) { - return "Name must be at least 1 character long"; + return langStore.get("VALIDATION_AUTOMATION_NAME"); } // eslint-disable-next-line for (const [name, _] of tags) { if (name.trim() === newName.trim()) { - return `The tag '${name}' already exists`; + return langStore.get("VALIDATION_TAG_EXISTS", { name }); } } }; @@ -101,23 +103,23 @@ export const AutoInfoBox: FC = ({
= ({
updateTagName(v, tagIndex)} options={foundNewTagNames} error={errorIndex === tagIndex ? error : undefined} /> onUpdateTags(v, tagIndex)} options={tagDB.getTagValues(tagName)} error={errorIndex === tagIndex ? error : undefined} @@ -153,14 +155,14 @@ export const AutoInfoBox: FC = ({
setNewTag([v, newTag[1]])} options={foundNewTagNames} error={errorIndex === "new" ? error : undefined} /> setNewTag([newTag[0], v])} options={tagDB.getTagValues(newTag[0])} error={errorIndex === "new" ? error : undefined} diff --git a/webapp/src/components/AutomationEditor/index.tsx b/webapp/src/components/AutomationEditor/index.tsx index f2fee79..f08f2c4 100644 --- a/webapp/src/components/AutomationEditor/index.tsx +++ b/webapp/src/components/AutomationEditor/index.tsx @@ -31,6 +31,7 @@ import { MiniFailure } from "types/validators/helper"; import { AutoInfoBox } from "./AutoInfoBox"; import { useAutomatioEditorState, EditorData } from "./state"; +import { useLang } from "lang"; interface Props { automation?: AutomationData | BareAutomationData; @@ -51,6 +52,7 @@ export const AutomationEditor: FC = ({ isNew, }) => { // state + const langStore = useLang(); const { state, updateSequence, @@ -131,7 +133,7 @@ export const AutomationEditor: FC = ({
{state.data.id}
updateMetadata( { @@ -145,7 +147,7 @@ export const AutomationEditor: FC = ({ = ({ options={[ { id: "single", - label: "Do not start a new run. Issue a warning.", + label: langStore.get("MODE_SIGNLE_LABEL"), }, { id: "parallel", - label: - "Start a new, independent run in parallel with previous runs.", + label: langStore.get("MODE_SIGNLE_PARALLEL"), }, { id: "queued", - label: - "Start a new run after all previous runs complete. Runs are guaranteed to execute in the order they were queued.", + label: langStore.get("MODE_SIGNLE_QUEUED"), }, { id: "restart", - label: "Start a new run after first stopping previous run.", + label: langStore.get("MODE_SIGNLE_RESTART"), }, ]} /> updateMetadata( { @@ -204,7 +204,7 @@ export const AutomationEditor: FC = ({ onClick={() => setFlipped(!flipped)} > {flipped ? "flip_to_front" : "flip_to_back"} - Flip + {langStore.get("FLIPP")} )} {state.status === "changed" && ( @@ -217,7 +217,7 @@ export const AutomationEditor: FC = ({ onClick={save} disabled={state.status !== "changed"} > - Save + {langStore.get("SAVE")}
= ({ // tooltipOpen sx={{ pointerEvents: "auto" }} icon={} - tooltipTitle={"Trigger"} + tooltipTitle={langStore.get("TRIGGER")} onClick={onTrigger} /> } - tooltipTitle={"Delete"} + tooltipTitle={langStore.get("DELETE")} onClick={onDelete} /> } - tooltipTitle={"Metadata"} + tooltipTitle={langStore.get("METADATA")} onClick={() => setInfoBox(!infoBoxOpen)} /> {state.status === "changed" && ( } - tooltipTitle={"Undo"} + tooltipTitle={langStore.get("UNDO")} onClick={undo} /> )} @@ -277,6 +277,7 @@ export const ValidationBox: FC<{ data: EditorData; onSave: (d: EditorData) => void; }> = (props) => { + const langStore = useLang(); const [{ failures, data }, setState] = useState({ failures: props.failures, data: props.data, @@ -317,12 +318,10 @@ export const ValidationBox: FC<{ ))} - - Please correct the automation file manually and then continue! - - + {langStore.get("VALIDATION_PLEASE_CORRECT_FILE")} +
); diff --git a/webapp/src/components/AutomationManager/Loaded/automationDB.ts b/webapp/src/components/AutomationManager/Loaded/automationDB.ts index 4b55dc2..acf46b2 100644 --- a/webapp/src/components/AutomationManager/Loaded/automationDB.ts +++ b/webapp/src/components/AutomationManager/Loaded/automationDB.ts @@ -1,4 +1,5 @@ import { HassEntities } from "home-assistant-js-websocket"; +import { LangStore, useLang } from "lang"; import { useEffect, useState } from "react"; import { AutomationData, BareAutomationData } from "types/automations"; import { defaultAutomation } from "utils/defaults"; @@ -10,7 +11,8 @@ export const useAutomationDB = ( configAutomations: AutomationData[], tagsDB: TagDB ) => { - const autoMap = genMapping(haEntities, configAutomations, tagsDB); + const langStore = useLang(); + const autoMap = genMapping(haEntities, configAutomations, tagsDB, langStore); const [newAuto, setNewAuto] = useState< null | [AutomationManagerAuto, AutomationData | BareAutomationData] @@ -54,13 +56,13 @@ export const useAutomationDB = ( entityId: "", title: auto.alias ?? "", description: auto.description ?? "", - state: "unregistered", + state: langStore.get("AUTOMATION_STATE_UNREGISTERED"), tags: {}, - issue: "New Automation", + issue: langStore.get("NEW_AUTOMATION"), isNew: true, - source_file: "n/a", - source_file_type: "n/a", - configuration_key: ["n/a"], + source_file: langStore.get("N/A"), + source_file_type: langStore.get("N/A"), + configuration_key: [], }, auto, ]); @@ -72,7 +74,8 @@ export const useAutomationDB = ( const genMapping = ( haEntities: HassEntities, configAutomations: AutomationData[], - tagsDB: TagDB + tagsDB: TagDB, + langStore: LangStore ) => { const configData: Record = configAutomations.reduce( (all, n) => ({ @@ -93,7 +96,9 @@ const genMapping = ( let description = ""; let issue: string | undefined = ["on", "off"].includes(entityData.state) ? undefined - : `recived invalid state "${entityData.state}, this could be because you have a lingering automation that was not cleared by homeassistant, try to reboot HA or manually clear this automation from HA Database."`; + : langStore.get("ISSUES_INVALID_STATE", { + state: entityData.state, + }); let found: AutomationData | null = null; let source_file = "n/a"; let source_file_type = "n/a"; @@ -107,7 +112,7 @@ const genMapping = ( configuration_key = found.configuration_key ?? configuration_key; delete configData[autoId]; } else { - issue = "failed to find this automation in '/config' folder"; + issue = langStore.get("ISSUES_FIND_AUTOMATION_IN_CONFIG"); } automatioinMap[autoId] = [ @@ -134,13 +139,12 @@ const genMapping = ( entityId: "", title: auto.alias ?? "", description: auto.description ?? "", - state: "unregistered", + state: langStore.get("AUTOMATION_STATE_UNREGISTERED"), tags: tagsDB.getTags(auto.id), source_file: auto.source_file, source_file_type: auto.source_file_type, configuration_key: auto.configuration_key, - issue: - "homeassistant did not load this automation, try to manually reload automations or restart homeassistant.", + issue: langStore.get("ISSUES_NO_LOAD_AUTOMATION"), }, auto, ]; diff --git a/webapp/src/components/AutomationManager/Loaded/index.tsx b/webapp/src/components/AutomationManager/Loaded/index.tsx index d5e9f02..878f2dc 100644 --- a/webapp/src/components/AutomationManager/Loaded/index.tsx +++ b/webapp/src/components/AutomationManager/Loaded/index.tsx @@ -10,6 +10,7 @@ import { } from "./state"; import Alert from "@mui/material/Alert"; import { useConfirm } from "material-ui-confirm"; +import { useLang } from "lang"; export type AutomationManagerLoadedProps = UseAutomationManagerStateArgs & { onAutomationDelete: (aid: string, eid: string) => void; @@ -17,13 +18,14 @@ export type AutomationManagerLoadedProps = UseAutomationManagerStateArgs & { export const AutomationManagerLoaded: FC< PropsWithChildren > = ({ children, ...args }) => { + const langStore = useLang(); const state = useAutomationManagerState(args); const confirm = useConfirm(); const onAutomationDelete = async (aid: string, eid: string) => confirm({ - title: "Are you sure you want to delete this automation?", - confirmationText: "Delete", + title: langStore.get("CONFIRMATION_DELETE_THIS_AUTOMATION"), + confirmationText: langStore.get("DELETE"), }) .then(() => { args.onAutomationDelete(aid, eid); @@ -76,8 +78,9 @@ export const AutomationManagerLoaded: FC< ) : (
- Failed to find an automation on disk with id{" "} - {state.currentAutomationId}. + {langStore.get("ISSUE_FAILED_TO_FIND_AUTOMATION_ON_DISK", { + id: state.currentAutomationId, + })}
) diff --git a/webapp/src/components/AutomationManager/Loaded/state.ts b/webapp/src/components/AutomationManager/Loaded/state.ts index 74cbca4..e9c7801 100644 --- a/webapp/src/components/AutomationManager/Loaded/state.ts +++ b/webapp/src/components/AutomationManager/Loaded/state.ts @@ -7,6 +7,7 @@ import { useAutomationDB } from "./automationDB"; import { useConfirm } from "material-ui-confirm"; import { AutomationManagerAutoUpdatable } from "../types"; import { useSnackbar } from "notistack"; +import { useLang } from "lang"; export type UseAutomationManagerStateArgs = { configAutomations: AutomationData[]; @@ -26,6 +27,7 @@ export const useAutomationManagerState = ({ onAutomationStateChange, }: UseAutomationManagerStateArgs) => { // state + const langStore = useLang(); const confirm = useConfirm(); const snackbr = useSnackbar(); const cookies = useAMSCookies(); @@ -44,10 +46,9 @@ export const useAutomationManagerState = ({ const stillHaveNewAreYouSure = async () => { try { await confirm({ - content: - "Selecting another automation will cause you to lose all work done on this new automation. Please save your work on this automation first.", - confirmationText: "Switch Automation", - cancellationText: "Cancel", + content: langStore.get("WARNING_SWITCHING_FROM_NONE_SAVE"), + confirmationText: langStore.get("SWITCH_AUTOMATION"), + cancellationText: langStore.get("CANCEL"), }); return true; } catch (_) { @@ -128,9 +129,10 @@ export const useAutomationManagerState = ({ } } else { snackbr.enqueueSnackbar( - `Failed to save automation "${aid}" contents - ${JSON.stringify( - a - )} -- not found in /config`, + langStore.get("ERROR_FAILED_TO_SAVE", { + aid, + contents: JSON.stringify(a), + }), { variant: "error" } ); } diff --git a/webapp/src/components/AutomationManager/MetadataBox/Tags.tsx b/webapp/src/components/AutomationManager/MetadataBox/Tags.tsx index 6dddc70..0a467f8 100644 --- a/webapp/src/components/AutomationManager/MetadataBox/Tags.tsx +++ b/webapp/src/components/AutomationManager/MetadataBox/Tags.tsx @@ -12,6 +12,7 @@ import { Button } from "components/Inputs/Buttons/Button"; import InputAutoText from "components/Inputs/InputAutoText"; import { TagDB } from "../TagDB"; +import { useLang } from "lang"; export type TagsProps = { automationId: string; @@ -29,6 +30,7 @@ export type TagModalState = }; export const Tags: FC = ({ automationId, tagsDB }) => { + const langStore = useLang(); const [modalState, setModal] = useState({ open: false }); const tags = tagsDB.getTags(automationId, true); const onUpdate = (t: Record) => @@ -44,7 +46,7 @@ export const Tags: FC = ({ automationId, tagsDB }) => { setModal({ @@ -56,7 +58,7 @@ export const Tags: FC = ({ automationId, tagsDB }) => { setModal({ @@ -67,7 +69,7 @@ export const Tags: FC = ({ automationId, tagsDB }) => { />
diff --git a/webapp/src/components/AutomationManager/MetadataBox/index.tsx b/webapp/src/components/AutomationManager/MetadataBox/index.tsx index c5ff714..ab90d41 100644 --- a/webapp/src/components/AutomationManager/MetadataBox/index.tsx +++ b/webapp/src/components/AutomationManager/MetadataBox/index.tsx @@ -15,6 +15,7 @@ import { AutomationManagerAuto } from "../types"; import { Tags } from "./Tags"; import { TagDB } from "../TagDB"; import { Chip, Tooltip } from "@mui/material"; +import { useLang } from "lang"; export type MetadataBoxProps = AutomationManagerAuto & { onDelete: () => void; @@ -28,6 +29,10 @@ export type MetadataBoxProps = AutomationManagerAuto & { }; export const MetadataBox: FC = (props) => { const isValidState = ["on", "off"].includes(props.state); + const langStore = useLang(); + const prettyState = ["on", "off"].includes(props.state) + ? langStore.get(`AUTOMATION_STATE_${props.state}`) + : props.state; return (
= (props) => { >
= (props) => {
@@ -66,7 +82,7 @@ export const MetadataBox: FC = (props) => { = (props) => { = (props) => { className="select" icon={} onClick={props.onSelect} - title="Select automation" + title={langStore.get("SELECT_AUTOMATION")} /> } onClick={props.onRun} - title="Trigger automation" + title={langStore.get("TRIGGER_AUTOMATION")} /> } onClick={props.onDelete} - title="Delete automation" + title={langStore.get("DELETE_AUTOMATION")} />
diff --git a/webapp/src/components/AutomationManager/Sidebar/index.tsx b/webapp/src/components/AutomationManager/Sidebar/index.tsx index c652d6c..4bb09aa 100644 --- a/webapp/src/components/AutomationManager/Sidebar/index.tsx +++ b/webapp/src/components/AutomationManager/Sidebar/index.tsx @@ -18,6 +18,7 @@ import { } from "../types"; import { Button } from "components/Inputs/Buttons/Button"; import { ButtonIcon } from "components/Icons/ButtonIcons"; +import { useLang } from "lang"; export type AutomationManagerSidebarProps = { tagsDB: TagDB; @@ -41,6 +42,7 @@ export const AutomationManagerSidebar: FC = ({ onSelectedAutomationId, ...events }) => { + const langStore = useLang(); const [searchText, setSearchText] = useState(""); const [selectedTagIdx, setSelectedTagIdx] = useState([]); const [isHidden, setHidden] = useState(false); @@ -76,9 +78,13 @@ export const AutomationManagerSidebar: FC = ({ ].join(" ")} >
- + = ({ color="primary" className="add-btn" > - Add + {langStore.get("ADD")} Promise; @@ -33,6 +34,7 @@ export const AutomationManager: FC = ({ forceDeleteAutomation: _forceDeleteAutomation, triggerAutomation: _triggerAutomation, }) => { + const langStore = useLang(); const snackbr = useSnackbar(); const confirm = useConfirm(); const validationsShown = useRef(false); @@ -52,9 +54,14 @@ export const AutomationManager: FC = ({ }) .catch((err) => { console.error(err); - snackbr.enqueueSnackbar(errorMessage.replace("{{err}}", String(err)), { - variant: "error", - }); + snackbr.enqueueSnackbar( + langStore.get(errorMessage, { + err: String(err), + }), + { + variant: "error", + } + ); setIsSaving(isSaving.filter((k) => k !== name)); }); } @@ -68,9 +75,14 @@ export const AutomationManager: FC = ({ if (resp.ok) { refreshAutomations(); } else { - snackbr.enqueueSnackbar(errorMessage.replace("{{err}}", resp.error), { - variant: "error", - }); + snackbr.enqueueSnackbar( + langStore.get(errorMessage, { + err: resp.error, + }), + { + variant: "error", + } + ); } } }); @@ -78,24 +90,26 @@ export const AutomationManager: FC = ({ const onAutomationStateChange = (eid: string, on: boolean) => wrapPromise( - "changing automation state", - 'failed to toggle autonation due to "{{err}}"', + langStore.get("AUTOMATION_MANAGER_STATE_CHANGE"), + "AUTOMATION_MANAGER_STATE_CHANGE_FAIL", () => _onAutomationStateChange(eid, on) ); const refreshAutomations = () => wrapPromise( - "refreshing automations", - 'failed refreshing automations due to "{{err}}"', + langStore.get("AUTOMATION_MANAGER_REFRESH"), + "AUTOMATION_MANAGER_REFRESH_FAIL", () => _refreshAutomations() ); const forceDeleteAutomation = (eid: string) => - wrapPromise("deleting automations", 'failed delete due to "{{err}}"', () => - _forceDeleteAutomation(eid) + wrapPromise( + langStore.get("AUTOMATION_MANAGER_DELETE"), + "AUTOMATION_MANAGER_DELETE_FAIL", + () => _forceDeleteAutomation(eid) ); const triggerAutomation = (eid: string) => wrapPromise( - "triggering automations", - 'failed trigger due to "{{err}}"', + langStore.get("AUTOMATION_MANAGER_TRIGGER"), + "AUTOMATION_MANAGER_TRIGGER_FAIL", () => _triggerAutomation(eid) ); @@ -129,7 +143,7 @@ export const AutomationManager: FC = ({ cancellationButtonProps: { style: { display: "none" }, }, - title: "Invalid Automations detected!", + title: langStore.get("ERROR_INVALID_AUTOMATION_DETECTED"), content: ( <>
    @@ -165,6 +179,7 @@ export const AutomationManager: FC = ({ .catch(console.error); } } + // eslint-disable-next-line }, [api.state.automations, confirm]); // handle bad states @@ -172,8 +187,7 @@ export const AutomationManager: FC = ({ return (
    - Failed to connect to websocket, please check that your access token is - properly setup + {langStore.get("ERROR_FAILED_CONNECTION_TO_HA")} {" "}
    {JSON.stringify(haEntities.error)} @@ -205,7 +219,7 @@ export const AutomationManager: FC = ({ return (
    - Failed to load automations from /config + {langStore.get("ISSUES_FIND_AUTOMATION_IN_CONFIG")} {" "}
    {error} @@ -237,8 +251,8 @@ export const AutomationManager: FC = ({ onAutomationStateChange={onAutomationStateChange} onAutomationAdd={(auto) => wrapApiPromise( - "adding automation", - "Failed to create automation, recieved error: {{err}}!", + langStore.get("AUTOMATION_MANAGER_ADD"), + "AUTOMATION_MANAGER_ADD_FAIL", () => api.createAutomation(auto) as any ) } @@ -258,7 +272,7 @@ export const AutomationManager: FC = ({ } if (!deleteSent) { snackbr.enqueueSnackbar( - "Failed to delete automation, this may be resolved by a refresh or reboot of Home Assistant", + langStore.get("AUTOMATION_MANAGER_DELETE_LIGHT"), { variant: "error", } @@ -268,15 +282,15 @@ export const AutomationManager: FC = ({ }} onAutomationUpdate={(auto) => wrapApiPromise( - "updating automation", - "Failed to update automation, recieved error: {{err}}!", + langStore.get("AUTOMATION_MANAGER_UPDATE"), + "AUTOMATION_MANAGER_UPDATE_FAIL", () => api.updateAutomation(auto) as any ) } onUpdateTags={async (aid, t) => { wrapApiPromise( - "updating tags", - "Failed to update tags, recieved error: {{err}}!", + langStore.get("AUTOMATION_MANAGER_UPDATE_TAGS"), + "AUTOMATION_MANAGER_UPDATE_TAGS_FAIL", () => api.updateTags({ automation_id: aid, diff --git a/webapp/src/components/ConditionEditor/ConditionNodeBase.tsx b/webapp/src/components/ConditionEditor/ConditionNodeBase.tsx index 7b0e906..e5987e1 100644 --- a/webapp/src/components/ConditionEditor/ConditionNodeBase.tsx +++ b/webapp/src/components/ConditionEditor/ConditionNodeBase.tsx @@ -12,6 +12,7 @@ import { getViewer } from "./viewRender"; import { getEditor } from "./editorRender"; import useWindowSize from "utils/useWindowSize"; import { ConditionNodeSettings } from "./ConditionNodeSettings"; +import { useLang } from "lang"; export type ConditionNodeBaseProps = { condition: AutomationCondition; @@ -24,6 +25,7 @@ export type ConditionNodeBaseViewMode = "edit" | "yaml" | "view"; export const ConditionNodeBase: FC = (props) => { // state const ha = useHA(); + const langStore = useLang(); const { isMobile } = useWindowSize(); const [{ isEdited, condition }, setCondition] = useState<{ isEdited: boolean; @@ -61,6 +63,7 @@ export const ConditionNodeBase: FC = (props) => { onChange={updateCondition} ha={ha} initialViewMode="edit" + langStore={langStore} /> ); } @@ -101,6 +104,7 @@ export const ConditionNodeBase: FC = (props) => { }, } as any) } + prettyOptionLabels={false} /> {isMobile && icons}
    diff --git a/webapp/src/components/ConditionEditor/editorRender.tsx b/webapp/src/components/ConditionEditor/editorRender.tsx index 232f89c..869cf28 100644 --- a/webapp/src/components/ConditionEditor/editorRender.tsx +++ b/webapp/src/components/ConditionEditor/editorRender.tsx @@ -31,6 +31,7 @@ import { prettyName } from "utils/formatting"; import { InputList } from "components/Inputs/InputList"; import { Button } from "components/Inputs/Buttons/Button"; import { RemoveCircle } from "@mui/icons-material"; +import { LangStore } from "lang"; interface Editor extends FC<{ @@ -38,6 +39,7 @@ interface Editor onChange: (condition: C) => void; ha: HAService; initialViewMode: ConditionNodeBaseViewMode; + langStore: LangStore; }> {} export const getEditor = (condition: AutomationCondition): Editor => { @@ -70,11 +72,12 @@ export const getEditor = (condition: AutomationCondition): Editor => { export const TemplateEditor: Editor = ({ onChange, condition, + langStore, }) => { return ( <> onChange({ @@ -119,6 +122,7 @@ export const DeviceConditionEditor: Editor = ({ export const NumericStateEditor: Editor = ({ onChange, condition, + langStore, }) => { return ( <> @@ -133,7 +137,7 @@ export const NumericStateEditor: Editor = ({ } /> onChange({ @@ -143,7 +147,7 @@ export const NumericStateEditor: Editor = ({ } /> onChange({ @@ -153,7 +157,7 @@ export const NumericStateEditor: Editor = ({ } /> onChange({ @@ -163,7 +167,7 @@ export const NumericStateEditor: Editor = ({ } /> onChange({ @@ -221,6 +225,7 @@ export const StateEditor: Editor = ({ onChange, condition, ha, + langStore, }) => { const restrictToDomain = !condition.entity_id || condition.entity_id.length === 0 @@ -241,7 +246,7 @@ export const StateEditor: Editor = ({ } /> = ({ } /> onChange({ ...condition, @@ -280,7 +285,11 @@ export const StateEditor: Editor = ({ }; type TimeEditorShows = "after" | "before" | "weekday"; -export const TimeEditor: Editor = ({ onChange, condition }) => { +export const TimeEditor: Editor = ({ + onChange, + condition, + langStore, +}) => { const [shows, setShows] = useState( Object.keys(condition).filter((k) => ["after", "before", "weekday"].includes(k) @@ -321,19 +330,19 @@ export const TimeEditor: Editor = ({ onChange, condition }) => { {prettyName(show)} opt} getLabel={(opt) => { return { - mon: "Monday", - tue: "Tuesday", - wed: "Wednesday", - thu: "Thursday", - fri: "Friday", - sat: "Saturday", - sun: "Sunday", + mon: langStore.get("DAY_mon"), + tue: langStore.get("DAY_tue"), + wed: langStore.get("DAY_wed"), + thu: langStore.get("DAY_thu"), + fri: langStore.get("DAY_fri"), + sat: langStore.get("DAY_sat"), + sun: langStore.get("DAY_sun"), }[opt]; }} onChange={(weekday: any) => @@ -362,7 +371,7 @@ export const TimeEditor: Editor = ({ onChange, condition }) => { {shows.length < 3 && ( !shows.includes(k) )} @@ -378,11 +387,12 @@ export const TimeEditor: Editor = ({ onChange, condition }) => { export const TriggerEditor: Editor = ({ onChange, condition, + langStore, }) => { return ( <> onChange({ @@ -395,11 +405,15 @@ export const TriggerEditor: Editor = ({ ); }; -export const ZoneEditor: Editor = ({ onChange, condition }) => { +export const ZoneEditor: Editor = ({ + onChange, + condition, + langStore, +}) => { return ( <> @@ -411,7 +425,7 @@ export const ZoneEditor: Editor = ({ onChange, condition }) => { restrictToDomain={["zone"]} /> diff --git a/webapp/src/components/DAGGraph/nodes/CollectionNode/CollectionNodeElement.tsx b/webapp/src/components/DAGGraph/nodes/CollectionNode/CollectionNodeElement.tsx index 3a22af3..a4d3cba 100644 --- a/webapp/src/components/DAGGraph/nodes/CollectionNode/CollectionNodeElement.tsx +++ b/webapp/src/components/DAGGraph/nodes/CollectionNode/CollectionNodeElement.tsx @@ -13,6 +13,7 @@ import { prettyName } from "utils/formatting"; import DeleteForeverIcon from "@mui/icons-material/DeleteForever"; import { useConfirm } from "material-ui-confirm"; import { useSnackbar } from "notistack"; +import { useLang } from "lang"; export const CollectionNodeElement: FC> = ({ @@ -27,6 +28,7 @@ export const CollectionNodeElement: FC> = title, children, }) => { + const lang = useLang(); const color = convertNodeTypeToSequenceNodeColor(collectionType); const nodeColor = useSequenceNodeColor(color); const confirm = useConfirm(); @@ -55,14 +57,19 @@ export const CollectionNodeElement: FC> = }) .then(() => { onDelete(); - snackbr.enqueueSnackbar("Deleted.", { + snackbr.enqueueSnackbar(lang.get("DELETED"), { variant: "info", }); }) .catch(() => - snackbr.enqueueSnackbar(`Did not delete ${trueTile}.`, { - variant: "info", - }) + snackbr.enqueueSnackbar( + lang.get("NOT_DELETED_THING", { + item: trueTile, + }), + { + variant: "info", + } + ) ); }} borderless diff --git a/webapp/src/components/DAGGraph/nodes/SequenceNode/SequenceNodeElement.tsx b/webapp/src/components/DAGGraph/nodes/SequenceNode/SequenceNodeElement.tsx index 0419e69..b5a5d0e 100644 --- a/webapp/src/components/DAGGraph/nodes/SequenceNode/SequenceNodeElement.tsx +++ b/webapp/src/components/DAGGraph/nodes/SequenceNode/SequenceNodeElement.tsx @@ -16,6 +16,7 @@ import InputBoolean from "components/Inputs/Base/InputBoolean"; import { SpeedDial } from "components/SpeedDial"; import { SequenceNodeElementProps } from "./types"; import { useSequenceNodeColor } from "./util"; +import { useLang } from "lang"; export const SequenceNodeElement: FC< PropsWithChildren @@ -35,6 +36,7 @@ export const SequenceNodeElement: FC< isClosed, setIsClosed, }) => { + const langStore = useLang(); const confirm = useConfirm(); const snackbr = useSnackbar(); const nodeColor = useSequenceNodeColor(color); @@ -89,18 +91,21 @@ export const SequenceNodeElement: FC< { confirm({ - description: "Are you sure you want to delete this node?", + description: langStore.get("CONFIRMATION_DELETE_THIS_NODE"), }) .then(() => { onXClick(); - snackbr.enqueueSnackbar("Deleted.", { + snackbr.enqueueSnackbar(langStore.get("DELETED"), { variant: "info", }); }) .catch(() => - snackbr.enqueueSnackbar("Did not delete node.", { - variant: "info", - }) + snackbr.enqueueSnackbar( + langStore.get("NOT_DELETED_NODE"), + { + variant: "info", + } + ) ); }} size="small" diff --git a/webapp/src/components/DeviceEditor/index.tsx b/webapp/src/components/DeviceEditor/index.tsx index fff7ba8..a73d8b5 100644 --- a/webapp/src/components/DeviceEditor/index.tsx +++ b/webapp/src/components/DeviceEditor/index.tsx @@ -8,6 +8,7 @@ import { InputEntity } from "components/Inputs/AutoComplete/InputEntities"; import { cleanUpUndefined } from "utils/helpers"; import { DeviceBaseType, DeviceTypeCapability } from "haService/types"; import { AutomationDeviceState } from "types/automations/common"; +import { useLang } from "lang"; export type DeviceEditorProps = { type: "action" | "condition" | "trigger"; @@ -23,6 +24,8 @@ export function DeviceEditor({ caps, options, }: DeviceEditorProps) { + // state + const langStore = useLang(); // aliases const update = (upd: Partial>) => setState( @@ -40,13 +43,13 @@ export function DeviceEditor({ <> setState({ device_id: device_id ?? "" })} /> options[k])} @@ -67,7 +70,7 @@ export function DeviceEditor({ {entities.length > 0 && ( @@ -85,7 +88,11 @@ export function DeviceEditor({ /> )} {Object.keys(options).length + entities.length === 0 && ( - <>This device has no {type}s. + <> + {langStore.get("WARNING_DEVICE_NO_TYPES", { + type: `${type}s`, + })} + )} ); diff --git a/webapp/src/components/Inputs/Base/InputYaml.tsx b/webapp/src/components/Inputs/Base/InputYaml.tsx index 75799b6..9899c99 100644 --- a/webapp/src/components/Inputs/Base/InputYaml.tsx +++ b/webapp/src/components/Inputs/Base/InputYaml.tsx @@ -9,6 +9,7 @@ import FormHelperText from "@mui/material/FormHelperText"; import InputAdornment from "@mui/material/InputAdornment"; import { Save } from "@mui/icons-material"; import { ButtonIcon } from "components/Icons/ButtonIcons"; +import { useLang } from "lang"; export interface Props { label: string; @@ -34,6 +35,7 @@ export default function InputYaml({ helperText, endAdornment, }: Props) { + const langStore = useLang(); const originalText = yaml.dump(value); const [{ text, error }, setState] = useState<{ text: string; @@ -48,7 +50,7 @@ export default function InputYaml({ yaml.load(t); setState({ text: t, error: undefined }); } catch (_) { - setState({ text: t, error: "! Invalid Yaml !" }); + setState({ text: t, error: langStore.get("ERROR_INVALID_YAML") }); } }; const onSave = () => { @@ -94,7 +96,9 @@ export default function InputYaml({ onSave()} - title={!!error ? "Invalid YAML" : hasChanged ? "Save" : ""} + title={ + !!error ? "Invalid YAML" : hasChanged ? langStore.get("SAVE") : "" + } icon={ = { current?: T; @@ -17,6 +18,7 @@ export type Props = { className?: string; prettyOptionLabels?: boolean; getKey?: (n: T) => string; + getLabel?: (n: T) => string; getDescription?: (n: T) => string; placeholder?: any; title?: string; @@ -34,6 +36,7 @@ export function InputList({ className, prettyOptionLabels = true, getKey = String, + getLabel: _getLabel, getDescription, placeholder, title, @@ -42,8 +45,17 @@ export function InputList({ disabled, fullWidth = true, }: Props) { + const langStore = useLang(); const invalidCurrent = current && !options.map(getKey).includes(getKey(current)); + + const getLabel = + _getLabel ?? + function (x: T) { + return typeof x === "string" + ? prettyName(langStore.get(x.toUpperCase())) + : getKey(x); + }; return ( ({ > {options.map((t, i) => ( - {prettyOptionLabels ? prettyName(getKey(t)) : getKey(t)} + {prettyOptionLabels + ? prettyName(getKey(t)) + : getLabel + ? getLabel(t) + : getKey(t)} {!!getDescription && ( <>
    diff --git a/webapp/src/components/Inputs/InputMultiSelect.tsx b/webapp/src/components/Inputs/InputMultiSelect.tsx index 0948f92..7dd1841 100644 --- a/webapp/src/components/Inputs/InputMultiSelect.tsx +++ b/webapp/src/components/Inputs/InputMultiSelect.tsx @@ -5,6 +5,7 @@ import Autocomplete from "@mui/material/Autocomplete"; import TextField from "@mui/material/TextField"; import Checkbox from "@mui/material/Checkbox"; import { useSnackbar } from "notistack"; +import { useLang } from "lang"; export interface Props { label: string; @@ -23,6 +24,7 @@ export default function InputMultiSelect({ max = 3, }: Props) { // alias + const langStore = useLang(); const snackbr = useSnackbar(); return ( ({ value={selected.map((i) => options[i])} onChange={(_, newValues: T[] = []) => { if (newValues.length > max) { - snackbr.enqueueSnackbar("Can only select up to 3 tags", { - variant: "warning", - autoHideDuration: 1500, - }); + snackbr.enqueueSnackbar( + langStore.get("VALIDATION_MAX_TAG_SELECTION", { count: "3" }), + { + variant: "warning", + autoHideDuration: 1500, + } + ); } onChange( newValues diff --git a/webapp/src/components/NodeEditor/OptionManager/index.tsx b/webapp/src/components/NodeEditor/OptionManager/index.tsx index 3484943..1a14bda 100644 --- a/webapp/src/components/NodeEditor/OptionManager/index.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/index.tsx @@ -13,6 +13,7 @@ import { getDescriptionFromAutomationNode } from "utils/formatting"; import { useHA } from "haService"; import { Generic } from "./Generic"; import { getNodeTypeAndValidate } from "utils/automations"; +import { useLang } from "lang"; type UseState = (s: S) => [S, Dispatch>]; @@ -23,6 +24,7 @@ export const useEditorNodeState = ( uState: UseState = useState ) => { // state + const langStore = useLang(); const [allState, setAllState] = uState({ yamlMode: false, isModified: false, @@ -77,7 +79,9 @@ export const useEditorNodeState = ( isErrored: allState.isErrored, get prettyNodeType() { if (nodeType) { - return `${nodeType.slice(0, 1).toUpperCase()}${nodeType.slice(1)} Type`; + return `${langStore.get(nodeType.toUpperCase())} ${langStore.get( + "TYPE" + )}`; } else { return "n/a"; } @@ -100,7 +104,7 @@ export const useEditorNodeState = ( aliasEditor = ( setState({ @@ -115,7 +119,7 @@ export const useEditorNodeState = ( aliasEditor = ( = ({ children, }) => { // state + const langStore = useLang(); const state = useEditorNodeState(node, allowedTypes, saveBtnCreateText); const confirm = useConfirm(); @@ -41,19 +43,19 @@ export const NodeEditor: FC = ({ ) => { const notes: string[] = []; if (!isReady) { - notes.push("This node is missing some values"); + notes.push(langStore.get("VALIDATION_MISSING_VALUES_FOR_NODE")); } if (state.isErrored) { - notes.push("This node contains errors"); + notes.push(langStore.get("VALIDATION_ERROR_VALUES_IN_NODE")); } if (checkModified && isModified) { - notes.push("This node is has some unsaved work"); + notes.push(langStore.get("VALIDATION_UNSAVED_WORK_IN_NODE")); } if (notes.length > 0) { try { await confirm({ confirmationText: "Yes", - title: `Are you sure you want to ${what}?`, + title: langStore.get("CONFIRM_EXIT", { what }), description: (
      {notes.map((n, i) => ( @@ -85,11 +87,11 @@ export const NodeEditor: FC = ({
      {allowedTypes.length > 1 ? ( ) : ( <> @@ -101,7 +103,7 @@ export const NodeEditor: FC = ({ getDescription={getNodeSubTypeDescription} options={state.subTypes} onChange={state.setSubType} - prettyOptionLabels + prettyOptionLabels={false} /> ) : ( <> @@ -115,7 +117,7 @@ export const NodeEditor: FC = ({ /> @@ -140,9 +142,11 @@ export const NodeEditor: FC = ({ onClick={() => areYouSureNotReady("save").then((ok) => ok && onSave(state.data)) } - title={!isReady ? "Some fields have not been properly filled up" : ""} + title={ + !isReady ? langStore.get("VALIDATION_NOT_ALL_FIELD_FILLED_IN") : "" + } > - {saveBtnCreateText ? "Create" : "Save"} + {saveBtnCreateText ? langStore.get("CREATE") : langStore.get("SAVE")} {children}
      diff --git a/webapp/src/haService/index.ts b/webapp/src/haService/index.ts index 6b1a075..72a09ef 100644 --- a/webapp/src/haService/index.ts +++ b/webapp/src/haService/index.ts @@ -12,6 +12,7 @@ import { TypedHassService } from "./fieldTypes"; import { Option } from "components/Inputs/AutoComplete/InputAutoComplete"; import { getDeviceExtraWsCalls } from "./extras"; import { useHAEntities } from "./HAEntities"; +import { useLang } from "lang"; export type ServiceOption = Option<{ domain: string; @@ -137,6 +138,7 @@ export const useHAEntityRegistry = () => { export type HAService = ReturnType; export const useHA = () => { + const langStore = useLang(); const entities = useHAEntities(); const devices = useHADeviceRegistry(); const services = useHAServices(); @@ -158,9 +160,14 @@ export const useHA = () => { target, service_data: data, }); - snackbr.enqueueSnackbar(`Successfully called ${domain}.${service}`, { - variant: "success", - }); + snackbr.enqueueSnackbar( + langStore.get("INFO_SUCCESS_CALL", { + entityId: `${domain}.${service}`, + }), + { + variant: "success", + } + ); return result; } catch (err: any) { let msg = JSON.stringify(err); @@ -168,7 +175,10 @@ export const useHA = () => { msg = err.message; } snackbr.enqueueSnackbar( - `Failed to call ${domain}.${service} because '${msg}'`, + langStore.get("ERROR_FAILED_CALLING", { + entityId: `${domain}.${service}`, + msg, + }), { variant: "error", } @@ -178,14 +188,20 @@ export const useHA = () => { } if (conn.status === "error") { snackbr.enqueueSnackbar( - `Failed to call service because connection is '${conn.status}' -- ${conn.error}`, + langStore.get("ERROR_FAILED_CALLING_BC_CONNECTION", { + connStatus: conn.status, + connError: conn.error, + }), { variant: "error", } ); } else { snackbr.enqueueSnackbar( - `Failed to call service because connection is '${conn.status}'`, + langStore.get("ERROR_FAILED_CALLING_BC_CONNECTION", { + connStatus: conn.status, + connError: "", + }), { variant: "error", } @@ -210,7 +226,7 @@ export const useHA = () => { .map(entities.getLabel) .join(", "); if (entity_id.length > maxEntities) { - return out + " and more"; + return out + " " + langStore.get("AND_MORE"); } return out; } diff --git a/webapp/src/lang/eng.json b/webapp/src/lang/eng.json new file mode 100644 index 0000000..515df76 --- /dev/null +++ b/webapp/src/lang/eng.json @@ -0,0 +1,148 @@ +{ + "ADD": "Add", + "ALIAS": "Alias", + "ATTRIBUTE": "Attribute", + "ABOVE": "Above", + "BELOW": "Below", + "ID": "Id", + "NAME": "Name", + "TAG": "Tag", + "TAGS": "Tags", + "DEVICE": "Device", + "ACTION": "Action", + "TAG_NAME": "Tag Name", + "TAG_VALUE": "Tag Value", + "TITLE": "Title", + "TYPE": "Type", + "TRIGGER_ID": "Trigger ID", + "TEMPLATE": "Template", + "MODE": "Mode", + "CLOSE": "Close", + "DESCRIPTION": "Description", + "TRIGGER": "Trigger", + "CONDITION": "Condition", + "DELETE": "Delete", + "METADATA": "Metadata", + "UNDO": "Undo", + "RAW": "Raw", + "SAVE": "Save", + "STATE": "State", + "SEARCH": "Search", + "FLIPP": "Flip", + "CANCEL": "Cancel", + "CREATE": "Create", + "OR": "Or", + "ZONE": "Zone", + "ENTITY": "Entity", + "ENABLED": "Enabled", + "ENTITY_WITH_LOCATION": "Entity with Location", + "AND_MORE": "and more", + "YES": "Yes", + "NO": "No", + + "SERVICE": "Service", + "REPEAT": "Repeat", + "WAIT": "Wait", + "STOP": "Stop", + "CHOOSE": "Choose", + "PARALLEL": "Parallel", + "SCENE": "Scene", + + "AND": "and", + "NOT": "not", + "NUMERIC_STATE": "Numeric State", + "TIME": "Time", + "EVENT": "Event", + "HOMEASSISTANT": "Home Assistant", + "CALENDAR": "Calendar", + "WEBHOOK": "Webhook", + "SUN": "Sun", + "MQTT": "MQTT", + + "DAY_MON": "Monday", + "DAY_TUE": "Tuesday", + "DAY_WED": "Wednesday", + "DAY_THU": "Thursday", + "DAY_FRI": "Friday", + "DAY_SAT": "Saturday", + "DAY_SUN": "Sunday", + + "WEEKDAY": "Weekday", + "OPTION": "Option", + + "SELECT_AUTOMATION": "Select automation", + "TRIGGER_AUTOMATION": "Trigger automation", + "DELETE_AUTOMATION": "Delete automation", + + "CONFIRMATION_DELETE_THIS_AUTOMATION": "Are you sure you want to delete this automation?", + "CONFIRMATION_DELETE_THIS_NODE": "Are you sure you want to delete this node?", + + "DELETED": "Deleted.", + "NOT_DELETED_NODE": "Did not delete node.", + "NOT_DELETED_THING": "Did not delete {{item}}.", + + "MISSING_TEXT": "MISSING TEXT -- {{langId}}", + + "AUTOMATION_METADATA_TOOLTIP_TEXT": "This automation is located in the file {{source_file}}. It's currently '{{state}}', it's entity id is '{{entityId}}' and it's automation id is '{{id}}'", + + "ERROR_FAILED_TO_SAVE": "Failed to save automation \"{{aid}}\" contents - {{contents}} -- not found in `/config`", + "ERROR_INVALID_AUTOMATION_STATE": "Invalid state", + "ERROR_INVALID_AUTOMATION_DETECTED": "Invalid Automations detected!", + "ERROR_FAILED_CONNECTION_TO_HA": "Failed to connect to websocket, please check that your access token is properly setup.", + "ERROR_FAILED_CALLING": "Failed to call {{entityId}} because '{{msg}}'", + "ERROR_FAILED_CALLING_BC_CONNECTION": "Failed to call service because connection is '{{connStatus}}' -- {{connError}}", + "ERROR_INVALID_YAML": "! Invalid Yaml !", + + "AUTOMATION_STATE_IS": "Automation is {{state}}", + + "ISSUE_FAILED_TO_FIND_AUTOMATION_ON_DISK": "Failed to find an automation on disk with id = {{id}}", + "ISSUES_INVALID_STATE": "Recived invalid state '{{state}}', this could be because you have a lingering automation that was not cleared by homeassistant, try to reboot HA or manually clear this automation from HA Database.", + "ISSUES_FIND_AUTOMATION_IN_CONFIG": "failed to find this automation in '/config' folder", + "ISSUES_NO_LOAD_AUTOMATION": "homeassistant did not load this automation, try to manually reload automations or restart homeassistant.", + + "AUTOMATION_STATE_UNREGISTERED": "unregistered", + "AUTOMATION_STATE_ON": "On", + "AUTOMATION_STATE_OFF": "Off", + + "AUTOMATION_MANAGER_STATE_CHANGE": "changing automation state", + "AUTOMATION_MANAGER_STATE_CHANGE_FAIL": "Failed to toggle automation due to \"{{err}}\"", + "AUTOMATION_MANAGER_REFRESH": "refreshing automations", + "AUTOMATION_MANAGER_REFRESH_FAIL": "Failed refreshing automations due to \"{{err}}\"", + "AUTOMATION_MANAGER_DELETE": "deleting automation", + "AUTOMATION_MANAGER_DELETE_FAIL": "Failed delete due to \"{{err}}\"", + "AUTOMATION_MANAGER_TRIGGER": "triggering automation", + "AUTOMATION_MANAGER_TRIGGER_FAIL": "Failed trigger due to \"{{err}}\"", + "AUTOMATION_MANAGER_ADD": "adding automation", + "AUTOMATION_MANAGER_ADD_FAIL": "Failed adding automation due to \"{{err}}\"", + "AUTOMATION_MANAGER_UPDATE": "updating automation", + "AUTOMATION_MANAGER_UPDATE_FAIL": "Failed updating automation due to \"{{err}}\"", + "AUTOMATION_MANAGER_UPDATE_TAGS": "updating automation tags", + "AUTOMATION_MANAGER_UPDATE_TAGS_FAIL": "Failed updating automation tags due to \"{{err}}\"", + "AUTOMATION_MANAGER_DELETE_LIGHT": "Failed to delete automation, this may be resolved by a refresh or reboot of Home Assistant", + + "NEW_AUTOMATION": "New Automation", + "SWITCH_AUTOMATION": "Switch Automation", + + "N/A": "n/a", + + "VALIDATION_AUTOMATION_NAME": "Name must be at least 1 character long", + "VALIDATION_MAX_TAG_SELECTION": "Can only select up to {{count}} tags", + "VALIDATION_TAG_EXISTS": "The tag '{{name}}' already exists", + "VALIDATION_PLEASE_CORRECT_FILE": "Please correct the automation file manually and then continue!", + "VALIDATION_MISSING_VALUES_FOR_NODE": "This node is missing some values", + "VALIDATION_ERROR_VALUES_IN_NODE": "This node contains errors", + "VALIDATION_UNSAVED_WORK_IN_NODE": "This node is has some unsaved work", + "VALIDATION_NOT_ALL_FIELD_FILLED_IN": "Some fields have not been properly filled up", + + "CONFIRM_EXIT": "Are you sure you want to {{what}}?", + + "MODE_SIGNLE_LABEL": "Do not start a new run. Issue a warning.", + "MODE_SIGNLE_PARALLEL": "Start a new, independent run in parallel with previous runs.", + "MODE_SIGNLE_QUEUED": "Start a new run after all previous runs complete. Runs are guaranteed to execute in the order they were queued.", + "MODE_SIGNLE_RESTART": "Start a new run after first stopping previous run.", + + "WARNING_SWITCHING_FROM_NONE_SAVE": "Selecting another automation will cause you to lose all work done on this new automation. Please save your work on this automation first.", + "WARNING_DEVICE_NO_TYPES": "This device has no {{type}}.", + + "INFO_SUCCESS_CALL": "Successfully called {{entityId}}" +} diff --git a/webapp/src/lang/fra.json b/webapp/src/lang/fra.json new file mode 100644 index 0000000..51b504e --- /dev/null +++ b/webapp/src/lang/fra.json @@ -0,0 +1,151 @@ +{ + "ADD": "Ajouter", + "ALIAS": "Pseudonyme", + "ATTRIBUTE": "Attribuer", + "ABOVE": "Plus grand que", + "BELOW": "Moins que", + "ID": "Id", + "NAME": "Nom", + "TAG": "Étiquette", + "TAGS": "Étiquettes", + "DEVICE": "Dispositif", + "ACTION": "Opération", + "ACTIONS": "Opérations", + "TAG_NAME": "Nom de l'étiquette", + "TAG_VALUE": "Valeur de balise", + "TYPE": "Taper", + "TITLE": "Titre", + "TRIGGER_ID": "ID déclencheur", + "TEMPLATE": "Gabarit", + "MODE": "Mode", + "CLOSE": "Proche", + "DESCRIPTION": "Description", + "TRIGGER": "Déclencheur", + "TRIGGERS": "Déclencheurs", + "CONDITION": "Condition", + "CONDITIONS": "Les conditions", + "DELETE": "Supprimez", + "METADATA": "Metadata", + "UNDO": "Undo", + "RAW": "Raw", + "SAVE": "Sauver", + "STATE": "State", + "SEARCH": "Chercher", + "FLIPP": "Retourner", + "CANCEL": "Annuler", + "CREATE": "Créer", + "OR": "Ou", + "ZONE": "Zone", + "ENTITY": "Entité", + "ENABLED": "Activé", + "ENTITY_WITH_LOCATION": "Entité avec emplacement", + "AND_MORE": "et plus", + "YES": "Oui", + "NO": "Non", + + "SERVICE": "Service", + "REPEAT": "Répéter", + "WAIT": "Attendre", + "STOP": "Arrêt", + "CHOOSE": "Choisir", + "PARALLEL": "Parallèle", + "SCENE": "Scène", + "EVENT": "Événement", + "HOMEASSISTANT": "Home Assistant", + "CALENDAR": "Calendrier", + "WEBHOOK": "Webhook", + "SUN": "Sol", + "MQTT": "MQTT", + + "AND": "et", + "NOT": "non", + "NUMERIC_STATE": "État numérique", + "TIME": "Temps", + + "DAY_MON": "Lundi", + "DAY_TUE": "Mardi", + "DAY_WED": "Mercredi", + "DAY_THU": "Jeudi", + "DAY_FRI": "Vendredi", + "DAY_SAT": "Samedi", + "DAY_SUN": "Dimanche", + + "WEEKDAY": "Jour de la semaine", + "OPTION": "Option", + + "SELECT_AUTOMATION": "Sélectionnez l'automatisation", + "TRIGGER_AUTOMATION": "Déclencher l'automatisation", + "DELETE_AUTOMATION": "Supprimer l'automatisation", + + "CONFIRMATION_DELETE_THIS_AUTOMATION": "Voulez-vous vraiment supprimer cette automatisation ?", + "CONFIRMATION_DELETE_THIS_NODE": "Voulez-vous vraiment supprimer ce nœud ?", + + "DELETED": "Supprimé.", + "NOT_DELETED_NODE": "N'a pas supprimé le nœud.", + "NOT_DELETED_THING": "{{item}} n'a pas été supprimé.", + + "MISSING_TEXT": "TEXTE MANQUANT --{{langId}}", + + "AUTOMATION_METADATA_TOOLTIP_TEXT": "Cette automatisation se trouve dans le fichier {{source_file}}. Il s'agit actuellement de '{{state}}', son identifiant d'entité est '{{entityId}}' et son identifiant d'automatisation est '{{id}}'", + + "ERROR_FAILED_TO_SAVE": "Échec de l'enregistrement du contenu de l'automatisation \"{{aid}}\" - {{contents}} -- introuvable dans `/config`", + "ERROR_INVALID_AUTOMATION_STATE": "Etat non valide", + "ERROR_INVALID_AUTOMATION_DETECTED": "Automatisations invalides détectées !", + "ERROR_FAILED_CONNECTION_TO_HA": "Échec de la connexion au websocket, veuillez vérifier que votre jeton d'accès est correctement configuré.", + "ERROR_FAILED_CALLING": "Échec de l'appel de {{entityId}} car '{{msg}}'", + "ERROR_FAILED_CALLING_BC_CONNECTION": "Impossible d'appeler le service car la connexion est '{{connStatus}}' -- {{connError}}", + "ERROR_INVALID_YAML": "! Yaml invalide !", + + "AUTOMATION_STATE_IS": "L'automatisation est {{state}}", + + "ISSUE_FAILED_TO_FIND_AUTOMATION_ON_DISK": "Impossible de trouver une automatisation sur le disque avec id = {{id}}", + "ISSUES_INVALID_STATE": "État invalide reçu '{{state}}', cela peut être dû au fait que vous avez une automatisation persistante qui n'a pas été effacée par homeassistant, essayez de redémarrer HA ou effacez manuellement cette automatisation de la base de données HA.", + "ISSUES_FIND_AUTOMATION_IN_CONFIG": "impossible de trouver cette automatisation dans le dossier '/config'", + "ISSUES_NO_LOAD_AUTOMATION": "homeassistant n'a pas chargé cette automatisation, essayez de recharger manuellement les automatisations ou redémarrez homeassistant.", + + "AUTOMATION_STATE_UNREGISTERED": "non enregistré", + "AUTOMATION_STATE_ON": "Activé", + "AUTOMATION_STATE_OFF": "Désactivé", + + "AUTOMATION_MANAGER_STATE_CHANGE": "modification de l'état de l'automatisation", + "AUTOMATION_MANAGER_STATE_CHANGE_FAIL": "Impossible de basculer l'automatisation en raison de \"{{err}}\"", + "AUTOMATION_MANAGER_REFRESH": "automatisations rafraîchissantes", + "AUTOMATION_MANAGER_REFRESH_FAIL": "Échec de l'actualisation des automatisations en raison de \"{{err}}\"", + "AUTOMATION_MANAGER_DELETE": "suppression des automatisation", + "AUTOMATION_MANAGER_DELETE_FAIL": "Échec de la suppression en raison de \"{{err}}\"", + "AUTOMATION_MANAGER_TRIGGER": "déclenchement de l'automatisation", + "AUTOMATION_MANAGER_TRIGGER_FAIL": "Échec du déclencheur dû à \"{{err}}\"", + "AUTOMATION_MANAGER_ADD": "ajouter des automatisations", + "AUTOMATION_MANAGER_ADD_FAIL": "Échec de l'ajout de l'automatisation en raison de \"{{err}}\"", + "AUTOMATION_MANAGER_UPDATE": "mise à jour de l'automatisation", + "AUTOMATION_MANAGER_UPDATE_FAIL": "Échec de la mise à jour de l'automatisation en raison de \"{{err}}\"", + "AUTOMATION_MANAGER_UPDATE_TAGS": "mise à jour des balises d'automatisation", + "AUTOMATION_MANAGER_UPDATE_TAGS_FAIL": "Échec de la mise à jour des balises d'automatisation en raison de \"{{err}}\"", + "AUTOMATION_MANAGER_DELETE_LIGHT": "Échec de la suppression de l'automatisation, cela peut être résolu par une actualisation ou un redémarrage de Home Assistant", + + "NEW_AUTOMATION": "Nouvelle automatisation", + "SWITCH_AUTOMATION": "Automatisation des commutateurs", + + "N/A": "n/a", + + "VALIDATION_AUTOMATION_NAME": "Le nom doit comporter au moins 1 caractère", + "VALIDATION_MAX_TAG_SELECTION": "Ne peut sélectionner que {{count}} tags maximum", + "VALIDATION_TAG_EXISTS": "Le tag '{{name}}' existe déjà", + "VALIDATION_PLEASE_CORRECT_FILE": "Veuillez corriger le fichier d'automatisation manuellement, puis continuer !", + "VALIDATION_MISSING_VALUES_FOR_NODE": "Il manque certaines valeurs à ce nœud", + "VALIDATION_ERROR_VALUES_IN_NODE": "Ce nœud contient des erreurs", + "VALIDATION_UNSAVED_WORK_IN_NODE": "Ce nœud contient du travail non enregistré", + "VALIDATION_NOT_ALL_FIELD_FILLED_IN": "Certains champs n'ont pas été correctement remplis", + + "CONFIRM_EXIT": "Êtes-vous sûr de vouloir {{what}}?", + + "MODE_SIGNLE_LABEL": "Ne démarrez pas une nouvelle course. Émettre un avertissement.", + "MODE_SIGNLE_PARALLEL": "Démarrez une nouvelle analyse indépendante en parallèle avec les analyses précédentes.", + "MODE_SIGNLE_QUEUED": "Démarrez une nouvelle exécution une fois toutes les exécutions précédentes terminées. Les exécutions sont garanties de s'exécuter dans l'ordre dans lequel elles ont été mises en file d'attente.", + "MODE_SIGNLE_RESTART": "Démarrez une nouvelle analyse après avoir arrêté l'analyse précédente.", + + "WARNING_SWITCHING_FROM_NONE_SAVE": "La sélection d'une autre automatisation vous fera perdre tout le travail effectué sur cette nouvelle automatisation. Veuillez d'abord enregistrer votre travail sur cette automatisation.", + "WARNING_DEVICE_NO_TYPES": "Cet appareil n'a pas de {{type}}.", + + "INFO_SUCCESS_CALL": "{{entityId}} a été appelé avec succès" +}