Severity: Error — causes exit code 1 and fails CI builds.
The hardcoded-text rule currently does not run on
.astro files. Astro
support is limited to translation key usage analysis for now.Detection Rule
Text is flagged as hardcoded if it contains at least one Unicode alphabetic character (char::is_alphabetic()). This approach:
- Supports all languages (English, Chinese, Japanese, etc.)
- Ignores pure numbers like
123or456.78 - Ignores pure symbols like
---or*** - Catches mixed content like
Price: $99(contains letters)
What Gets Detected
JSX Text Content
Direct text inside JSX elements:String Expressions
String literals in JSX expressions:Ternary Operators
Text in conditional expressions:Logical Operators
Text in logical expressions:Template Literals
Template strings with text:Multiline JSX Text
Text spanning multiple lines:JSX Fragments
Text in fragments:Checked Attributes
By default, glot checks these JSX attributes for hardcoded text:Configuring Checked Attributes
You can customize which attributes are checked in.glotrc.json:
Setting
checkedAttributes overrides the defaults. Include all attributes you
want checked.What’s NOT Detected
Glot is smart about ignoring certain patterns:Translation Function Calls
Recognized translation patterns are ignored:Pure Numbers and Symbols
Code Examples
Code blocks typically aren’t in JSX context and aren’t checked.Suppressed Lines
Lines with suppression directives:Examples
Form Component
Form Component
Related
Check Command
Run hardcoded text detection
Directives
Suppress specific warnings