Available Directives
| Directive | Scope |
|---|---|
glot-disable-next-line | Suppresses the next line only |
glot-disable | Starts suppression block |
glot-enable | Ends suppression block |
glot-message-keys | Declares dynamic keys as used |
Line Suppression
Useglot-disable-next-line to suppress warnings for the next line:
Block Suppression
Useglot-disable and glot-enable to suppress a section:
glot-disable and glot-enable is ignored.
File-Level Suppression
Placeglot-disable on the first or second line to disable the entire file:
File-level suppression only works if
glot-disable appears on line 1 or 2 of
the file.JSX Comments
In JSX context, use JSX comment syntax:Mixed Contexts
You can mix JavaScript and JSX comments:Block Behavior
Nesting
Blocks cannot be nested. The firstglot-enable closes the block:
Same-Line Enable
Code on the same line asglot-enable is checked:
Unclosed Blocks
An unclosedglot-disable suppresses everything after it:
Dynamic Key Declaration
Useglot-message-keys to declare which translation keys are used dynamically. This is essential for dynamic keys that cannot be statically analyzed.
Why Use This?
When you use dynamic keys liket(`items.${type}`), glot cannot determine which keys are actually used. This causes two problems:
- The
checkcommand reports a dynamic key warning - The
cleancommand refuses to run (to prevent accidental key deletion)
glot-message-keys solves both problems by explicitly declaring which keys are used.
Syntax
JavaScript/TypeScript comments:Pattern Types
Literal Keys
Declare exact key names:Glob Patterns
Use* as a wildcard to match multiple keys:
Prefix wildcards like
"*.title" are not supported. The wildcard must appear
after at least one segment.Dynamic Key Use Cases
Conditional Keys
Array Iteration
Object Property Access
How It Works with Clean
Keys declared viaglot-message-keys are marked as “used” in glot’s analysis:
- The
checkcommand no longer warns about the dynamic key - The
cleancommand can run safely because it knows which keys are in use - Declared keys will not be accidentally deleted as “unused”
glot-disable-next-line, which only suppresses the warning without telling glot which keys are actually used.
Use Cases
Third-Party Components
When using components that require hardcoded text:Development Placeholders
Temporary text during development:Legal or Technical Text
Text that shouldn’t be translated:Legacy Code
Sections being migrated gradually:Baseline Command
Instead of manually adding directives, use thebaseline command:
Best Practices
Be Specific
Prefer
glot-disable-next-line over blocks when possibleAdd Context
Include a comment explaining why suppression is needed
Use glot-message-keys for Dynamic Keys
Prefer declaring keys over disabling checks for dynamic key usage
Review Regularly
Periodically check suppressed items to see if they can be fixed
Track in CI
Monitor the count of suppressed items over time