From 54388cece507c3ce125ece1a0bf7bb81feb0f585 Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Tue, 16 Nov 2021 15:44:21 +0100 Subject: [PATCH] Follow-up: 64a87b1c67 - Let the pot string extractor ignore empty strings. --- lib/generators/translation_catalog/extractor/erb.rb | 2 +- lib/generators/translation_catalog/extractor/frontend.rb | 2 +- lib/generators/translation_catalog/extractor/ruby.rb | 2 +- .../generators/translation_catalog/extractor/erb_spec.rb | 1 + .../translation_catalog/extractor/frontend_spec.rb | 6 +++++- .../generators/translation_catalog/extractor/ruby_spec.rb | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/generators/translation_catalog/extractor/erb.rb b/lib/generators/translation_catalog/extractor/erb.rb index f32200bb7..fd36b0e39 100644 --- a/lib/generators/translation_catalog/extractor/erb.rb +++ b/lib/generators/translation_catalog/extractor/erb.rb @@ -6,7 +6,7 @@ class Generators::TranslationCatalog::Extractor::Erb < Generators::TranslationCa return if string.empty? # zt() / t() - literal_string_regex = %r{(['"])(.*?)(? <%= t("String with #{interpolation}") %> + <%= t("") %> # should not happen CODE end diff --git a/spec/lib/generators/translation_catalog/extractor/frontend_spec.rb b/spec/lib/generators/translation_catalog/extractor/frontend_spec.rb index 3ffc116e9..2f76080ec 100644 --- a/spec/lib/generators/translation_catalog/extractor/frontend_spec.rb +++ b/spec/lib/generators/translation_catalog/extractor/frontend_spec.rb @@ -18,11 +18,13 @@ RSpec.describe Generators::TranslationCatalog::Extractor::Frontend do App.i18n.translateContent('String') App.i18n.translateInline('Inline string') App.i18n.translatePlain("Double quoted String with '") + @T('T') + @Ti('Ti') CODE end it 'finds the correct strings' do - expect(result_strings).to eq(Set['__ String', 'String', 'Inline string', "Double quoted String with '"]) + expect(result_strings).to eq(Set['__ String', 'String', 'Inline string', "Double quoted String with '", 'T', 'Ti']) end end @@ -31,6 +33,8 @@ RSpec.describe Generators::TranslationCatalog::Extractor::Frontend do <<~'CODE' App.i18n.translateContent(dynamic_variable) App.i18n.translateContent("String with #{interpolation}") + @Tdate(ignore) + @Ti('') CODE end diff --git a/spec/lib/generators/translation_catalog/extractor/ruby_spec.rb b/spec/lib/generators/translation_catalog/extractor/ruby_spec.rb index 93b50eb4b..b836c3a83 100644 --- a/spec/lib/generators/translation_catalog/extractor/ruby_spec.rb +++ b/spec/lib/generators/translation_catalog/extractor/ruby_spec.rb @@ -33,6 +33,7 @@ RSpec.describe Generators::TranslationCatalog::Extractor::Ruby do <<~'CODE' Translation.translate('de-de', dynamic_variable) Translation.translate('de-de', "String with #{interpolation}") + __('') CODE end