lib/gettext/po_entry.rb in gettext-3.2.2 vs lib/gettext/po_entry.rb in gettext-3.2.3

- old
+ new

@@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2012-2014 Kouhei Sutou <kou@clear-code.com> +# Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com> # Copyright (C) 2010 masone (Christian Felder) <ema@rh-productions.ch> # Copyright (C) 2009 Masao Mutoh # # License: Ruby's or LGPL # @@ -81,11 +81,11 @@ # Support for extracted comments. Explanation s. # http://www.gnu.org/software/gettext/manual/gettext.html#Names # @return [void] def add_comment(new_comment) if (new_comment and ! new_comment.empty?) - @extracted_comment ||= "" + @extracted_comment ||= String.new @extracted_comment << "\n" unless @extracted_comment.empty? @extracted_comment << new_comment end end @@ -364,11 +364,11 @@ def include_previous_comment? @options[:include_previous_comment] end def format_comments - formatted_comment = "" + formatted_comment = String.new if include_translator_comment? formatted_comment << format_translator_comment end if include_extracted_comment? formatted_comment << format_extracted_comment @@ -393,11 +393,11 @@ format_comment(EXTRACTED_COMMENT_MARK, @entry.extracted_comment) end def format_reference_comment max_line_width = @options[:max_line_width] - formatted_reference = "" + formatted_reference = String.new if not @entry.references.nil? and not @entry.references.empty? formatted_reference << REFERENCE_COMMENT_MARK line_width = 2 @entry.references.each do |reference| if max_line_width > 0 and @@ -415,11 +415,11 @@ end formatted_reference end def format_flag_comment - formatted_flags = "" + formatted_flags = String.new @entry.flags.each do |flag| formatted_flags << format_comment(FLAG_MARK, flag) end formatted_flags end @@ -429,11 +429,11 @@ end def format_comment(mark, comment) return "" if comment.nil? - formatted_comment = "" + formatted_comment = String.new comment.each_line do |comment_line| if comment_line == "\n" formatted_comment << "#{mark}\n" else formatted_comment << "#{mark} #{comment_line.strip}\n" @@ -444,11 +444,11 @@ def format_obsolete_comment(comment) mark = "#~" return "" if comment.nil? - formatted_comment = "" + formatted_comment = String.new comment.each_line do |comment_line| if /\A#[^~]/ =~ comment_line or comment_line.start_with?(mark) formatted_comment << "#{comment_line.chomp}\n" elsif comment_line == "\n" formatted_comment << "\n" @@ -464,10 +464,10 @@ return empty_formatted_message if message.nil? chunks = wrap_message(message) return empty_formatted_message if chunks.empty? - formatted_message = "" + formatted_message = String.new if chunks.size > 1 or chunks.first.end_with?("\n") formatted_message << empty_formatted_message end chunks.each do |chunk| formatted_message << "\"#{escape(chunk)}\"\n"