Skip to content

Commit

Permalink
Add util for retrieving i18n'd resource descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatawnclementawn committed Dec 2, 2024
1 parent e325729 commit 29aaf32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arches_vue_utils/src/arches_vue_utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ export interface WithValues {
}

export type Labellable = WithLabels | WithValues;

export interface Descriptors {
[key: string]: {
name: string;
description: string;
};
}
12 changes: 12 additions & 0 deletions arches_vue_utils/src/arches_vue_utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ALT_LABEL, PREF_LABEL } from "@/arches_vue_utils/constants.ts";

import type {
Descriptors,
Label,
Labellable,
WithLabels,
Expand Down Expand Up @@ -66,3 +67,14 @@ export const getItemLabel = (
rankLabel(a, preferredLanguageCode, systemLanguageCode),
)[0];
};

export const getDescriptors = (
data: Descriptors,
systemLanguageCode: string,
): [string, string] => {
if (!data) {
return ["None", "None"];
}
const descriptors = data[systemLanguageCode];
return [descriptors.name, descriptors.description];
};

0 comments on commit 29aaf32

Please sign in to comment.