mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
* more tweaks to the translation engine to ease the translations
This commit is contained in:
parent
b57c33fe7b
commit
2498c5e44a
@ -42,7 +42,7 @@ Choice.options do
|
|||||||
short '-f'
|
short '-f'
|
||||||
long '--file=SNIPPET FILE NAME'
|
long '--file=SNIPPET FILE NAME'
|
||||||
desc 'A specific snippet that you want to copy or a glob for various files'
|
desc 'A specific snippet that you want to copy or a glob for various files'
|
||||||
default '*.{tmSnippet,plist,tmMacro}'
|
default '*.{tmSnippet,tmCommand,plist,tmMacro}'
|
||||||
end
|
end
|
||||||
|
|
||||||
option :print_pretty do
|
option :print_pretty do
|
||||||
@ -173,7 +173,9 @@ class TmSnippet
|
|||||||
"${TM_RAILS_TEMPLATE_START_RUBY_INLINE}" => "<% ",
|
"${TM_RAILS_TEMPLATE_START_RUBY_INLINE}" => "<% ",
|
||||||
"${TM_RAILS_TEMPLATE_END_RUBY_INLINE}" => " -%>",
|
"${TM_RAILS_TEMPLATE_END_RUBY_INLINE}" => " -%>",
|
||||||
"${TM_RAILS_TEMPLATE_END_RUBY_BLOCK}" => "end" ,
|
"${TM_RAILS_TEMPLATE_END_RUBY_BLOCK}" => "end" ,
|
||||||
"${0:$TM_SELECTED_TEXT}" => "${0:`yas/selected-text`" },
|
"${0:$TM_SELECTED_TEXT}" => "${0:`yas/selected-text`}",
|
||||||
|
"${1:$TM_SELECTED_TEXT}" => "${1:`yas/selected-text`}",
|
||||||
|
"${2:$TM_SELECTED_TEXT}" => "${2:`yas/selected-text`}"},
|
||||||
"condition" => {
|
"condition" => {
|
||||||
/^source\..*$/ => "" },
|
/^source\..*$/ => "" },
|
||||||
"binding" => {},
|
"binding" => {},
|
||||||
@ -226,7 +228,12 @@ class TmSnippet
|
|||||||
end
|
end
|
||||||
|
|
||||||
def type
|
def type
|
||||||
yas_directive "type"
|
override = yas_directive "type"
|
||||||
|
if override
|
||||||
|
return override
|
||||||
|
else
|
||||||
|
return "# type: command\n" if @file =~ /(Commands\/)/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def binding
|
def binding
|
||||||
@ -238,24 +245,29 @@ class TmSnippet
|
|||||||
merge(@@extra_substitutions["content"])[uuid]
|
merge(@@extra_substitutions["content"])[uuid]
|
||||||
return direct
|
return direct
|
||||||
else
|
else
|
||||||
content = @snippet["content"]
|
ct = @snippet["content"]
|
||||||
if content
|
|
||||||
|
if ct
|
||||||
@@known_substitutions["content"].
|
@@known_substitutions["content"].
|
||||||
merge(@@extra_substitutions["content"]).
|
merge(@@extra_substitutions["content"]).
|
||||||
each_pair do |k,v|
|
each_pair do |k,v|
|
||||||
content.gsub!(k,v)
|
ct.gsub!(k,v)
|
||||||
end
|
end
|
||||||
# the remaining stuff is an unknown substitution
|
# the remaining stuff is an unknown substitution
|
||||||
#
|
#
|
||||||
[ %r'\$\{ [^/\}\{:]* / [^/]* / [^/]* / [^\}]*\}'x ,
|
[ %r'\$\{ [^/\}\{:]* / [^/]* / [^/]* / [^\}]*\}'x ,
|
||||||
%r'\$\{[^\d][^}]+\}'x ,
|
%r'\$\{[^\d][^}]+\}',
|
||||||
%r'`[^`]+`'
|
%r'`[^`]+`',
|
||||||
|
%r'\$TM_[\w_]+'
|
||||||
].each do |reg|
|
].each do |reg|
|
||||||
content.scan(reg) do |match|
|
ct.scan(reg) do |match|
|
||||||
@@unknown_substitutions["content"][match] = self
|
@@unknown_substitutions["content"][match] = self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return content
|
return ct
|
||||||
|
else
|
||||||
|
@@unknown_substitutions["content"][uuid] = self
|
||||||
|
return "(yas/unimplemented)"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -265,12 +277,12 @@ class TmSnippet
|
|||||||
doc << (self.type || "")
|
doc << (self.type || "")
|
||||||
doc << "# uuid: #{self.uuid}\n"
|
doc << "# uuid: #{self.uuid}\n"
|
||||||
doc << "# key: #{self.key}\n" if self.key
|
doc << "# key: #{self.key}\n" if self.key
|
||||||
doc << "# contributor: Translated from TextMate Snippet\n"
|
doc << "# contributor: Translated from textmate snippet by PROGRAM_NAME\n"
|
||||||
doc << "# name: #{self.name}\n"
|
doc << "# name: #{self.name}\n"
|
||||||
doc << (self.binding || "")
|
doc << (self.binding || "")
|
||||||
doc << (self.condition || "")
|
doc << (self.condition || "")
|
||||||
doc << "# --\n"
|
doc << "# --\n"
|
||||||
doc << (self.content || "")
|
doc << (self.content || "(yas/unimplemented)")
|
||||||
doc
|
doc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user