feat(i18n): add bilingual() display helper
This commit is contained in:
@@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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;
|
||||||
Reference in New Issue
Block a user