Don't add empty strings into source file
This commit is contained in:
parent
b4cc2cf5e0
commit
9924c83b85
@ -1,10 +1,14 @@
|
||||
module Jekyll
|
||||
module TranslateFilter
|
||||
def translate_text(input)
|
||||
if input.nil? or input.empty?
|
||||
input
|
||||
else
|
||||
text = input.strip
|
||||
weblate_id = Weblate::ID.get(input)
|
||||
page_language = @context.environments.first["page"]["language"]
|
||||
site = @context.registers[:site]
|
||||
|
||||
if page_language.nil?
|
||||
Weblate::SourceFile.add_entry(weblate_id, text)
|
||||
|
||||
@ -15,6 +19,7 @@ module Jekyll
|
||||
translated_string.nil? ? text : translated_string.strip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def translate_page(page)
|
||||
page_language = @context.environments.first["page"]["language"]
|
||||
|
@ -27,7 +27,7 @@ module Weblate
|
||||
class SourceFile
|
||||
class << self
|
||||
def add_entry(weblate_id, source_text)
|
||||
unless id_already_exists?(weblate_id) or source_text.nil?
|
||||
unless id_already_exists?(weblate_id) or source_text.nil? or source_text.empty?
|
||||
new_entry = <<-YAML
|
||||
#{weblate_id}: |
|
||||
#{source_text}
|
||||
|
Reference in New Issue
Block a user