(field: string, t: TFunction)
| 430 | |
| 431 | /** Get translated operators for a field, preserving the original structure */ |
| 432 | export function getTranslatedOperatorsForField(field: string, t: TFunction): { value: string; label: string }[] { |
| 433 | const ops = getOperatorsForField(field); |
| 434 | return ops.map((op) => { |
| 435 | // Symbolic operators (=, !=, >, >=, <, <=) stay as-is |
| 436 | if (/^[^a-zA-Z]/.test(op.label)) return op; |
| 437 | const key = OPERATOR_LABEL_KEYS[op.value]; |
| 438 | if (!key) return op; |
| 439 | // "is" / "is not" share keys with equals/notEquals for state/boolean types but have different labels |
| 440 | const type = getFieldType(field); |
| 441 | if ((type === "state" || type === "trackerStatus" || type === "boolean" || type === "hardlinkScope") && (op.value === "EQUAL" || op.value === "NOT_EQUAL")) { |
| 442 | return { value: op.value, label: t(`queryBuilder.operators.${op.value === "EQUAL" ? "is" : "isNot"}`, { defaultValue: op.label }) }; |
| 443 | } |
| 444 | return { value: op.value, label: t(`queryBuilder.operators.${key}`, { defaultValue: op.label }) }; |
| 445 | }); |
| 446 | } |
| 447 | |
| 448 | /** Get translated torrent states */ |
| 449 | export function getTranslatedTorrentStates(t: TFunction): { value: string; label: string }[] { |
no test coverage detected