Skip to content

Commit 7bcef6d

Browse files
committedMar 8, 2025
add ability to process ASL and Othe language tsKey values
1 parent 923bb7a commit 7bcef6d

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed
 

‎packages/ui/modals/Service/processor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export const processAttributes = ({
178178
}
179179

180180
case 'lang': {
181-
const langItem = processLangAttrib(attribute)
181+
const langItem = processLangAttrib(attribute, t, locale)
182182
if (langItem) {
183183
output.lang.push(langItem)
184184
}

‎packages/ui/modals/Service/processors/langAttrib.ts

+23-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
import { type AttributeRecord } from '../types'
22

3-
export const processLangAttrib = (record: AttributeRecord): LangAttribReturn => {
4-
const { language, supplementId: id, active } = record
5-
if (!language) {
6-
return null
3+
export const processLangAttrib = (
4+
record: AttributeRecord,
5+
t: (key: string, options?: { ns?: string; lng?: string }) => string,
6+
locale: string = 'en'
7+
): LangAttribReturn => {
8+
const { language, supplementId: id, active, tsKey } = record
9+
if (language) {
10+
return {
11+
id,
12+
active,
13+
childProps: {
14+
children: language.languageName,
15+
},
16+
}
717
}
8-
const { languageName } = language
9-
10-
return {
11-
id,
12-
active,
13-
childProps: {
14-
children: languageName,
15-
},
18+
if (tsKey) {
19+
return {
20+
id,
21+
active,
22+
childProps: {
23+
children: t(tsKey, { ns: 'attribute', lng: locale }),
24+
},
25+
}
1626
}
27+
return null
1728
}
1829

1930
export interface LangAttribOutput {

0 commit comments

Comments
 (0)