siuying/zhconv

bug

Opened this issue · 0 comments

def self.convert(variant, message, use_web=true)    
    if use_web
      case variant
      when "zh-cn", "zh-sg"
        converter = web_converter(variant)
        message = converter.convert(message)
      when "zh-tw", "zh-hk"
        converter = web_converter(variant)
        message = converter.convert(message)
         puts "called"
      end
    end
    # li: here is a bug. use_web result is converd by the local ones
    case variant
    when "zh-cn", "zh-sg"
        
      converter = local_converter(variant)
      message = converter.convert(message)
    when "zh-tw", "zh-hk"
       # puts "called"
      converter = local_converter(variant)
      message = converter.convert(message)
       puts "called"
    end
    if use_web  
      case variant
      when "zh-hans", "zh-cn", "zh-sg"
        converter = web_converter("zh-hans"
        message = converter.convert(message)
      when "zh-hant", "zh-tw", "zh-hk"
        converter = web_converter("zh-hant")
        message = converter.convert(message)
      end
    end
    
    case variant
    when "zh-hans", "zh-cn", "zh-sg"
      converter = local_converter("zh-hans")
      message = converter.convert(message)
    when "zh-hant", "zh-tw", "zh-hk"
      converter = local_converter("zh-hant")
      message = converter.convert(message)
    end

    message
  end

In fact local_converter is called no matter you set use_web to true or false