web / lib/services/schema-detection/utilities/language
lib/services/schema-detection/utilities/language
Language detection utilities.
Uses the franc library to detect the language of sample data, enabling language-aware field mapping detection.
Type Aliases
SupportedLanguage
SupportedLanguage = typeof
SUPPORTED_LANGUAGES[number]
Variables
SUPPORTED_LANGUAGES
constSUPPORTED_LANGUAGES: readonly ["eng","deu","fra","spa","ita","nld","por"]
Supported languages for field mapping detection.
LANGUAGE_NAMES
constLANGUAGE_NAMES:Record<string,string>
Human-readable names for supported languages.
Functions
extractTextForLanguageDetection()
extractTextForLanguageDetection(
sampleData,headers):string
Extracts text content suitable for language detection from sample data.
Filters out values that are not useful for language detection:
- Non-string values (numbers, booleans, null)
- Very short strings (likely IDs or codes)
- Email addresses, URLs, dates, coordinates, UUIDs
Parameters
sampleData
Record<string, unknown>[]
Array of sample data rows
headers
string[]
Column headers
Returns
string
Combined text content for language detection
detectLanguageFromText()
detectLanguageFromText(
text):LanguageResult
Detects the language of text using the franc library.
Parameters
text
string
Text to analyze
Returns
Language detection result
detectLanguage()
detectLanguage(
sampleData,headers):LanguageResult
Detects language from sample data and headers.
Parameters
sampleData
Record<string, unknown>[]
Array of sample data rows from uploaded file
headers
string[]
Column headers from uploaded file
Returns
Language detection result
isSupportedLanguage()
isSupportedLanguage(
code): code is “eng” | “deu” | “fra” | “spa” | “ita” | “nld” | “por”
Checks if a language code is supported.
Parameters
code
string
Returns
code is “eng” | “deu” | “fra” | “spa” | “ita” | “nld” | “por”