Skip to content

Commit

Permalink
fix: add missing translations (closes #1823)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Oct 4, 2023
1 parent d9eef6f commit d12276c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 27 deletions.
6 changes: 4 additions & 2 deletions apps/client/locales/en/leo.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@
"motorway_sign_130": "Speed 130",
"motorway_sign_140": "Speed 140",
"motorway_sign_150": "Speed 150",
"arrestReportLogs": "Arrest report logs"
"arrestReportLogs": "Arrest report logs",
"all": "All",
"ungrouped": "Ungrouped",
"counts": "Counts"
},
"Bolos": {
"activeBolos": "Active Bolos",
Expand Down Expand Up @@ -415,4 +418,3 @@
"noWeaponsPendingBof": "There are no weapons pending approval."
}
}

10 changes: 9 additions & 1 deletion apps/client/locales/en/values.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@
"importWeapons": "Import Weapons",
"customCallsignTemplate": "Custom Callsign Template",
"customCallsignTemplateDescription": "When set, it will use this template over the global callsign template. You can use the following variables: {variables}",
"category": "Category"
"category": "Category",
"addGroup": "Add Group",
"manageGroup": "Manage Group",
"INFRACTION": "INfraction",
"MISDEMEANOR": "Misdemeanor",
"FELONY": "Felony",
"warningApplicable": "Warning Applicable",
"warningNotApplicable": "Warning Not Applicable",
"isPrimary": "Is Primary"
},
"PENAL_CODE_GROUP": {
"MANAGE": "Manage Penal Code Groups",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export function ManagePenalCodeGroup({ onCreate, onUpdate, onClose, group }: Pro
const modalState = useModal();
const { state, execute } = useFetch();
const common = useTranslations("Common");
const t = useTranslations("Values");

const footerTitle = group ? common("save") : common("create");
const title = group ? "Manage Group" : "Add Group";
const title = group ? t("manageGroup") : t("addGroup");

function handleClose() {
modalState.closeModal(ModalIds.ManagePenalCodeGroup);
Expand Down Expand Up @@ -72,14 +73,14 @@ export function ManagePenalCodeGroup({ onCreate, onUpdate, onClose, group }: Pro
errorMessage={errors.name}
autoFocus
isRequired
label="Name"
label={common("name")}
value={values.name}
onChange={(value) => setFieldValue("name", value)}
/>

<footer className="flex justify-end mt-5">
<Button type="reset" onPress={handleClose} variant="cancel">
Cancel
{common("cancel")}
</Button>
<Button className="flex items-center" disabled={state === "loading"} type="submit">
{state === "loading" ? <Loader className="mr-2" /> : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface Props {
export function ManagePenalCode({ onCreate, onUpdate, onClose, groupId, type, penalCode }: Props) {
const { state, execute } = useFetch();
const modalState = useModal();
const valuesT = useTranslations("Values");
const t = useTranslations(type);
const common = useTranslations("Common");
const { LEO_BAIL } = useFeatureEnabled();
Expand Down Expand Up @@ -117,7 +118,7 @@ export function ManagePenalCode({ onCreate, onUpdate, onClose, groupId, type, pe
<Form>
<TextField
errorMessage={errors.title}
label="Title"
label={common("title")}
autoFocus
name="title"
onChange={(value) => setFieldValue("title", String(value))}
Expand All @@ -126,11 +127,11 @@ export function ManagePenalCode({ onCreate, onUpdate, onClose, groupId, type, pe

<SelectField
errorMessage={errors.type}
label="Type"
label={common("type")}
name="type"
options={Object.values(PenalCodeType).map((value) => ({
value,
label: value.toLowerCase(),
label: valuesT(value),
}))}
onSelectionChange={(key) => setFieldValue("type", key)}
isClearable={false}
Expand All @@ -141,10 +142,10 @@ export function ManagePenalCode({ onCreate, onUpdate, onClose, groupId, type, pe
onChange={(isSelected) => setFieldValue("isPrimary", isSelected)}
isSelected={values.isPrimary}
>
Is Primary
{valuesT("isPrimary")}
</CheckboxField>

<FormField errorMessage={errors.description} label="Description">
<FormField errorMessage={errors.description} label={common("description")}>
<Editor
value={values.descriptionData}
onChange={(v) => setFieldValue("descriptionData", v)}
Expand All @@ -157,7 +158,7 @@ export function ManagePenalCode({ onCreate, onUpdate, onClose, groupId, type, pe
onChange={(isSelected) => setFieldValue("warningApplicable", isSelected)}
isSelected={values.warningApplicable}
>
Warning Applicable
{valuesT("warningApplicable")}
</CheckboxField>

<div>
Expand All @@ -170,7 +171,7 @@ export function ManagePenalCode({ onCreate, onUpdate, onClose, groupId, type, pe
onChange={(isSelected) => setFieldValue("warningNotApplicable", isSelected)}
isSelected={values.warningNotApplicable}
>
Warning not applicable
{valuesT("warningNotApplicable")}
</CheckboxField>

<div>
Expand All @@ -183,7 +184,7 @@ export function ManagePenalCode({ onCreate, onUpdate, onClose, groupId, type, pe

<footer className="flex justify-end mt-5">
<Button type="reset" onPress={handleClose} variant="cancel">
Cancel
{common("cancel")}
</Button>
<Button className="flex items-center" disabled={state === "loading"} type="submit">
{state === "loading" ? <Loader className="mr-2" /> : null}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as React from "react";
import { Select, SelectValue } from "components/form/Select";
import type { PenalCode, PenalCodeGroup } from "@snailycad/types";
import type { PenalCode } from "@snailycad/types";
import { FormRow } from "@snailycad/ui";
import { usePenalCodeGroups } from "hooks/values/use-penal-code-groups";
import { parseCurrentValue } from "./table-item-form";
import { useTranslations } from "use-intl";

interface Props {
value: SelectValue<PenalCode>[];
Expand All @@ -12,21 +13,16 @@ interface Props {
isReadOnly?: boolean;
}

const ungroupedGroup = {
id: "ungrouped",
name: "Ungrouped",
} as PenalCodeGroup;

const allPenalCodesGroup = {
id: "all",
name: "All",
} as PenalCodeGroup;

export function SelectPenalCode({ value, handleChange, penalCodes, isReadOnly }: Props) {
const [currentGroup, setCurrentGroup] = React.useState<string | null>("all");
const { groups: penalCodeGroups } = usePenalCodeGroups();
const t = useTranslations("Leo");

const groups = [allPenalCodesGroup, ungroupedGroup, ...penalCodeGroups];
const groups = [
{ id: "ungrouped", name: t("ungrouped") },
{ id: "all", name: t("all") },
...penalCodeGroups,
];
const [codes, setCodes] = React.useState<PenalCode[]>(penalCodes);

function onGroupChange(e: { target: { value: string } }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function TableItemForm({ penalCode, isReadOnly }: Props) {
return (
<div className="flex flex-row gap-5">
<FieldWrapper description={countDescription}>
<FormField className="!mb-0" label="Counts">
<FormField className="!mb-0" label={t("counts")}>
<Input
max={10}
min={1}
Expand Down

0 comments on commit d12276c

Please sign in to comment.