Download next.js/packages/next/src/shared/lib/i18n/detect-domain-locale.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 662 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/i18n/detect-domain-locale.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/shared/lib/i18n/detect-domain-locale.ts
-
curl -L -o detect-domain-locale.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/i18n/detect-domain-locale.ts
662 Bytes
| import type { DomainLocale } from '../../../server/config-shared' | |
| export function detectDomainLocale( | |
| domainItems?: readonly DomainLocale[], | |
| hostname?: string, | |
| detectedLocale?: string | |
| ) { | |
| if (!domainItems) return | |
| if (detectedLocale) { | |
| detectedLocale = detectedLocale.toLowerCase() | |
| } | |
| for (const item of domainItems) { | |
| // remove port if present | |
| const domainHostname = item.domain?.split(':', 1)[0].toLowerCase() | |
| if ( | |
| hostname === domainHostname || | |
| detectedLocale === item.defaultLocale.toLowerCase() || | |
| item.locales?.some((locale) => locale.toLowerCase() === detectedLocale) | |
| ) { | |
| return item | |
| } | |
| } | |
| } | |