Files
useful/configs/sublime-text/User/wrap_template_translate.py

14 lines
554 B
Python

import sublime
import sublime_plugin
class WrapInDjangoTranslateCommand(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
translated_text = '{{% translate "{}" %}}'.format(selected_text)
# Replace the selection with the translated text
self.view.replace(edit, region, translated_text)