Skip to content

Commit

Permalink
Avoid breaking the build of yast2.rpm (bsc#1130822)
Browse files Browse the repository at this point in the history
If /usr/share/YaST2/locale does not exist (eg. during the building of
yast2.rpm) FastGettext will complain. So in that case bail out of
`textdomain` and `_`+friends.

Here's how it broke without this fix:

+Log	No textdomain configured in Yast::CommandLineClass, cannot translate "Print the help for this module"

The log line *appears* because it is now reported at CommandLine.rb
(previously i18n.rb) which matches the "testedfiles" filter of the
testsuite.

The error *happens* the "textdomain" method returns early before
remembering its argument.
  • Loading branch information
mvidner committed May 20, 2019
1 parent e297e6b commit 89bd462
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/ruby/yast/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ def textdomain(domain) # usually without brackets like textdomain "example"
def _(str)
# no textdomain configured yet
if !@my_textdomain
msg = "No textdomain configured in #{self.class}, " \
"cannot translate #{str.inspect}"
raise msg if ENV["Y2STRICTTEXTDOMAIN"]
Yast.y2warning(1, "%1", msg) # skip 1 frame
if File.exist?(LOCALE_DIR)
msg = "No textdomain configured in #{self.class}, " \
"cannot translate #{str.inspect}"
raise msg if ENV["Y2STRICTTEXTDOMAIN"]
Yast.y2warning(1, "%1", msg) # skip 1 frame
end
return str.freeze
end

Expand Down Expand Up @@ -123,11 +125,13 @@ def Nn_(*keys)
def n_(singular, plural, num)
# no textdomain configured yet
if !@my_textdomain
# it's enough to log just the singular form
msg = "No textdomain configured in #{self.class}, " \
"cannot translate #{singular.inspect}"
raise msg if ENV["Y2STRICTTEXTDOMAIN"]
Yast.y2warning(1, "%1", msg) # skip 1 frame
if File.exist?(LOCALE_DIR)
# it's enough to log just the singular form
msg = "No textdomain configured in #{self.class}, " \
"cannot translate #{singular.inspect}"
raise msg if ENV["Y2STRICTTEXTDOMAIN"]
Yast.y2warning(1, "%1", msg) # skip 1 frame
end
return fallback_n_(singular, plural, num)
end

Expand Down

0 comments on commit 89bd462

Please sign in to comment.