+
Language Code Lookup
+
+ Enter language names below (one per line) and click Look Up to get their
+ language codes. Example: Punjabi >> lah/pan.
+
+
+
+
+
+
+
+
+
+
+
+
+ {outputText && (
+
+ )}
+
+ {statusMessages.length > 0 && (
+
+ {statusMessages.map((msg, i) => (
+
+ {msg}
+
+ ))}
+
+ )}
+
+ );
+};
+
+export default CodeLookupPageBody;
diff --git a/src/pages/code-lookup/__tests__/batchMatchCensus.test.ts b/src/pages/code-lookup/__tests__/batchMatchCensus.test.ts
new file mode 100644
index 000000000..7d764262c
--- /dev/null
+++ b/src/pages/code-lookup/__tests__/batchMatchCensus.test.ts
@@ -0,0 +1,284 @@
+import { renderHook, waitFor } from '@testing-library/react';
+import * as fs from 'fs';
+import * as path from 'path';
+import * as React from 'react';
+import { MemoryRouter } from 'react-router-dom';
+import { afterAll, beforeAll, describe, expect, it } from 'vitest';
+
+import * as DataProviderModule from '@features/data/context/DataProvider';
+const DataProvider = (DataProviderModule as any).DataProvider || (DataProviderModule as any).default;
+
+import * as UseDataContextModule from '@features/data/context/useDataContext';
+const useDataContext = (UseDataContextModule as any).useDataContext || (UseDataContextModule as any).default;
+
+import * as PageParamsModule from '@features/params/PageParamsProvider';
+const PageParamsProvider = (PageParamsModule as any).PageParamsProvider || (PageParamsModule as any).default;
+
+import { LanguageData } from '@entities/language/LanguageTypes';
+import { findBestMatch } from '../batchMatchLogic';
+
+
+const PUBLIC_DIR = path.resolve(__dirname, '../../../../public');
+const CENSUS_DIR = path.join(PUBLIC_DIR, 'data/census/official');
+
+
+function parseCensusTSV(filePath: string): Array<{ expectedCode: string; name: string }> {
+ const text = fs.readFileSync(filePath, 'utf-8');
+ const lines = text.split('\n');
+ const results: Array<{ expectedCode: string; name: string }> = [];
+
+ let pastHeader = false;
+
+ for (const line of lines) {
+ if (line.startsWith('#')) continue;
+
+ if (!pastHeader) {
+ pastHeader = true;
+ continue;
+ }
+
+ const parts = line.split('\t');
+ const code = parts[0]?.trim();
+ const name = parts[1]?.trim();
+
+ if (!code || !name) continue;
+ if (name.startsWith('#')) continue;
+ if (code === 'und' || code === 'mul' || code === 'zxx') continue;
+ if (name.includes('Sign')) continue;
+
+ results.push({ expectedCode: code, name });
+ }
+
+ return results;
+}
+
+
+function topByFrequency