Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: fixing android escaping #133

Closed
wants to merge 6 commits into from
Closed

WIP: fixing android escaping #133

wants to merge 6 commits into from

Conversation

falkorichter
Copy link
Contributor

@falkorichter falkorichter commented Jun 23, 2020

should fix #130

  • fix existing tests
  • handle existing escaped charaters
  • handle limited html (<b> for instance)

lib/babelish/csv2android.rb Outdated Show resolved Hide resolved
lib/babelish/csv2android.rb Outdated Show resolved Hide resolved
lib/babelish/csv2android.rb Outdated Show resolved Hide resolved
lib/babelish/csv2android.rb Outdated Show resolved Hide resolved
lib/babelish/csv2android.rb Outdated Show resolved Hide resolved
lib/babelish/csv2android.rb Outdated Show resolved Hide resolved
test/babelish/test_csv2android.rb Show resolved Hide resolved
test/babelish/test_csv2android.rb Outdated Show resolved Hide resolved
test/babelish/test_csv2android.rb Outdated Show resolved Hide resolved
def escape_android_characters(value)
value.gsub!(/'/, "'" => "\\'")
value.gsub!(/&/, "&" => '&amp;')
value.gsub!(/</, "<" => '&lt;')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

lib/babelish/csv2android.rb Show resolved Hide resolved
lib/babelish/csv2android.rb Outdated Show resolved Hide resolved
@falkorichter
Copy link
Contributor Author

works on my machine :(
Screenshot 2020-06-24 at 11 26 09

assert_equal expected_output, output

assert_true FileUtils.identical?("values-en/escaped_strings.xml",
"test/data/test_data_with_characters_that_need_escaping.xml")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [98/80]

assert exist, "the ouptut file does not exist"

output = File.read("values-en/escaped_strings.xml")
expected_output = File.read("test/data/test_data_with_characters_that_need_escaping.xml")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [93/80]

def test_android_character_escaping
converter = Babelish::CSV2Android.new("test/data/test_data_with_characters_that_need_escaping.csv",
{ "English" => "en" },
{ output_basename: "escaped_strings" })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/BracesAroundHashParameters: Redundant curly braces around a hash parameter.
Metrics/LineLength: Line is too long. [81/80]

@@ -69,4 +69,25 @@ def test_converting_with_basename
# clean up
system("rm -rf ./values-en")
end

def test_android_character_escaping
converter = Babelish::CSV2Android.new("test/data/test_data_with_characters_that_need_escaping.csv",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [103/80]

@falkorichter
Copy link
Contributor Author

falkorichter commented Jun 24, 2020

TRAVIS=1
omits the tests that failed before, thanks for the tip!
Screenshot 2020-06-24 at 14 01 06

@falkorichter falkorichter marked this pull request as draft June 24, 2020 13:07
@falkorichter falkorichter changed the title fixing android escaping WIP: fixing android escaping Jun 24, 2020
@falkorichter
Copy link
Contributor Author

There is some problems regarding already escaped charaters from the original data

@ghost ghost closed this by deleting the head repository May 2, 2024
uliluckas added a commit to uliluckas/Babelish that referenced this pull request Aug 28, 2024
Inspired by PR from Falko Richter:
netbe#133
uliluckas added a commit to uliluckas/Babelish that referenced this pull request Aug 28, 2024
Inspired by PR from Falko Richter:
netbe#133
uliluckas added a commit to uliluckas/Babelish that referenced this pull request Aug 28, 2024
Inspired by PR from Falko Richter:
netbe#133
uliluckas added a commit to uliluckas/Babelish that referenced this pull request Aug 28, 2024
Inspired by PR from Falko Richter:
netbe#133
uliluckas added a commit to uliluckas/Babelish that referenced this pull request Aug 28, 2024
Inspired by PR from Falko Richter:
netbe#133
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apostrophe Issue
2 participants