ad_localize 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ae0a65677bc70e3175aae752514334aac36642bfb2a2dc2ce8e750f70bbf1d2
4
- data.tar.gz: 30fb7aa05e9b7b6d27f608ec8d9c712f71be21be91560f082cb13f935167e258
3
+ metadata.gz: 6f445861f1e816fc7c19b5f5f609e5bda1d8451036d3f9be1bc5b55e203f8c5f
4
+ data.tar.gz: a3929195545e16d10d6140b11afe1a12d51006e20bf0ec93f0900b367bba82cd
5
5
  SHA512:
6
- metadata.gz: f9e675d6438e1883632aa685e74166021fbe71e75ae1de4b4fda6d93b5c3705b177e0b19dc7399737261d97499c6521c5f746228e021df5401f97ef3fa57ccd6
7
- data.tar.gz: 86b8d0efe4d91fe6eebb6849a76e1bb090c797de13ce3d430fb8a49efa7c93986626a1bb31bfccc639b19006ab7f6edae8c60e339f36b3aeb5d8734fc3e5b024
6
+ metadata.gz: dacb1931f9870fd035584209161f3d7c014795ba189030eee0202bd9ccdce9a9d0a3661e090dbd0f43ab808330b60817fc1371562fa2ff197ceafbb1f8b9ad99
7
+ data.tar.gz: '088585ccd1b256228c3f4652c85cb9d351630a8595c72e9f723203ae1653031e0f5ee922778ce5b29167c3e86ccfc9c43f213f9732eea02d3427533804c66f33'
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ ad_localize/.bundle/
2
+ ad_localize/.yardoc
3
+ ad_localize/_yardoc/
4
+ ad_localize/coverage/
5
+ ad_localize/doc/
6
+ ad_localize/pkg/
7
+ ad_localize/spec/reports/
8
+ ad_localize/tmp/
9
+ .idea
10
+ .byebug_history
11
+ .ruby-version
12
+
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [3.0.0] - 2019-02-19
8
+ TODO
9
+
10
+ ## [2.1.0] - 2016-12-22
11
+ TODO
12
+
13
+ ## [2.0.0] - 2016-07-05
14
+ TODO
15
+
16
+ ## [1.1.0] - 2016-04-27
17
+ TODO
18
+
19
+ ## [1.0.0] - 2016-04-25
20
+ TODO
21
+
22
+ ## [0.1.0] - 2016-04-25
23
+ TODO
24
+
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at joanna.vigne@fabernovel.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ad_localize.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ad_localize (3.0.0)
5
+ activesupport (~> 4.2, >= 4.2.10)
6
+ colorize (~> 0.8)
7
+ nokogiri (~> 1.8, >= 1.8.2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (4.2.11)
13
+ i18n (~> 0.7)
14
+ minitest (~> 5.1)
15
+ thread_safe (~> 0.3, >= 0.3.4)
16
+ tzinfo (~> 1.1)
17
+ ansi (1.5.0)
18
+ builder (3.2.3)
19
+ byebug (11.0.0)
20
+ colorize (0.8.1)
21
+ concurrent-ruby (1.1.4)
22
+ i18n (0.9.5)
23
+ concurrent-ruby (~> 1.0)
24
+ mini_portile2 (2.4.0)
25
+ minitest (5.11.3)
26
+ minitest-reporters (1.3.6)
27
+ ansi
28
+ builder
29
+ minitest (>= 5.0)
30
+ ruby-progressbar
31
+ nokogiri (1.10.1)
32
+ mini_portile2 (~> 2.4.0)
33
+ rake (12.3.2)
34
+ ruby-progressbar (1.10.0)
35
+ thread_safe (0.3.6)
36
+ tzinfo (1.2.5)
37
+ thread_safe (~> 0.1)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ ad_localize!
44
+ bundler (~> 2.0)
45
+ byebug (~> 11.0)
46
+ minitest (~> 5.11)
47
+ minitest-reporters (~> 1.3)
48
+ rake (~> 12.3)
49
+
50
+ BUNDLED WITH
51
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Joanna Vigné
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # AdLocalize
2
+
3
+ The purpose of this gem is to automatically generate wording files from a csv input (local file or google spreadsheet). It is a useful tool when working on a mobile application or a SPA.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ad_localize'
11
+ ```
12
+
13
+ And then execute:
14
+ ```
15
+ $ bundle install
16
+ ```
17
+
18
+ Or install it yourself as:
19
+ ```
20
+ $ gem install ad_localize
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Command Line
26
+
27
+ * Display help
28
+ ```
29
+ $ bundle exec ad_localize -h
30
+ ```
31
+
32
+ * Export wording from a google drive spreadsheet, using the file key
33
+ ```
34
+ $ bundle exec ad_localize -k <your-spreadsheet-drive-key>
35
+ ```
36
+ * Export wording from a google drive spreadsheet, using the file key and specifying a sheet (useful when your file has multiple sheets)
37
+ ```
38
+ $ bundle exec ad_localize -k <your-spreadsheet-drive-key> -s <your-specific-sheet-id>
39
+ ```
40
+
41
+ * Only generate wording files for the specified platforms
42
+ ```
43
+ $ bundle exec ad_localize -o ios
44
+ ```
45
+
46
+ * Choose the path of the output directory
47
+ ```
48
+ $ bundle exec ad_localize -t <path-to-the-output-directory>
49
+ ```
50
+
51
+ * Run in debug mode. In this mode, logs are more verbose and missing values are replaced with "<Missing Translation>"
52
+ ```
53
+ $ bundle exec ad_localize -d
54
+ ```
55
+
56
+ ### CSV file
57
+ #### General syntax rules
58
+
59
+ | key | fr | en |
60
+ | --- | --- | --- |
61
+ | agenda | agenda | events |
62
+ | favorites | Mes favoris | My favorites |
63
+ | from_to | du %1$@ au %2$@ | from %1$@ to %2$@ |
64
+
65
+ - Any column after the `key` column will be considered as a locale column (except from the optional `comment columns)
66
+ - Keys should be written in Android format : [a-z0-9_]+
67
+ - Format specifiers must be numeroted if there are more than one in a translation string (eg: "%1$@ %2$@'s report").
68
+
69
+ #### Comment columns
70
+
71
+ In iOS (and only iOS) you can add a comment to a missing translation.
72
+
73
+ | key | fr | comment fr | en | comment en |
74
+ | --- | --- | --- | --- | --- |
75
+ | player_time_live | Live | bypass-unused-error | Live | bypass-unused-error |
76
+ | seconds | secondes | | seconds | bypass-untranslated-error |
77
+
78
+ The comment will be written in the output files such as below:
79
+
80
+ ```
81
+ "player_time_live" = "Live"; // bypass-unused-error
82
+ "seconds" = "seconds"; // bypass-untranslated-error
83
+ ```
84
+
85
+ ## Output
86
+
87
+ The output folder name is `exports` and it contains a folder for each platform and each locale. In the best case, you just have to replace your existing files with the new ones.
88
+
89
+ Eg:
90
+ ```
91
+ exports/
92
+ ├── android
93
+ │   ├── values
94
+ │   │   └── strings.xml
95
+ │   └── values-en
96
+ │   └── strings.xml
97
+ ├── ios
98
+ │   ├── en.lproj
99
+ │   │   ├── Localizable.strings
100
+ │   │   └── Localizable.stringsdict
101
+ │   └── fr.lproj
102
+ │   ├── Localizable.strings
103
+ │   └── Localizable.stringsdict
104
+ ├── json
105
+ │   ├── en.json
106
+ │   └── fr.json
107
+ └── yml
108
+ ├── en.yml
109
+ └── fr.yml
110
+ ```
111
+
112
+ ## Plurals
113
+
114
+ Plurals are supported for iOS and Android.
115
+
116
+ Syntax for plural keys in the CSV file:
117
+
118
+ key##{few}
119
+ key##{one}
120
+ key##{other}
121
+
122
+
123
+ Sample of Android output in strings.xml
124
+
125
+ ```xml
126
+ <resources>
127
+ <plurals name="cake">
128
+ <item quantity=["zero"|"one"]>gateau</item>
129
+ <item quantity="other">gateaux</item>
130
+ </plural>
131
+ </resources>
132
+ ```
133
+
134
+ Sample of iOS output in .stringsdict
135
+
136
+ ```xml
137
+ <?xml version="1.0" encoding="UTF-8"?>
138
+ <plist>
139
+ <dict>
140
+ <key>traveller_type_child_title</key>
141
+ <dict>
142
+ <key>NSStringLocalizedFormatKey</key>
143
+ <string>%#@key@</string>
144
+ <key>key</key>
145
+ <dict>
146
+ <key>NSStringFormatSpecTypeKey</key>
147
+ <string>NSStringPluralRuleType</string>
148
+ <key>NSStringFormatValueTypeKey</key>
149
+ <string>d</string>
150
+ <key>zero</key>
151
+ <string/>
152
+ <key>one</key>
153
+ <string>1 enfant</string>
154
+ <key>two</key>
155
+ <string/>
156
+ <key>few</key>
157
+ <string/>
158
+ <key>many</key>
159
+ <string/>
160
+ <key>other</key>
161
+ <string>%d enfants</string>
162
+ </dict>
163
+ </dict>
164
+ </dict>
165
+ </plist>
166
+ ```
167
+
168
+ ## Development
169
+
170
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
171
+
172
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
173
+
174
+ ## Contributing
175
+
176
+ Bug reports and pull requests are welcome on GitHub at https://github.com/applidium/ad_localize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
177
+
178
+ ## License
179
+
180
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
181
+
182
+ ## Code of Conduct
183
+
184
+ Everyone interacting in the AdLocalize project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ad_localize/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,51 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ad_localize/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ad_localize'
8
+ spec.version = AdLocalize::VERSION
9
+ spec.license = 'MIT'
10
+ spec.date = '2018-04-18'
11
+ spec.authors = [
12
+ 'Edouard Siegel',
13
+ 'Patrick Nollet',
14
+ 'Adrien Couque',
15
+ 'Tarek Belkahia',
16
+ 'Hugo Hache',
17
+ 'Vincent Brison',
18
+ 'Joanna Vigné',
19
+ 'Nicolas Braun',
20
+ 'Corentin Huard',
21
+ 'Claire Peyron',
22
+ 'Claire Dufetrelle'
23
+ ]
24
+ spec.email = %w(joanna.vigne@fabernovel.com hugo.hache@fabernovel.com edouard.siegel@fabernovel.com)
25
+
26
+ spec.summary = %q{AdLocalize helps with mobile and web applications wording}
27
+ spec.description = %q{AdLocalize produces localization files from platform agnostic wording.
28
+ Supported wording format : CSV. Supported export format: iOS, Android, JSON and YAML}
29
+ spec.homepage = 'https://technologies.fabernovel.com'
30
+
31
+ # Specify which files should be added to the gem when it is released.
32
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
33
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
34
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
35
+ end
36
+ spec.bindir = "exe"
37
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
+ spec.require_paths = ['lib']
39
+
40
+ spec.add_development_dependency 'bundler', '~> 2.0'
41
+ spec.add_development_dependency 'rake', '~> 12.3'
42
+ spec.add_development_dependency 'minitest', '~> 5.11'
43
+ spec.add_development_dependency 'byebug', '~> 11.0'
44
+ spec.add_development_dependency 'minitest-reporters', '~> 1.3'
45
+
46
+ spec.add_dependency 'activesupport', '~> 4.2' ,'>= 4.2.10' # Fastlane does not support activesupport 5
47
+ spec.add_dependency 'nokogiri', '~> 1.8', '>= 1.8.2'
48
+ spec.add_dependency 'colorize', '~> 0.8'
49
+
50
+ spec.required_ruby_version = '~> 2.3'
51
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ad_localize"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ if [ "$#" -ne 2 ] || ! [ -d "$1" ] || ! [ -e "$2" ]; then
3
+ echo "Usage: $0 PROJECT_DIRECTORY LOCALIZABLE_PATH" >&2
4
+ exit 1
5
+ fi
6
+
7
+ diff <((grep -roh '".*"\.localized' $2 | sed 's/\.localized//'; grep -Eroh 'LocalizedString\(@".*?"' $1 | sed 's/LocalizedString(@//') | sort -u) <(grep -roh '".*" =' $2 | sed 's/ =//' | sort -u)
@@ -1,3 +1,3 @@
1
1
  #! /usr/bin/env ruby
2
2
  require 'ad_localize'
3
- AdLocalize.run
3
+ AdLocalize::Runner.new.run(ARGV)
@@ -8,13 +8,13 @@ module AdLocalize
8
8
  end
9
9
 
10
10
  # Returns the downloaded file name (it is located in the current directory)
11
- def download_from_drive(key)
11
+ def download_from_drive(key, sheet)
12
12
  LOGGER.log(:info, :black, "Downloading file from google drive...")
13
13
  download_string_path = "./#{key}.csv"
14
14
  begin
15
15
  File.open(download_string_path, "wb") do |saved_file|
16
16
  # the following "open" is provided by open-uri
17
- open(drive_download_url(key), "rb") do |read_file|
17
+ open(drive_download_url(key, sheet), "rb") do |read_file|
18
18
  saved_file.write(read_file.read)
19
19
  end
20
20
  File.basename saved_file
@@ -38,8 +38,9 @@ module AdLocalize
38
38
  end
39
39
 
40
40
  private
41
- def drive_download_url(key)
42
- "https://docs.google.com/spreadsheets/d/#{key}/export?format=csv&id=#{key}"
41
+ def drive_download_url(key, sheet)
42
+ query_id = sheet ? "gid=#{sheet}" : "id=#{key}"
43
+ "https://docs.google.com/spreadsheets/d/#{key}/export?format=csv&#{query_id}"
43
44
  end
44
45
  end
45
46
  end
@@ -22,6 +22,9 @@ module AdLocalize
22
22
  is_valid_drive_key = !!(key =~ GOOGLE_DRIVE_DOCUMENT_ID.dig(:regexp)) && (key.size >= GOOGLE_DRIVE_DOCUMENT_ID.dig(:length))
23
23
  args[:drive_key] = is_valid_drive_key ? key : nil
24
24
  end
25
+ opts.on("-s", "--drive-sheet SHEET_ID", String, "Use a specific sheet id for Google Drive spreadsheets with several sheets") do |value|
26
+ args[:sheet_id] = value
27
+ end
25
28
  opts.on("-o", "--only platform1,platform2", Array, "Only generate localisation files for the specified platforms. Supported platforms : #{Constant::SUPPORTED_PLATFORMS.join(', ')}") do |platforms|
26
29
  args[:only] = filter_option_args("-o", platforms) { |platform| !!Constant::SUPPORTED_PLATFORMS.index(platform) }
27
30
  end
@@ -13,7 +13,10 @@ module AdLocalize::Platform
13
13
  xml.resources {
14
14
  data.each do |key, wording|
15
15
  singular_wording = wording.dig(locale, AdLocalize::Constant::SINGULAR_KEY_SYMBOL)
16
- add_singular_wording_to_xml(key, singular_wording, xml) unless singular_wording.blank?
16
+ unless singular_wording.blank?
17
+ comment = wording.dig(locale, AdLocalize::Constant::COMMENT_KEY_SYMBOL)
18
+ add_singular_wording_to_xml(key, singular_wording, xml, comment: comment)
19
+ end
17
20
 
18
21
  plural_wording = wording.dig(locale, AdLocalize::Constant::PLURAL_KEY_SYMBOL)
19
22
  add_plural_wording_to_xml(key, plural_wording, xml) unless plural_wording.blank?
@@ -28,12 +31,10 @@ module AdLocalize::Platform
28
31
  end
29
32
 
30
33
  private
34
+
31
35
  def ios_converter(value)
32
- processedValue = value.gsub(/</, "&lt;")
33
- processedValue = processedValue.gsub(/>/, "&gt;")
34
- processedValue = processedValue.gsub(/(?<!\\)'/, "\\\\'")
35
- processedValue = processedValue.gsub(/(?<!\\)\"/, "\\\"")
36
- processedValue = processedValue.gsub(/&(?!(?:amp|lt|gt|quot|apos);)/, '&amp;')
36
+ processedValue = value.gsub(/(?<!\\)'/, "\\\\'") # match ' unless there is a \ before
37
+ processedValue = processedValue.gsub(/(?<!\\)\"/, "\\\"") # match " unless there is a \ before
37
38
  processedValue = processedValue.gsub(/(%(\d+\$)?@)/, '%\2s') # should match values like %1$s and %s
38
39
  processedValue = processedValue.gsub(/(%((\d+\$)?(\d+)?)i)/, '%\2d') # should match values like %i, %3$i, %01i, %1$02i
39
40
  processedValue = processedValue.gsub(/%(?!((\d+\$)?(s|(\d+)?d)))/, '%%') # negative lookahead: identifies when user really wants to display a %
@@ -41,7 +42,8 @@ module AdLocalize::Platform
41
42
  "\"#{processedValue}\""
42
43
  end
43
44
 
44
- def add_singular_wording_to_xml(key, text, xml)
45
+ def add_singular_wording_to_xml(key, text, xml, comment: nil)
46
+ xml.comment(comment) unless comment.blank?
45
47
  xml.string(name: key) {
46
48
  add_wording_text_to_xml(text, xml)
47
49
  }
@@ -1,3 +1,5 @@
1
+ require 'byebug'
2
+
1
3
  module AdLocalize::Platform
2
4
  class PlatformFormatter
3
5
  PLURAL_KEY_SYMBOL = :plural
@@ -27,7 +29,7 @@ module AdLocalize::Platform
27
29
  hash_acc[locale.to_s][key.to_s] = value
28
30
  end
29
31
  if wording.dig(locale)&.key? :plural
30
- hash_acc[locale.to_s][key.to_s] = {} unless hash_acc[locale.to_s].key? key.to_s
32
+ hash_acc[locale.to_s][key.to_s] = {}
31
33
  wording.dig(locale, :plural).each do |plural_type, plural_text|
32
34
  value = ios_converter(plural_text)
33
35
  hash_acc[locale.to_s][key.to_s][plural_type.to_s] = value
@@ -15,7 +15,7 @@ module AdLocalize
15
15
  file_to_parse = args.first
16
16
  LOGGER.log(:warn, :yellow, "Only one CSV can be treated - the priority goes to #{file_to_parse}") if input_files.length > 1
17
17
  if args.empty?
18
- options[:drive_file] = CsvFileManager.download_from_drive(options.dig(:drive_key))
18
+ options[:drive_file] = CsvFileManager.download_from_drive(options.dig(:drive_key), options.dig(:sheet_id))
19
19
  file_to_parse = options.dig(:drive_file)
20
20
  end
21
21
  CsvFileManager.csv?(file_to_parse) ? export(file_to_parse) : LOGGER.log(:error, :red, "#{file_to_parse} is not a csv")
@@ -42,4 +42,4 @@ module AdLocalize
42
42
  end
43
43
  end
44
44
  end
45
- end
45
+ end
@@ -0,0 +1,3 @@
1
+ module AdLocalize
2
+ VERSION = "3.0.0"
3
+ end
data/lib/ad_localize.rb CHANGED
@@ -1,20 +1,17 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
1
  require 'active_support'
4
2
  require 'active_support/core_ext'
5
- require 'byebug'
6
3
  require 'fileutils'
7
4
  require 'pathname'
8
5
  require 'yaml'
6
+ require 'json'
7
+ require 'csv'
9
8
  require 'logger'
10
9
  require 'colorize'
11
- require 'csv'
12
- require 'active_support'
13
10
  require 'open-uri'
14
11
  require 'optparse'
15
- require 'json'
16
12
  require 'nokogiri'
17
13
 
14
+ require 'ad_localize/version'
18
15
  require 'ad_localize/ad_logger'
19
16
  require 'ad_localize/constant'
20
17
  require 'ad_localize/csv_file_manager'
@@ -28,9 +25,7 @@ require 'ad_localize/platform/json_formatter'
28
25
  require 'ad_localize/platform/yml_formatter'
29
26
 
30
27
  module AdLocalize
31
- LOGGER = AdLogger.new
28
+ class Error < StandardError; end
32
29
 
33
- def self.run
34
- Runner.new.run
35
- end
30
+ LOGGER = AdLogger.new
36
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ad_localize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Siegel
@@ -13,8 +13,10 @@ authors:
13
13
  - Joanna Vigné
14
14
  - Nicolas Braun
15
15
  - Corentin Huard
16
+ - Claire Peyron
17
+ - Claire Dufetrelle
16
18
  autorequire:
17
- bindir: bin
19
+ bindir: exe
18
20
  cert_chain: []
19
21
  date: 2018-04-18 00:00:00.000000000 Z
20
22
  dependencies:
@@ -24,132 +26,127 @@ dependencies:
24
26
  requirements:
25
27
  - - "~>"
26
28
  - !ruby/object:Gem::Version
27
- version: '1.16'
29
+ version: '2.0'
28
30
  type: :development
29
31
  prerelease: false
30
32
  version_requirements: !ruby/object:Gem::Requirement
31
33
  requirements:
32
34
  - - "~>"
33
35
  - !ruby/object:Gem::Version
34
- version: '1.16'
36
+ version: '2.0'
35
37
  - !ruby/object:Gem::Dependency
36
38
  name: rake
37
39
  requirement: !ruby/object:Gem::Requirement
38
40
  requirements:
39
41
  - - "~>"
40
42
  - !ruby/object:Gem::Version
41
- version: '10.0'
43
+ version: '12.3'
42
44
  type: :development
43
45
  prerelease: false
44
46
  version_requirements: !ruby/object:Gem::Requirement
45
47
  requirements:
46
48
  - - "~>"
47
49
  - !ruby/object:Gem::Version
48
- version: '10.0'
50
+ version: '12.3'
49
51
  - !ruby/object:Gem::Dependency
50
52
  name: minitest
51
53
  requirement: !ruby/object:Gem::Requirement
52
54
  requirements:
53
55
  - - "~>"
54
56
  - !ruby/object:Gem::Version
55
- version: '5.0'
57
+ version: '5.11'
56
58
  type: :development
57
59
  prerelease: false
58
60
  version_requirements: !ruby/object:Gem::Requirement
59
61
  requirements:
60
62
  - - "~>"
61
63
  - !ruby/object:Gem::Version
62
- version: '5.0'
64
+ version: '5.11'
63
65
  - !ruby/object:Gem::Dependency
64
66
  name: byebug
65
67
  requirement: !ruby/object:Gem::Requirement
66
68
  requirements:
67
69
  - - "~>"
68
70
  - !ruby/object:Gem::Version
69
- version: '10.0'
71
+ version: '11.0'
70
72
  type: :development
71
73
  prerelease: false
72
74
  version_requirements: !ruby/object:Gem::Requirement
73
75
  requirements:
74
76
  - - "~>"
75
77
  - !ruby/object:Gem::Version
76
- version: '10.0'
78
+ version: '11.0'
77
79
  - !ruby/object:Gem::Dependency
78
- name: json
80
+ name: minitest-reporters
79
81
  requirement: !ruby/object:Gem::Requirement
80
82
  requirements:
81
83
  - - "~>"
82
84
  - !ruby/object:Gem::Version
83
- version: '1.8'
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: 1.8.3
87
- type: :runtime
85
+ version: '1.3'
86
+ type: :development
88
87
  prerelease: false
89
88
  version_requirements: !ruby/object:Gem::Requirement
90
89
  requirements:
91
90
  - - "~>"
92
91
  - !ruby/object:Gem::Version
93
- version: '1.8'
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 1.8.3
92
+ version: '1.3'
97
93
  - !ruby/object:Gem::Dependency
98
- name: nokogiri
94
+ name: activesupport
99
95
  requirement: !ruby/object:Gem::Requirement
100
96
  requirements:
101
97
  - - "~>"
102
98
  - !ruby/object:Gem::Version
103
- version: '1.8'
99
+ version: '4.2'
104
100
  - - ">="
105
101
  - !ruby/object:Gem::Version
106
- version: 1.8.2
102
+ version: 4.2.10
107
103
  type: :runtime
108
104
  prerelease: false
109
105
  version_requirements: !ruby/object:Gem::Requirement
110
106
  requirements:
111
107
  - - "~>"
112
108
  - !ruby/object:Gem::Version
113
- version: '1.8'
109
+ version: '4.2'
114
110
  - - ">="
115
111
  - !ruby/object:Gem::Version
116
- version: 1.8.2
112
+ version: 4.2.10
117
113
  - !ruby/object:Gem::Dependency
118
- name: activesupport
114
+ name: nokogiri
119
115
  requirement: !ruby/object:Gem::Requirement
120
116
  requirements:
121
117
  - - "~>"
122
118
  - !ruby/object:Gem::Version
123
- version: '5.1'
119
+ version: '1.8'
124
120
  - - ">="
125
121
  - !ruby/object:Gem::Version
126
- version: 5.1.5
122
+ version: 1.8.2
127
123
  type: :runtime
128
124
  prerelease: false
129
125
  version_requirements: !ruby/object:Gem::Requirement
130
126
  requirements:
131
127
  - - "~>"
132
128
  - !ruby/object:Gem::Version
133
- version: '5.1'
129
+ version: '1.8'
134
130
  - - ">="
135
131
  - !ruby/object:Gem::Version
136
- version: 5.1.5
132
+ version: 1.8.2
137
133
  - !ruby/object:Gem::Dependency
138
134
  name: colorize
139
135
  requirement: !ruby/object:Gem::Requirement
140
136
  requirements:
141
137
  - - "~>"
142
138
  - !ruby/object:Gem::Version
143
- version: 0.8.1
139
+ version: '0.8'
144
140
  type: :runtime
145
141
  prerelease: false
146
142
  version_requirements: !ruby/object:Gem::Requirement
147
143
  requirements:
148
144
  - - "~>"
149
145
  - !ruby/object:Gem::Version
150
- version: 0.8.1
151
- description: " Convert a wording file in localization files. Supported export formats
152
- are : iOS, Android,\n JSON and YAML "
146
+ version: '0.8'
147
+ description: |-
148
+ AdLocalize produces localization files from platform agnostic wording.
149
+ Supported wording format : CSV. Supported export format: iOS, Android, JSON and YAML
153
150
  email:
154
151
  - joanna.vigne@fabernovel.com
155
152
  - hugo.hache@fabernovel.com
@@ -159,7 +156,20 @@ executables:
159
156
  extensions: []
160
157
  extra_rdoc_files: []
161
158
  files:
162
- - bin/ad_localize
159
+ - ".gitignore"
160
+ - ".travis.yml"
161
+ - CHANGELOG.md
162
+ - CODE_OF_CONDUCT.md
163
+ - Gemfile
164
+ - Gemfile.lock
165
+ - LICENSE.txt
166
+ - README.md
167
+ - Rakefile
168
+ - ad_localize.gemspec
169
+ - bin/console
170
+ - bin/setup
171
+ - diff_project_vs_localizable_keys.sh
172
+ - exe/ad_localize
163
173
  - lib/ad_localize.rb
164
174
  - lib/ad_localize/ad_logger.rb
165
175
  - lib/ad_localize/constant.rb
@@ -172,6 +182,7 @@ files:
172
182
  - lib/ad_localize/platform/platform_formatter.rb
173
183
  - lib/ad_localize/platform/yml_formatter.rb
174
184
  - lib/ad_localize/runner.rb
185
+ - lib/ad_localize/version.rb
175
186
  homepage: https://technologies.fabernovel.com
176
187
  licenses:
177
188
  - MIT
@@ -182,18 +193,17 @@ require_paths:
182
193
  - lib
183
194
  required_ruby_version: !ruby/object:Gem::Requirement
184
195
  requirements:
185
- - - ">="
196
+ - - "~>"
186
197
  - !ruby/object:Gem::Version
187
- version: '0'
198
+ version: '2.3'
188
199
  required_rubygems_version: !ruby/object:Gem::Requirement
189
200
  requirements:
190
201
  - - ">="
191
202
  - !ruby/object:Gem::Version
192
203
  version: '0'
193
204
  requirements: []
194
- rubyforge_project:
195
- rubygems_version: 2.7.3
205
+ rubygems_version: 3.0.2
196
206
  signing_key:
197
207
  specification_version: 4
198
- summary: AdLocalize
208
+ summary: AdLocalize helps with mobile and web applications wording
199
209
  test_files: []