Skip to content

Commit a060152

Browse files
akoclaude
andcommitted
feat: add SHOW LANGUAGES command and QUAL005 missing translations linter rule
SHOW LANGUAGES lists all languages found in the project's translatable strings with counts, useful for translation workflows: mdl> SHOW LANGUAGES; | Language | Strings | |------------|---------| | en_US | 142 | | nl_NL | 87 | QUAL005 (MissingTranslations) linter rule detects elements that have translations in some languages but not all languages used in the project: [QUAL005] Missing 'nl_NL' translation for PAGE MyModule.EditCustomer (page_title: "Edit Customer") Both features build on the Language column added to the catalog strings table in the previous commit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cad7afa commit a060152

File tree

15 files changed

+5576
-5326
lines changed

15 files changed

+5576
-5326
lines changed

mdl/ast/ast_query.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const (
8484
ShowContractActions // SHOW CONTRACT ACTIONS FROM Module.Service
8585
ShowContractChannels // SHOW CONTRACT CHANNELS FROM Module.Service (AsyncAPI)
8686
ShowContractMessages // SHOW CONTRACT MESSAGES FROM Module.Service (AsyncAPI)
87+
ShowLanguages // SHOW LANGUAGES
8788
)
8889

8990
// String returns the human-readable name of the show object type.
@@ -199,6 +200,8 @@ func (t ShowObjectType) String() string {
199200
return "CONTRACT CHANNELS"
200201
case ShowContractMessages:
201202
return "CONTRACT MESSAGES"
203+
case ShowLanguages:
204+
return "LANGUAGES"
202205
default:
203206
return "UNKNOWN"
204207
}

mdl/executor/cmd_languages.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package executor
4+
5+
import (
6+
"fmt"
7+
)
8+
9+
// showLanguages lists all languages found in the project's translatable strings.
10+
// Requires REFRESH CATALOG FULL to populate the strings table.
11+
func (e *Executor) showLanguages() error {
12+
if e.catalog == nil {
13+
return fmt.Errorf("no catalog available — run REFRESH CATALOG FULL first")
14+
}
15+
16+
result, err := e.catalog.Query(`
17+
SELECT Language, COUNT(*) as StringCount
18+
FROM strings
19+
WHERE Language != ''
20+
GROUP BY Language
21+
ORDER BY StringCount DESC
22+
`)
23+
if err != nil {
24+
return fmt.Errorf("failed to query languages: %w", err)
25+
}
26+
27+
if len(result.Rows) == 0 {
28+
fmt.Fprintln(e.output, "No translatable strings found. Run REFRESH CATALOG FULL to populate the strings table.")
29+
return nil
30+
}
31+
32+
// Print table
33+
fmt.Fprintf(e.output, "| %-10s | %s |\n", "Language", "Strings")
34+
fmt.Fprintf(e.output, "|%-12s|%s|\n", "------------", "---------")
35+
for _, row := range result.Rows {
36+
lang := ""
37+
count := ""
38+
if len(row) > 0 {
39+
lang = fmt.Sprintf("%v", row[0])
40+
}
41+
if len(row) > 1 {
42+
count = fmt.Sprintf("%v", row[1])
43+
}
44+
fmt.Fprintf(e.output, "| %-10s | %7s |\n", lang, count)
45+
}
46+
47+
fmt.Fprintf(e.output, "\n(%d languages)\n", len(result.Rows))
48+
return nil
49+
}

mdl/executor/cmd_lint.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func (e *Executor) execLint(s *ast.LintStmt) error {
5656
lint.AddRule(rules.NewDomainModelSizeRule())
5757
lint.AddRule(rules.NewValidationFeedbackRule())
5858
lint.AddRule(rules.NewImageSourceRule())
59+
lint.AddRule(rules.NewMissingTranslationsRule())
5960

6061
// Load custom Starlark rules
6162
rulesDir := filepath.Join(projectDir, ".claude", "lint-rules")
@@ -122,6 +123,7 @@ func (e *Executor) showLintRules() error {
122123
lint.AddRule(rules.NewDomainModelSizeRule())
123124
lint.AddRule(rules.NewValidationFeedbackRule())
124125
lint.AddRule(rules.NewImageSourceRule())
126+
lint.AddRule(rules.NewMissingTranslationsRule())
125127

126128
for _, rule := range lint.Rules() {
127129
fmt.Fprintf(e.output, " %s (%s)\n", rule.ID(), rule.Name())

mdl/executor/executor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,8 @@ func (e *Executor) execShow(s *ast.ShowStmt) error {
786786
return e.showRestClients(s.InModule)
787787
case ast.ShowPublishedRestServices:
788788
return e.showPublishedRestServices(s.InModule)
789+
case ast.ShowLanguages:
790+
return e.showLanguages()
789791
case ast.ShowContractEntities:
790792
return e.showContractEntities(s.Name)
791793
case ast.ShowContractActions:

mdl/grammar/MDLLexer.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ CONNECTIONS: C O N N E C T I O N S;
513513
DEFINE: D E F I N E;
514514
FRAGMENT: F R A G M E N T;
515515
FRAGMENTS: F R A G M E N T S;
516+
LANGUAGES: L A N G U A G E S;
516517

517518
// ALTER PAGE keywords
518519
INSERT: I N S E R T;

mdl/grammar/MDLParser.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2539,6 +2539,7 @@ showStatement
25392539
| SHOW DATABASE CONNECTIONS (IN (qualifiedName | IDENTIFIER))? // SHOW DATABASE CONNECTIONS [IN module]
25402540
| SHOW REST CLIENTS (IN (qualifiedName | IDENTIFIER))? // SHOW REST CLIENTS [IN module]
25412541
| SHOW PUBLISHED REST SERVICES (IN (qualifiedName | IDENTIFIER))? // SHOW PUBLISHED REST SERVICES [IN module]
2542+
| SHOW LANGUAGES // SHOW LANGUAGES
25422543
;
25432544

25442545
/**

mdl/grammar/parser/MDLLexer.interp

Lines changed: 4 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)