Locale Code
Type Registry
Locale Code
technology.code.locale_code Language-region code in IETF BCP 47 format (e.g., en-US, fr-FR, zh-Hans). Allows for script subtags (e.g., zh-Hant) and extensions.
Domain technology›code
Casts to VARCHAR
Scope Universal
Try it
CLI
$ finetype infer -i "en"
→ technology.code.locale_code DuckDB
Detect
SELECT finetype('en');
-- → 'technology.code.locale_code' Cast expression
CAST({col} AS VARCHAR) Safe cast pipeline
-- Normalise and cast in one step
SELECT TRY_CAST(finetype_cast(my_column) AS VARCHAR) AS clean_value
FROM my_table
WHERE finetype(my_column) = 'technology.code.locale_code'; Struct Expansion
country: REGEXP_EXTRACT(LOWER({col}), '-([a-z]{2})(?:$|-)')
language: REGEXP_EXTRACT(LOWER({col}), '^([a-z]{2,3})') JSON Schema
finetype schema technology.code.locale_code {
"$id": "https://noon.sh/schemas/technology.code.locale_code",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "Language-region code in IETF BCP 47 format (e.g., en-US, fr-FR, zh-Hans). Allows for script subtags (e.g., zh-Hant) and extensions.",
"examples": [
"en",
"en-US",
"fr-FR",
"zh-Hans-CN",
"de-AT"
],
"pattern": "^[a-zA-Z]{2,3}(?:[-_][a-zA-Z]{2,4})*$",
"title": "Locale Code",
"type": "string"
} Examples
enen-USfr-FRzh-Hans-CNde-AT