mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-20 13:54:36 +01:00
Add zones friend name (#20761)
* feat: add zones friendly name * fix: fix the issue where the input field was empty when there was no friendly_name * chore: fix the issue where the friendly name would replace spaces with underscores * docs: update zones docs * Update web/src/components/settings/ZoneEditPane.tsx Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> * Add friendly_name option for zone configuration Added optional friendly name for zones in configuration. * fix: fix the logical error in the null/empty check for the polygons parameter * fix: remove the toast name for zones will use the friendly_name instead * docs: remove emoji tips * revert: revert zones doc ui tips * Update docs/docs/configuration/zones.md Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> * Update docs/docs/configuration/zones.md Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> * Update docs/docs/configuration/zones.md Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> * feat: add friendly zone names to tracking details and lifecycle item descriptions * chore: lint fix * refactor: add friendly zone names to timeline entries and clean up unused code * refactor: add formatList --------- Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { t } from "i18next";
|
||||
|
||||
export const capitalizeFirstLetter = (text: string): string => {
|
||||
return text.charAt(0).toUpperCase() + text.slice(1);
|
||||
};
|
||||
@@ -45,3 +47,29 @@ export function generateFixedHash(name: string, prefix: string = "id"): string {
|
||||
export function isValidId(name: string): boolean {
|
||||
return /^[a-zA-Z0-9_-]+$/.test(name) && !/^\d+$/.test(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a list of strings into a human-readable format with proper localization.
|
||||
* Handles different cases for empty, single-item, two-item, and multi-item lists.
|
||||
*
|
||||
* @param item - The array of strings to format
|
||||
* @returns A formatted string representation of the list
|
||||
*/
|
||||
export function formatList(item: string[]): string {
|
||||
if (item.length === 0) return "";
|
||||
if (item.length === 1) return item[0];
|
||||
if (item.length === 2) {
|
||||
return t("list.two", {
|
||||
0: item[0],
|
||||
1: item[1],
|
||||
ns: "common",
|
||||
});
|
||||
}
|
||||
|
||||
const separatorWithSpace = t("list.separatorWithSpace", { ns: "common" });
|
||||
const allButLast = item.slice(0, -1).join(separatorWithSpace);
|
||||
return t("list.many", {
|
||||
items: allButLast,
|
||||
last: item[item.length - 1],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user