getLocaleBySubdomain

Overview

Get the locale in a subdomain structure
Important: You must include the protocol (http:// or https://)

Video Example

Arguments

  • url: The url where to extract the locale
  • defaultValue: The default value used for the main lang version without specifying a locale subdomain
  • defaultLocale: The default locale to return when no locale is found

Expected Output

  • String: The string with the locale

Text example

getLocaleBySubdomain("https://www.domain.com", "www", "ES")
// "ES"
getLocaleBySubdomain("https://en.domain.com", "www", "ES")
// "EN"

Use cases

  • Extract URL patterns in Sheets
  • Extract subdomains in Spreadsheet