nl_tokens: Sets language properties to context if a WordPress . com language slug is detected in the hostname
pl_tokens: function handleLocaleSubdomains ( req , res , next ) { const langSlug = endsWith ( req . hostname , config ( 'hostname' ) ) ? split ( req . hostname , '.' ) [ 0 ] : null ; if ( langSlug && <mask> ( config ( 'magnificent_non_en_locales' ) , langSlug ) ) { // Retrieve the language object for the RTL information. const language = getLanguage ( langSlug ) ; // Switch locales only in a logged-out state. if ( language && ! req . context . isLoggedIn ) { req . context = { ... req . context , lang : language . langSlug , isRTL : ! ! language . rtl , } ; } else { // Strip the langSlug and redirect using hostname // so that the user's locale preferences take priority. const protocol = req . get ( 'X-Forwarded-Proto' ) === 'https' ? 'https' : 'http' ; const port = process . env . PORT || config ( 'port' ) || '' ; const hostname = req . hostname . substr ( langSlug . length + 1 ) ; const redirectUrl = ` ${ protocol } ${ hostname } ${ port } ${ req . path } ` ; return res . redirect ( redirectUrl ) ; } } next ( ) ; }