international 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a0eaff45a90e8fea50b473abfbe7fb2aa2d0b59
4
- data.tar.gz: ebf01a993cbebc5c4efebd7b1e3b14b7639de7c2
3
+ metadata.gz: 294fc6b6d766cb05c80fff6507693d2a9031e287
4
+ data.tar.gz: 22399bd6a99f811272d6f1bd281fc91e5e98fae1
5
5
  SHA512:
6
- metadata.gz: c12de318a9269320de25d63562dbaccafa38eb23a5d4ca44e64d0be5e08aef293a75697cfe86155eb79706e5ae6ed4ff5135e27d3090d38c25b421145f8d291c
7
- data.tar.gz: 80f9c7915d35cf5de5f37c24f80ae3387ee081be4989424829115f1aa16a8426392237076f37a83e15d228a50d48bacc1f8af623b3401dea51b32cc02e05d2e6
6
+ metadata.gz: 559538ad04fed14064daeef45e47ad423214cb68538c04b05d499c090f00648a0a4cf3ae6748a66bc5e50a31e7de79b137346da38fa6371c5a8aacd0319f78f2
7
+ data.tar.gz: 5e00abd8fe04daf4d039c893888dffc67aaba41bdfab0acae6abe129e44bf1b44884e9238c6e22545d349e0d5183a659039ba0e24952666f8d2aad5702193df0
data/README.md CHANGED
@@ -15,7 +15,7 @@ This will create the localization for you, based on a `.csv` file
15
15
  international --csv ~/import.csv
16
16
  ```
17
17
  ### Will have this output:
18
- English, `/values-en/translation.xml`:
18
+ For **android** (English, etc.), `/values-en/translation.xml`:
19
19
 
20
20
  ```xml
21
21
  <?xml version="1.0" ?>
@@ -25,16 +25,16 @@ English, `/values-en/translation.xml`:
25
25
  <string name="goodbye_message">goodbye</string>
26
26
  </resources>
27
27
  ```
28
- Portuguese, `/values-pt/translation.xml`:
29
- ```xml
30
- <?xml version="1.0" ?>
31
- <resources>
32
- <string name="welcome_message">Bem vindo</string>
33
- <string name="thank_you_message">Obrigado</string>
34
- <string name="goodbye_message">Adeus</string>
35
- </resources>
28
+
29
+ For **iOS** (English, etc.), `iosApp/en.lbproj/Localizable.strings`:
30
+
31
+ ```bash
32
+ WELCOME_MESSAGE="Welcome";
33
+ THANK_YOU_MESSAGE="Thank you";
34
+ GOODBYE_MESSAGE="Goodbye";
36
35
  ```
37
36
 
37
+
38
38
  Given this `~/import.csv`
39
39
  ```csv
40
40
  keys,pt,en,es
@@ -46,34 +46,11 @@ goodbye,adeus,goodbye,adios
46
46
  <b>You can also send it straight to some folder:</b>
47
47
 
48
48
  ```bash
