GithubHelp home page GithubHelp logo

Apostrophe Issue about babelish HOT 1 OPEN

ExPl0siF avatar ExPl0siF commented on July 24, 2024
Apostrophe Issue

from babelish.

Comments (1)

falkorichter avatar falkorichter commented on July 24, 2024 1

we have a workaround:

csv2android.rb:

require 'uri'
module Babelish
 class CSV2Android < Csv2Base
 attr_accessor :file_path
 def initialize(filename, langs, args = {})
 super(filename, langs, args)
 @file_path = args[:output_dir].to_s
 end
 def language_filepaths(language)
 require 'pathname'
 filepath = Pathname.new(@file_path) + "values-#{language.code}" + "strings.xml"
 return filepath ? [filepath] : []
 end
 def process_value(row_value, default_value)
 value = super(row_value, default_value)
 value.gsub!(/'/, "'" => "\\'") # escape single quote only for Android
 value.gsub!(/&/, "&" => '&amp;')
 # if the value begins and ends with a quote we must leave them unescaped
 if value.size > 4 && value[0, 2] == "\\\"" && value[value.size - 2, value.size] == "\\\""
 value[0, 2] = "\""
 value[value.size - 2, value.size] = "\""
 end
 value.to_utf8
 end
 def get_row_format(row_key, row_value, comment = nil, indentation = 0)
 entry = comment.to_s.empty? ? "" : "\n\t<!-- #{comment} -->\n"
 entry + "\t<string name=\"#{row_key}\">#{row_value}</string>\n"
 end
 def hash_to_output(content = {})
 output = ''
 if content && content.size > 0
 output += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
 output += "<resources>\n"
 content.each do |key, value|
 comment = @comments[key]
 output += get_row_format(key, value, comment)
 end
 output += "</resources>\n"
 end
 return output
 end
 def extension
 "xml"
 end
 end
end

I hope to find some time and prepare a pull request these days...

from babelish.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.