Comments (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!(/&/, "&" => '&')
# 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)
- Fetching csv file from google drive error HOT 3
- Sign in with Google temporarily disabled for this app HOT 17
- Cannot load such file -- babelish/keys HOT 5
- Ruby version 2.7.0 warnings
- Support OneDrive HOT 1
- Android strings.xml indented with tabs instead of spaces HOT 2
- Google disabled this app HOT 4
- Can't update fastlane due to dependency lock HOT 5
- docker image not working
- Ask credentials if invalid token
- android2csv: <plurals> are removed HOT 3
- Cannot found client_secret for Android Application when creating OAuth Client Id. HOT 1
- Omit Empty translations CSV2Any HOT 2
- Error while running `babelish csv2android` because of thor dependency HOT 3
- Custom CSV2STRINGS -> cannot load such file -- babelish/keys HOT 1
- can't read text when convert japanese HOT 6
- Unexpected error: #<Faraday::ConnectionFailed wrapped=#<Net::OpenTimeout: execution expired>> HOT 1
- Problem with MacOS 12.3 Monterey HOT 2
- Google issue HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babelish.