Class LocaleIdentifierValidator

java.lang.Object
org.ek9lang.compiler.common.LocaleIdentifierValidator

public final class LocaleIdentifierValidator extends Object
Authoritative validator for EK9 locale identifiers used in defines text for "<locale>" blocks. The regex matches Phase 1's TextLanguageExtraction rule exactly — both point at this class so editor pre-call validation and compiler diagnostic emission share a single source of truth (compiler error E07900 INVALID_VALUE).

Format: lowercase language code, optionally followed by an underscore and an uppercase country code:

  • VALID: en, en_GB, de, fr_FR, ja_JP
  • INVALID: "EN" (uppercase base), "EN_US" (uppercase base), "en-US" (hyphen separator), "en_us" (lowercase country)
  • Field Details

    • LOCALE_PATTERN

      public static final Pattern LOCALE_PATTERN
      The EK9 locale-identifier pattern. Used by TextLanguageExtraction for Phase 1 SYMBOL_DEFINITION validation and by editor tools for pre-call validation.
    • LOCALE_REGEX

      public static final String LOCALE_REGEX
      The regex source as a string — useful in tool documentation and error messages.
      See Also:
  • Method Details

    • isValidLocale

      public static boolean isValidLocale(String locale)
      Parameters:
      locale - the locale identifier to validate (no surrounding quotes)
      Returns:
      true if the locale matches the EK9 locale-identifier rule