49
- international --csv ~/import.csv --output app/src/main/res/
50
- ```
51
-
52
-
53
- <!--
54
- .Strings - iOS
55
- en.strings
56
- ```
57
- /* */
58
- "welcome_message" = "hello";
59
-
60
- /* */
61
- "thank_you_message" = "thank you";
62
-
63
- /* */
64
- "goodbye_message" = "goodbye";
65
- ru.strings
66
-
67
- /* */
68
- "welcome_message" = "здравствуйте";
69
-
70
- /* */
71
- "thank_you_message" = "спасибо";
72
-
73
- /* */
74
- "goodbye_message" = "До свидания";
49
+ # For iOS
50
+ international --csv ~/import.csv --platform ios --output iosApp/
51
+ # For Android
52
+ international --csv ~/import.csv --platform android --output app/src/main/res/
75
53
  ```
76
- -->
77
54
 
78
55
 
79
56
  ## Full usage
@@ -84,6 +61,7 @@ Usage: international [OPTIONS]
84
61
  Options
85
62
  -c, --csv PATH_TO_CSV # Path to the .csv file
86
63
  -o, --output PATH_TO_OUTPUT # Path to the desired output folder
64
+ -p, --platform PLATFORM # Choose between "android" and "ios" (default: "android")
87
65
  -d, --dryrun # Only simulates the output and don't write files
88
66
  -h, --help # Displays help
89
67
  -v, --version # Displays version
@@ -3,9 +3,10 @@ require 'erubis'
3
3
  require 'fileutils'
4
4
  require 'colorize'
5
5
 
6
- class AndroidManager
7
- def initialize language, items, output_folder, dryrun=false
8
- @language = language
6
+ class FileManager
7
+ def initialize language, items, output_folder, platform, dryrun=false
8
+ @language = language.downcase
9
+ @platform = platform
9
10
  @dryrun = dryrun
10
11
  @items = items
11
12
  @path = output_folder
@@ -13,16 +14,20 @@ class AndroidManager
13
14
  end
14
15
 
15
16
  def get_template_path
16
- File.join(File.dirname(__FILE__), 'templates/android.erb')
17
+ File.join(File.dirname(__FILE__), "templates/#{@platform}.erb")
17
18
  end
18
19
 
19
20
  def get_file_name
20
- "values-#{@language}/translation.xml"
21
+ if @platform.eql?'android'
22
+ "values-#{@language}/translation.xml"
23
+ else
24
+ "#{@language}.lbproj/Localizable.strings"
25
+ end
21
26
  end
22
27
 
23
28
  def create_file
24
29
  file_name = get_file_name
25
- destination_file_path = "#{@path}#{file_name}"
30
+ destination_file_path = "#{@path}#{file_name}"
26
31
 
27
32
  pretty_print destination_file_path
28
33
 
@@ -1,3 +1,3 @@
1
1
  module International
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
  end
data/lib/international.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'colorize'
2
2
  require 'international/version'
3
3
  require 'csv'
4
- require 'android_manager'
4
+ require 'file_manager'
5
5
 
6
6
  module International
7
7
 
@@ -13,6 +13,7 @@ module International
13
13
  @path_to_output = 'output/'
14
14
  @path_to_csv = nil
15
15
  @dryrun = false
16
+ @platform = 'android'
16
17
 
17
18
  # Parse Options
18
19
  arguments.push "-h" if arguments.length == 0
@@ -22,6 +23,10 @@ module International
22
23
 
23
24
  end
24
25
 
26
+ def is_valid_platform
27
+ @platform.eql?'android' or @platform.eql?'ios'
28
+ end
29
+
25
30
  ### Options parser
26
31
  def create_options_parser(args)
27
32
 
@@ -34,6 +39,10 @@ module International
34
39
  @path_to_csv = csv_path
35
40
  end
36
41
 
42
+ opts.on('-p PLATFORM', '--platform PLATFORM', 'Choose between "android" and "ios" (default: "android")') do |platform|
43
+ @platform = platform.downcase
44
+ end
45
+
37
46
  opts.on('-o PATH_TO_OUTPUT', '--output PATH_TO_OUTPUT', 'Path to the desired output folder') do |path_to_output|
38
47
  unless path_to_output[-1,1] == '/'
39
48
  path_to_output = "#{path_to_output}/"
@@ -69,6 +78,11 @@ module International
69
78
  exit 1
70
79
  end
71
80
 
81
+ unless is_valid_platform
82
+ puts "The platform you chose could not be found, pick 'android' or 'ios'".yellow
83
+ exit 1
84
+ end
85
+
72
86
  hash = csv_to_hash(@path_to_csv)
73
87
  separate_languages hash
74
88
  end
@@ -104,7 +118,7 @@ module International
104
118
  items.push item
105
119
  end
106
120
 
107
- manager = AndroidManager.new lang, items, @path_to_output, @dryrun
121
+ manager = FileManager.new lang, items, @path_to_output, @platform, @dryrun
108
122
  manager.create_file
109
123
  end
110
124
  end
@@ -1,2 +1,2 @@
1
1
  <% for @item in @items %>
2
- "<%= @item[:key] %>"="<%= @item[:translation] %>"<% end %>
2
+ <%= @item[:key].upcase %>="<%= @item[:translation] %>";<% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: international
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cesarferreira
@@ -131,7 +131,7 @@ files:
131
131
  - Rakefile
132
132
  - bin/international
133
133
  - international.gemspec
134
- - lib/android_manager.rb
134
+ - lib/file_manager.rb
135
135
  - lib/international.rb
136
136
  - lib/international/version.rb
137
137
  - lib/templates/android.erb