vscode, sublime text configs
This commit is contained in:
17
configs/sublime-text/User/wrap_gettext_translate.py
Normal file
17
configs/sublime-text/User/wrap_gettext_translate.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import sublime
|
||||
import sublime_plugin
|
||||
|
||||
class WrapInDjangoGettextCommand(sublime_plugin.TextCommand):
|
||||
def run(self, edit):
|
||||
for region in self.view.sel():
|
||||
if not region.empty():
|
||||
# Get the selected text
|
||||
selected_text = self.view.substr(region)
|
||||
# Create the translated text
|
||||
if "\"" in selected_text or "\'" in selected_text:
|
||||
base = '_({})'
|
||||
else:
|
||||
base = '_("{}")'
|
||||
translated_text = base.format(selected_text)
|
||||
# Replace the selection with the translated text
|
||||
self.view.replace(edit, region, translated_text)
|
||||
Reference in New Issue
Block a user