diff --git a/APP/src/app/shared/i18n/bilingual.spec.ts b/APP/src/app/shared/i18n/bilingual.spec.ts new file mode 100644 index 0000000..1ed0231 --- /dev/null +++ b/APP/src/app/shared/i18n/bilingual.spec.ts @@ -0,0 +1,19 @@ +import { bilingual } from './bilingual'; + +describe('bilingual', () => { + it('joins English and Chinese with a slash, no spaces', () => { + expect(bilingual('Worship', '敬拜')).toBe('Worship/敬拜'); + }); + + it('returns English only when Chinese is null', () => { + expect(bilingual('Zelle', null)).toBe('Zelle'); + }); + + it('returns English only when Chinese is undefined', () => { + expect(bilingual('PayPal')).toBe('PayPal'); + }); + + it('returns English only when Chinese is an empty string', () => { + expect(bilingual('Other', '')).toBe('Other'); + }); +}); diff --git a/APP/src/app/shared/i18n/bilingual.ts b/APP/src/app/shared/i18n/bilingual.ts new file mode 100644 index 0000000..ef5bfad --- /dev/null +++ b/APP/src/app/shared/i18n/bilingual.ts @@ -0,0 +1,7 @@ +/** + * Display-only bilingual label: English first, Chinese second, joined by '/' + * with no spaces. Falls back to English alone when no Chinese is provided. + * Does NOT alter stored values — for display binding only. + */ +export const bilingual = (en: string, zh?: string | null): string => + zh ? `${en}/${zh}` : en;