netbe / babelish Goto Github PK
View Code? Open in Web Editor NEWChaotically confused, like Babel
Home Page: http://netbe.github.io/Babelish
License: MIT License
Chaotically confused, like Babel
Home Page: http://netbe.github.io/Babelish
License: MIT License
Catch xml parser in the android2csv command.
If I try to convert an malformed xml file i got the following error:
/home/neoklosch/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:340:in `pull_event': Missing end tag for 'p' (got "string") (REXML::ParseException)
Line: 10
Position: 649
Last 80 unconsumed characters:
from /home/neoklosch/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:184:in `pull'
from /home/neoklosch/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/parsers/treeparser.rb:22:in `parse'
from /home/neoklosch/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/document.rb:287:in `build'
from /home/neoklosch/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/document.rb:44:in `initialize'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/xml-simple-1.1.5/lib/xmlsimple.rb:971:in `new'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/xml-simple-1.1.5/lib/xmlsimple.rb:971:in `parse'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/xml-simple-1.1.5/lib/xmlsimple.rb:1013:in `load_xml_file'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/xml-simple-1.1.5/lib/xmlsimple.rb:186:in `xml_in'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/xml-simple-1.1.5/lib/xmlsimple.rb:203:in `xml_in'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/babelish-0.4.0/lib/babelish/android2csv.rb:13:in `load_strings'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/babelish-0.4.0/lib/babelish/base2csv.rb:31:in `block in convert'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/babelish-0.4.0/lib/babelish/base2csv.rb:29:in `each'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/babelish-0.4.0/lib/babelish/base2csv.rb:29:in `convert'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/babelish-0.4.0/lib/babelish/commandline.rb:165:in `base2csv'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/babelish-0.4.0/lib/babelish/commandline.rb:56:in `block (2 levels) in <class:Commandline>'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/babelish-0.4.0/bin/babelish:6:in `<top (required)>'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/bin/babelish:23:in `load'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/bin/babelish:23:in `<main>'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
A propper error handling would be helpful.
I don't know if this intended
Hey,
i want to have link on string file, but when i leave <a href="sherif-activity://sms-information-activity">
to google spreadsheets then Babelish translate it to <a href=\"sherif-activity://sms-information-activity\">
. Is there a way to leave the special character like a " make it Babelish " after translation (like a " in java string or in regex)?
I am getting this error with 0.1.5:
./convert.rb
Parsing filename : en.lproj/Localizable.strings
./convert.rb:32:in match': invalid byte sequence in US-ASCII (ArgumentError) from ./convert.rb:32:in
match'
from ./convert.rb:32:in block (2 levels) in load_strings' from ./convert.rb:29:in
each_line'
from ./convert.rb:29:in block in load_strings' from ./convert.rb:28:in
open'
from ./convert.rb:28:in load_strings' from ./convert.rb:61:in
block in dotstrings_to_csv'
from ./convert.rb:58:in each' from ./convert.rb:58:in
dotstrings_to_csv'
from ./convert.rb:153:in `
Hello,
we are having issues running Babelish when "fetch" property is set to "true".
This is the error we get:
C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:921:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::SSLError)
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:921:in `block in connect'
from C:/Ruby200-x64/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:921:in `connect'
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:851:in `start'
from C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:1373:in `request'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:82:in `perform_request'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:40:in `block in call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:87:in `with_net_http_connection'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:32:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.9.2/lib/faraday/request/url_encoded.rb:15:in `call'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.9.2/lib/faraday/rack_builder.rb:139:in `build_response'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.9.2/lib/faraday/connection.rb:377:in `run_request'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/faraday-0.9.2/lib/faraday/connection.rb:177:in `post'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/signet-0.7.2/lib/signet/oauth_2/client.rb:960:in `fetch_access_token'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/signet-0.7.2/lib/signet/oauth_2/client.rb:998:in `fetch_access_token!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/google_drive-1.0.5/lib/google_drive.rb:154:in `saved_session'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/babelish-0.4.2/lib/babelish/google_doc.rb:45:in `authenticate'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/babelish-0.4.2/lib/babelish/google_doc.rb:50:in `file_with_name'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/babelish-0.4.2/lib/babelish/google_doc.rb:27:in `download_spreadsheet'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/babelish-0.4.2/lib/babelish/commandline.rb:116:in `download'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/babelish-0.4.2/lib/babelish/commandline.rb:135:in `csv2base'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/babelish-0.4.2/lib/babelish/commandline.rb:37:in `block (2 levels) in <class:Commandline>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/babelish-0.4.2/bin/babelish:6:in `<top (required)>'
from C:/Ruby200-x64/bin/babelish:23:in `load'
from C:/Ruby200-x64/bin/babelish:23:in `<main>'
We've searched for solution with no luck. Could you take a look and suggest what to do?
Thanks!
Google changes its apis, so need to upgrade soon.
https://github.com/gimite/google-drive-ruby before 20/04/2015
Is there a way to integrate comments into generated files on android like it already works on iOS ?
Thanks!
In an Android xml string file it's possible that an entry contains a CDATA block.
An example for that:
<string name="html"><![CDATA[<p>Text<p>]]></string>
After running the converter, the CDATA block is removed in the resulting csv.
result:
html,<p>Text<p>
If you convert the csv back to a xml the CDATA block is still missing and the xml file is completely wrong and it end in an error in android cause plain xml is not allowed.
result:
<string name="html"><p>Text<p></string>
I have installed by gem install csv2strings on ruby 1.9.3.
When I try to run a strings file through strings2csv I get this stack dump:
strings2csv --filenames=en.lproj/Localizable.strings -o=test.csv
/Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv/converter.rb:31:in `merge!': can't convert nil into Hash (TypeError)
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv/converter.rb:31:in `block (2 levels) in load_strings'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv/converter.rb:30:in `each_line'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv/converter.rb:30:in `block in load_strings'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv/converter.rb:29:in `open'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv/converter.rb:29:in `load_strings'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv/converter.rb:56:in `block in dotstrings_to_csv'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv/converter.rb:54:in `each'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv/converter.rb:54:in `dotstrings_to_csv'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/lib/strings2csv_command.rb:21:in `strings2csv'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/gems/csv2strings-0.2.1/bin/strings2csv:5:in `<top (required)>'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/bin/strings2csv:23:in `load'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/bin/strings2csv:23:in `<main>'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:15:in `eval'
from /Users/enginkurutepe/.rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:15:in `<main>'
The .strings file exists where it is supposed to. I have also tried using -i option with and without the equals sign. All with the same results.
Thanks a lot,
Engin.
required options prevent from loading options from yaml file
Command to generate a default configuration file for projects
In case of an app with many localizations some of them out of date, missing some keys and translations, using strings2csv to combine all localizations in a big csv results in a messed up csv. In the combined file, most of the keys don't have any translations, and some keys have all translations taken from the same Localizable.strings file.
I added the .babelish.config file and the keys_column:2 because the keys in my google drive file starts from 2nd row.
this is my sructure:
Category | Key | English | Notes
Run babelish csv2strings -i "Project Language" -L English:en --fetch
the .string file looks like this
"category1" = "";
"category2" = "";
....
Did i miss something ?
OS : OS X 10.8.5
ruby : 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
park$ date '+%F %r'
2013-11-07 02:19:36 PM
park$ git status
nothing to commit, working directory clean
park$ make translate
bundle exec csv2strings
/Users/park/Project/vendor/bundler/ruby/1.8/bundler/gems/mirror-CSV-to-iOS-Localizable.strings-converter-47ade2ded32c/lib/csvconverter.rb:4:in require': no such file to load -- orderedhash (LoadError) from /Users/park/Project/vendor/bundler/ruby/1.8/bundler/gems/mirror-CSV-to-iOS-Localizable.strings-converter-47ade2ded32c/lib/csvconverter.rb:4 from /Users/park/Project/vendor/bundler/ruby/1.8/bundler/gems/mirror-CSV-to-iOS-Localizable.strings-converter-47ade2ded32c/bin/csv2strings:4:in
require'
from /Users/park/Project/vendor/bundler/ruby/1.8/bundler/gems/mirror-CSV-to-iOS-Localizable.strings-converter-47ade2ded32c/bin/csv2strings:4
from /Users/park/Project/vendor/bundler/ruby/1.8/bin/csv2strings:23:in `load'
from /Users/park/Project/vendor/bundler/ruby/1.8/bin/csv2strings:23
make: *** [translate] Error 1
park$
park$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
https://github.com/robocat/MiawKit style with quick documentation preview including translations.
Suddenly I get the following error message when trying to download from google drive:
Fetching csv file [...] from Google Drive
/Users/[...]/.rvm/gems/ruby-2.1.1/gems/google_drive-0.3.11/lib/google_drive/session.rb:472:in `request': Response code 400 for get https://docs.google.com/feeds/default/private/full?v=3&title=[...]&title-exact=true: <errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>BadRequestException</code><internalReason>The Doclist API has been shut down. Please use the new Drive API, https://developers.google.com/drive/.</internalReason></error></errors> (GoogleDrive::Error)
It makes sense to embed that in fastlane, and a good way that the team as it installed. check https://docs.fastlane.tools/plugins/CreatePlugin/
Apostrophes '
are not escaped with backslash \
.
The official documentation: http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling
use VCR to capture requests
See http://rdoc.info/github/netbe/CSV-to-iOS-Localizable.strings-converter/master/frames
Affected version: 0.2.2.
Solution: Use master branch for now
For some reason Pages and Word exports to CSV with semicolon ";" column separator. On the other hand Google Docs exports with comma "," column separator.
Is it possible to define custom column separator?
Please change line 16 to this:
region = language.region.to_s.empty? ? "" : "-#{language.region}"
filepath = Pathname.new(@file_path) + "values-#{language.code}#{region}" + output_name
'--output-filename' argument of 'babelish csv_download' is treated as 'worksheet_index' for 'GoogleDoc downloader'
Hi @netbe,
Thanks for the nice library!
As a suggestion, could you add a .csv file and/or Google Docs file as example?
It would be nice to have a .csv file as example and how to call it to generate .strings files, for example.
I was wondering how to escape some rows and I couldn't find a way.
Cheers!
after upgrade mac os to el Capitan
-bash: babelish: command not found
install babelish :
sudo gem install babelish
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/babelish
Unfortunately, it seems that csv2android:
which makes it impossible to convert XML to CSV and back again to XML (presumably a common translation workflow).
Original XML with correctly escaped HTML:
<string name="title">Title of <a href="asd">File</a></string>
through android2csv results in:
title,"Title of <a href=""asd"">File</a>"
Converting it back to XML results in:
<string name="title">Title of <a href=\"asd\">File</a></string>
Note the non-escaped < and the backslash escaped href
attribute.
Converting it once again to CSV with android2csv then results in the following error:
[...]/ruby-2.1.2/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:373:in `pull_event':
missing attribute quote (REXML::ParseException)
Line: 4
Position: 128
Last 80 unconsumed characters:
<a href=\"asd\">File</a></string> </resources>
With the manually fixed quotes the HTML tag gets truncated in the resulting CSV:
title,Title of
I get "Could not download the requested file <file_id>" when firing csv_download command.
I've tried to set gDocs file name as "gd_filename" and also with absolute path but does not work. .babelish.token file has been successfully generated.
Is there something else I should set in config file beside "gd_filename", "output_filename" and "sheet" ?
Thanks
Similar to the xml error problem I got an error if the file I want to convert doesn't exist.
I got the following error:
$ babelish android2csv --filenames=/tmp/android.xml --csv-filename=/tmp/android_run2.csv --headers=Vars German
/home/neoklosch/ruby-projects/Babelish/lib/babelish/android2csv.rb:11:in `load_strings': No such file or directory (Errno::ENOENT)
from /home/neoklosch/ruby-projects/Babelish/lib/babelish/base2csv.rb:31:in `block in convert'
from /home/neoklosch/ruby-projects/Babelish/lib/babelish/base2csv.rb:29:in `each'
from /home/neoklosch/ruby-projects/Babelish/lib/babelish/base2csv.rb:29:in `convert'
from /home/neoklosch/ruby-projects/Babelish/lib/babelish/commandline.rb:165:in `base2csv'
from /home/neoklosch/ruby-projects/Babelish/lib/babelish/commandline.rb:56:in `block (2 levels) in <class:Commandline>'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /home/neoklosch/ruby-projects/Babelish/bin/babelish:6:in `<top (required)>'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/bin/babelish:23:in `load'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/bin/babelish:23:in `<main>'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
from /home/neoklosch/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
A propper error handling would be helpful.
Right now the name is csv2strings which would not make sense anymore with the Android, PHP and JSON support coming up.
First: This tool is great. I hate strings files and handling localization on iOS, it's absurdly bad, but this is making it a bit better.
I have English and Japanese strings files. My English file contains my (the developer) comments. The Japanese file contains some comments added by the translator, or at least the person responsible for sorting out the translation.
When I run:
babelish strings2csv
It extracts the comments only from the second file. If anything I'd prefer it to extract the comments from the first file, ideally though it would get both and put them in different columns.
Is there any way to specify which comments to use or use both?
Hi, i am trying to get a header with all the macros for localization in our project.
babelish strings2csv -i Localizable.strings
babelish csv2strings -i translations.csv -L English:en
however i am getting the following errorbabelish csv2strings -i translations.csv -L English:en
/usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/lib/babelish/csv2base.rb:139:in `block (2 levels) in convert': undefined method `add_content_pair' for nil:NilClass (NoMethodError)
from /usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/lib/babelish/csv2base.rb:113:in `times'
from /usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/lib/babelish/csv2base.rb:113:in `block in convert'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/csv.rb:1739:in `each'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/csv.rb:1122:in `block in foreach'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/csv.rb:1273:in `open'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/csv.rb:1121:in `foreach'
from /usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/lib/babelish/csv2base.rb:102:in `convert'
from /usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/lib/babelish/commandline.rb:153:in `block in csv2base'
from /usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/lib/babelish/commandline.rb:145:in `each'
from /usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/lib/babelish/commandline.rb:145:in `each_with_index'
from /usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/lib/babelish/commandline.rb:145:in `csv2base'
from /usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/lib/babelish/commandline.rb:37:in `block (2 levels) in <class:Commandline>'
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /usr/local/lib/ruby/gems/2.2.0/gems/babelish-0.5.0/bin/babelish:6:in `<top (required)>'
from /usr/local/bin/babelish:23:in `load'
from /usr/local/bin/babelish:23:in `<main>'
Installing the gem on OS X 10.9:
sudo gem install csv2strings
ends with:
Successfully installed csv2strings-0.2.2
ERROR: While executing gem ... (TypeError)
no implicit conversion of Array into String
and running csv2strings
throws:
/Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.2/lib/csvconverter/commands/csv2strings_command.rb:39:in `csv2strings': uninitialized constant CSV2StringsCommand::CSV2Strings (NameError) from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:27:in `run' from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command' from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch' from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:439:in `start' from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.2/bin/csv2strings:5:in `' from /usr/bin/csv2strings:23:in `load' from /usr/bin/csv2strings:23:in `'
Usual format of google spreadsheet:
keys, english, german, state_column, comments
csv2strings
NSLocalizedStringFromTable(@"#{key}",@"#{table}",@"{comment}")
strings2csv
When I run sudo babelish csv2strings -i "iOS_Translations" --fetch --verbose
I get a 400 error from Google.
Fetching csv file iOS_Translations from Google Drive
/Library/Ruby/Gems/2.0.0/gems/google_drive-0.3.11/lib/google_drive/session.rb:472:in `request': Response code 400 for get https://docs.google.com/spreadsheets/d/14njfggrCyBliasdfg0yzf81tC7JWghf0QwH3dfg5fISM/export?usp=docslist_api&gid=0&format=csv: <!DOCTYPE html> [html message] </html>
from /Library/Ruby/Gems/2.0.0/gems/google_drive-0.3.11/lib/google_drive/spreadsheet.rb:150:in `export_as_string'
from /Library/Ruby/Gems/2.0.0/gems/google_drive-0.3.11/lib/google_drive/spreadsheet.rb:173:in `block in export_as_file'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:36:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:36:in `open'
from /Library/Ruby/Gems/2.0.0/gems/google_drive-0.3.11/lib/google_drive/spreadsheet.rb:172:in `export_as_file'
from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:29:in `download_spreadsheet'
from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:20:in `block in download'
from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:19:in `each'
from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:19:in `each_with_index'
from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/google_doc.rb:19:in `download'
from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/commandline.rb:100:in `download'
from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/commandline.rb:116:in `csv2base'
from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/lib/babelish/commandline.rb:34:in `block (2 levels) in <class:Commandline>'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /Library/Ruby/Gems/2.0.0/gems/babelish-0.3.3/bin/babelish:6:in `<top (required)>'
from /usr/bin/babelish:23:in `load'
from /usr/bin/babelish:23:in `<main>'
The funny thing is, when I change the filename to a not existing file like, "iOS_Translations X" the output is Fetching csv file iOS_Translations X from Google Drive Could not download the requested file: iOS_Translations X
So it looks like I set up the token thing correctly.
When having a Localizable.strings file which does not have whitespace binding name and definition, fails to parse. E.g. "name"= "definition"; fails to parse, while "name" = "definition"; succeeds.
HTML tags seem to get removed when converting to csv.
E.g.:
Android XML:
<string name="title">Title of <b>this</b> file</string>
Through android2csv becomes:
title,"[""Title of "", "" file""]"
missing
<b>this</b>
and generating what seems to be an array with too many quotes.
If the translation consists of only an html tag, the whole tag gets removed and replaced with empty quotes.
As far as I know html tags are allowed in Android's localization XML files.
/Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:41:in strip!': invalid byte sequence in UTF-8 (ArgumentError) from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:41:in
parse_dotstrings_line'
from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:33:in block (2 levels) in load_strings' from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:32:in
each_line'
from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:32:in block in load_strings' from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:31:in
open'
from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:31:in load_strings' from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:59:in
block in dotstrings_to_csv'
from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:57:in each' from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/strings2csv.rb:57:in
dotstrings_to_csv'
from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/lib/csvconverter/commands/strings2csv_command.rb:19:in strings2csv' from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:27:in
run'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in invoke_command' from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor.rb:363:in
dispatch'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:439:in start' from /Library/Ruby/Gems/2.0.0/gems/csv2strings-0.2.3/bin/strings2csv:6:in
<top (required)>'
from /usr/bin/strings2csv:23:in load' from /usr/bin/strings2csv:23:in
Because of the differences handling localisation files between platforms (iOS, Android) I've duplicated keys in csv file for some translations (handling translations with parameters) and than added excluded_states property to config file (iOS, Android) to exclude the ones that does not go with selected plaftform.
e.g.:
translationKey;number %d;iOS;
translationKey;number %1$d;Android;
Config in iOS project defines excluded_states: ["Android"]
.
Config in Android project defines excluded_states: ["iOS"]
.
Script always takes the last key (in above case for android) ingoring excluded_states. Is there a workaround?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.