'pt' / 'zh'. $language = strtolower( (string) strtok( $locale, '_-' ) ); // Space-padded lists of language subtags grouped by the typical UTF-8 byte width of // their script, covering the locale IDs WordPress core actually installs — including // its three-letter IDs (kir, ckb, snd, sah, ...) — plus common ISO aliases (ky, be). // Three bytes: CJK, Thai, Georgian, Ethiopic, Tibetan, and Brahmic (Indic) scripts. // Two bytes: Cyrillic, Greek, Hebrew, Arabic-script, and Armenian. Everything else // (Latin and unknown) is treated as single-byte. The padding makes each match whole-word. // Latin-script languages with heavy diacritics (e.g. Vietnamese) are intentionally // single-byte: slugs pass through wc_sanitize_taxonomy_name(), whose sanitize_title() // call transliterates accented Latin letters to plain ASCII before the byte limit // applies ('Tiếng Việt đậm nhạt' is stored as 'tieng-viet-dam-nhat'). $three_byte = ' zh ja ko th ka hi bn ne ta te mr gu kn ml pa or si km lo my am as bo dzo '; $two_byte = ' ru uk bg sr be bel mk kk ky kir tg tt mn sah el he ar ary azb ckb fa haz ps skr snd ug ur hy '; if ( false !== strpos( $three_byte, " {$language} " ) ) { $byte_width = 3; } elseif ( false !== strpos( $two_byte, " {$language} " ) ) { $byte_width = 2; } else { $byte_width = 1; } return max( 1, intdiv( wc_get_attribute_slug_max_byte_length(), $byte_width ) ); } }