diff --git a/app/src/atoms/SoftwareKeyboard/AlphanumericKeyboard/index.tsx b/app/src/atoms/SoftwareKeyboard/AlphanumericKeyboard/index.tsx index 4b0e632677f..4ab8dab1274 100644 --- a/app/src/atoms/SoftwareKeyboard/AlphanumericKeyboard/index.tsx +++ b/app/src/atoms/SoftwareKeyboard/AlphanumericKeyboard/index.tsx @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux' import { getAppLanguage } from '/app/redux/config' import { alphanumericKeyboardLayout, - pinYinLayoutCandidates, + layoutCandidates, customDisplay, } from '../constants' import type { KeyboardReactInterface } from 'react-simple-keyboard' @@ -55,7 +55,7 @@ export function AlphanumericKeyboard({ layoutName={layoutName} layout={alphanumericKeyboardLayout} layoutCandidates={ - appLanguage === 'zh-CN' ? pinYinLayoutCandidates : undefined + appLanguage != null ? layoutCandidates[appLanguage] : undefined } display={customDisplay} mergeDisplay={true} diff --git a/app/src/atoms/SoftwareKeyboard/FullKeyboard/index.tsx b/app/src/atoms/SoftwareKeyboard/FullKeyboard/index.tsx index 1c340d8461c..eed2a0b5934 100644 --- a/app/src/atoms/SoftwareKeyboard/FullKeyboard/index.tsx +++ b/app/src/atoms/SoftwareKeyboard/FullKeyboard/index.tsx @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux' import { getAppLanguage } from '/app/redux/config' import { customDisplay, - pinYinLayoutCandidates, + layoutCandidates, fullKeyboardLayout, } from '../constants' import type { KeyboardReactInterface } from 'react-simple-keyboard' @@ -64,7 +64,7 @@ export function FullKeyboard({ layoutName={layoutName} layout={fullKeyboardLayout} layoutCandidates={ - appLanguage === 'zh-CN' ? pinYinLayoutCandidates : undefined + appLanguage != null ? layoutCandidates[appLanguage] : undefined } display={customDisplay} mergeDisplay={true} diff --git a/app/src/atoms/SoftwareKeyboard/constants.ts b/app/src/atoms/SoftwareKeyboard/constants.ts index cf7b22f31a1..6fccfd21b81 100644 --- a/app/src/atoms/SoftwareKeyboard/constants.ts +++ b/app/src/atoms/SoftwareKeyboard/constants.ts @@ -1,5 +1,11 @@ import chineseLayout from 'simple-keyboard-layouts/build/layouts/chinese' +type LayoutCandidates = + | { + [key: string]: string + } + | undefined + export const customDisplay = { '{numbers}': '123', '{shift}': 'ABC', @@ -72,6 +78,11 @@ export const numericalCustom = { '{backspace}': 'del', } -// @ts-expect-error layout candidates exists but is not on the type -// in the simple-keyboard-layouts package -export const pinYinLayoutCandidates = chineseLayout.layoutCandidates +export const layoutCandidates: { + [key: string]: LayoutCandidates +} = { + // @ts-expect-error layout candidates exists but is not on the type + // in the simple-keyboard-layouts package + 'zh-CN': chineseLayout.layoutCandidates, + 'en-US': undefined, +}