ruby-gettext / gettext

Gettext gem is a pure Ruby Localization(L10n) library and tool which is modeled after the GNU gettext package.
https://ruby-gettext.github.io/
68 stars 28 forks source link

gettext:find not finding all message IDs if .erb file contains -%> closing tags #77

Closed lremes closed 4 years ago

lremes commented 4 years ago

Message IDs are not picked up by gettext:find / rxgettext if .erb file contains -%> closing tag.

Neither ID is picked up:

<% content_for :javascript_includes do %>
<%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" %>
<% end -%>
<%= fa_icon('building', title: _("View account's calendar")) %> <%= _("Account's events") %>

Result:

% rxgettext gettext_test.erb
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-17 17:38+0200\n"
"PO-Revision-Date: 2020-03-17 17:38+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

If the ending tag is changed from '-%>' to '%>' it works:

<% content_for :javascript_includes do %>
<%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" %>
<% end %>
<%= fa_icon('building', title: _("View account's calendar")) %> <%= _("Account's events") %>
% rxgettext gettext_test.erb
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-17 17:37+0200\n"
"PO-Revision-Date: 2020-03-17 17:37+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#: gettext_test.erb:4
msgid "View account's calendar"
msgstr ""

#: gettext_test.erb:4
msgid "Account's events"
msgstr ""

-%> is a valid end tag, and thus it should be allowed. https://api.rubyonrails.org/classes/ActionView/Base.html

kou commented 4 years ago

Thanks for your report. I've fixed this.