mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
completions: Detect translatable properties
Looked through the Gtk documentation (and a few other libraries) to make a list of all the properties that should probably be translated. If a property is on the list, the language server will mark it as translated in completions.
This commit is contained in:
parent
ac70ea7403
commit
5b0f662478
2 changed files with 199 additions and 2 deletions
|
@ -20,7 +20,7 @@
|
|||
import sys
|
||||
import typing as T
|
||||
|
||||
from . import gir, language
|
||||
from . import annotations, gir, language
|
||||
from .ast_utils import AstNode
|
||||
from .completions_utils import *
|
||||
from .language.types import ClassName
|
||||
|
@ -154,11 +154,17 @@ def property_completer(lsp, ast_node, match_variables):
|
|||
detail=prop.detail,
|
||||
)
|
||||
elif isinstance(prop.type, gir.StringType):
|
||||
snippet = (
|
||||
f'{prop_name}: _("$0");'
|
||||
if annotations.is_property_translated(prop)
|
||||
else f'{prop_name}: "$0";'
|
||||
)
|
||||
|
||||
yield Completion(
|
||||
prop_name,
|
||||
CompletionItemKind.Property,
|
||||
sort_text=f"0 {prop_name}",
|
||||
snippet=f'{prop_name}: "$0";',
|
||||
snippet=snippet,
|
||||
docs=prop.doc,
|
||||
detail=prop.detail,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue