Spaces:
Sleeping
Sleeping
File size: 854 Bytes
88b6846 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import { franc } from 'franc';
export const RTL_LANGUAGES = ['arb', 'heb', 'urd', 'per', 'ara', 'fas', 'urd'];
export function detectLanguage(text: string): string {
// franc returns 'und' if undetermined
// We can set a minimum length threshold to avoid noise
if (!text || text.length < 5) return 'eng';
return franc(text);
}
export function isRTL(langCode: string): boolean {
return RTL_LANGUAGES.includes(langCode);
}
export function getSuggestedFont(langCode: string): string {
switch (langCode) {
case 'arb':
case 'ara':
return 'Amiri'; // Assuming we have this or similar
case 'jpn':
return 'Noto Sans JP';
case 'kor':
return 'Noto Sans KR';
case 'cmn':
return 'Noto Sans SC';
default:
return 'DM Sans';
}
}
|