This repository has been archived by the owner on May 23, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# How do you surround marked text with a custom snippet? | ||
|
||
In order to mark strings as "translatable" in Flask via Flask-WTF, you need to apply special syntax. | ||
|
||
This means, e.g. in a Jinja template a string like `Conference` has to be transformed into `{{ _('Conference') }}`. | ||
|
||
This is a very tedious work, so I created a shortcut for it. | ||
|
||
Add the following lines to your `keybindings.json`: | ||
|
||
"key": "ctrl+shift+alt+0", | ||
"command": "editor.action.insertSnippet", | ||
"when": "editorHasSelection || editorHasMultipleSelections", | ||
"args": { | ||
"snippet": "{{ _('${TM_SELECTED_TEXT}') }}" | ||
} | ||
|
||
I used "ctrl+shift+alt+0" as on the German keyboard the closing curly brace is on the same key as the `0`. | ||
|
||
via https://stackoverflow.com/a/53545200/672833 |