localio 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -3
- data/lib/localio/localizable_writer.rb +4 -2
- data/lib/localio/templates/resx_localizable.erb +136 -0
- data/lib/localio/version.rb +1 -1
- data/lib/localio/writers/resx_writer.rb +38 -0
- data/localio.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b34d3628cd466fa2c3e779ab9d3cd1e6e38f8d27
|
4
|
+
data.tar.gz: 1c5f6ca2433dd58363b2a95823a9461b5f32638c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07e98e7291d6ac2f4ad1cda97b5ca39be7b154cd0b37418a29dd3926ace3218cf14ecc33b54570f2803a5faaefe0de28b415677f1d4aee9735a49dbc644faf72
|
7
|
+
data.tar.gz: 1b9bbd621abb3b5a2be60e222d8cf1722af14d890fa463f412a0e68d7331529c60be24a2406e8c970dc2bedc916fc30d9c9ccee1d41873ffb1e21aa4b31ccf7a
|
data/README.md
CHANGED
@@ -76,12 +76,13 @@ Option | Description
|
|
76
76
|
* `:rails` for Rails YAML files. The `output_path` needed is your `config/locales` directory.
|
77
77
|
* `:json` for an easy JSON format for localizables. The `output_path` is yours to decide :)
|
78
78
|
* `:java_properties` for .properties files used mainly in Java. Files named language_(lang).properties will be generated in `output_path`'s root directory.
|
79
|
+
* `:resx` for .resx files used by .NET projects, e.g. Windows Forms, Windows Phone or Xamarin.
|
79
80
|
|
80
81
|
#### Extra platform parameters
|
81
82
|
|
82
|
-
##### iOS
|
83
|
+
##### iOS - :ios, :swift
|
83
84
|
|
84
|
-
|
85
|
+
We can opt-out from the constants/macros. We will simple need to add `:create_constants => false`. By default, if omitted, the constants will be always created. It's a good practice to have a compile-time check of the existence of your keys; but if you don't like it it's fine.
|
85
86
|
|
86
87
|
Example:
|
87
88
|
|
@@ -90,6 +91,17 @@ platform :ios, :create_constants => false
|
|
90
91
|
# ... rest of your Locfile ...
|
91
92
|
````
|
92
93
|
|
94
|
+
##### ResX - :resx
|
95
|
+
|
96
|
+
The default resource file name is `Resources.resx`. We can set a different base name using the `:resource_file` option.
|
97
|
+
|
98
|
+
````ruby
|
99
|
+
# Generate WebResources.resx, WebResources.es.resx, etc.
|
100
|
+
platform :resx, :resource_file => "WebResources"
|
101
|
+
|
102
|
+
# ... rest of your Locfile ...
|
103
|
+
````
|
104
|
+
|
93
105
|
#### Supported sources
|
94
106
|
|
95
107
|
##### Google Drive
|
@@ -168,6 +180,7 @@ Platform | "App name" | "ANOTHER_KIND_OF_KEY"
|
|
168
180
|
`:smart` (android) | `app_name` | `another_kind_of_key`
|
169
181
|
`:smart` (ruby) | `app_name` | `another_kind_of_key`
|
170
182
|
`:smart` (json) | `app_name` | `another_kind_of_key`
|
183
|
+
`:smart` (resx) | `AppName` | `AnotherKindOfKey`
|
171
184
|
|
172
185
|
Example of use:
|
173
186
|
|
@@ -197,7 +210,7 @@ only :keys => '[\[][a][\]]'
|
|
197
210
|
|
198
211
|
#### Overriding default language
|
199
212
|
|
200
|
-
This only makes sense with `platform :android` at the moment. If we want to override (for whatever reason) the default language flag in the source spreadsheet, we can use `:override_default => 'language'`.
|
213
|
+
This only makes sense with `platform :android` and `platform :resx` at the moment. If we want to override (for whatever reason) the default language flag in the source spreadsheet, we can use `:override_default => 'language'`.
|
201
214
|
|
202
215
|
For example, if we wanted to override the default (english) and use spanish instead, we could do this:
|
203
216
|
|
@@ -4,7 +4,7 @@ require 'localio/writers/swift_writer'
|
|
4
4
|
require 'localio/writers/json_writer'
|
5
5
|
require 'localio/writers/rails_writer'
|
6
6
|
require 'localio/writers/java_properties_writer'
|
7
|
-
|
7
|
+
require 'localio/writers/resx_writer'
|
8
8
|
|
9
9
|
module LocalizableWriter
|
10
10
|
def self.write(platform, languages, terms, path, formatter, options)
|
@@ -21,8 +21,10 @@ module LocalizableWriter
|
|
21
21
|
RailsWriter.write languages, terms, path, formatter, options
|
22
22
|
when :java_properties
|
23
23
|
JavaPropertiesWriter.write languages, terms, path, formatter, options
|
24
|
+
when :resx
|
25
|
+
ResXWriter.write languages, terms, path, formatter, options
|
24
26
|
else
|
25
|
-
raise ArgumentError, 'Platform not supported! Current possibilities are :android, :ios, :json, :rails, :java_properties'
|
27
|
+
raise ArgumentError, 'Platform not supported! Current possibilities are :android, :ios, :json, :rails, :java_properties, :resx'
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<root>
|
3
|
+
<!--
|
4
|
+
Microsoft ResX Schema
|
5
|
+
|
6
|
+
Version 2.0
|
7
|
+
|
8
|
+
The primary goals of this format is to allow a simple XML format
|
9
|
+
that is mostly human readable. The generation and parsing of the
|
10
|
+
various data types are done through the TypeConverter classes
|
11
|
+
associated with the data types.
|
12
|
+
|
13
|
+
Example:
|
14
|
+
|
15
|
+
... ado.net/XML headers & schema ...
|
16
|
+
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
17
|
+
<resheader name="version">2.0</resheader>
|
18
|
+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
19
|
+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
20
|
+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
21
|
+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
22
|
+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
23
|
+
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
24
|
+
</data>
|
25
|
+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
26
|
+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
27
|
+
<comment>This is a comment</comment>
|
28
|
+
</data>
|
29
|
+
|
30
|
+
There are any number of "resheader" rows that contain simple
|
31
|
+
name/value pairs.
|
32
|
+
|
33
|
+
Each data row contains a name, and value. The row also contains a
|
34
|
+
type or mimetype. Type corresponds to a .NET class that support
|
35
|
+
text/value conversion through the TypeConverter architecture.
|
36
|
+
Classes that don't support this are serialized and stored with the
|
37
|
+
mimetype set.
|
38
|
+
|
39
|
+
The mimetype is used for serialized objects, and tells the
|
40
|
+
ResXResourceReader how to depersist the object. This is currently not
|
41
|
+
extensible. For a given mimetype the value must be set accordingly:
|
42
|
+
|
43
|
+
Note - application/x-microsoft.net.object.binary.base64 is the format
|
44
|
+
that the ResXResourceWriter will generate, however the reader can
|
45
|
+
read any of the formats listed below.
|
46
|
+
|
47
|
+
mimetype: application/x-microsoft.net.object.binary.base64
|
48
|
+
value : The object must be serialized with
|
49
|
+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
50
|
+
: and then encoded with base64 encoding.
|
51
|
+
|
52
|
+
mimetype: application/x-microsoft.net.object.soap.base64
|
53
|
+
value : The object must be serialized with
|
54
|
+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
55
|
+
: and then encoded with base64 encoding.
|
56
|
+
|
57
|
+
mimetype: application/x-microsoft.net.object.bytearray.base64
|
58
|
+
value : The object must be serialized into a byte array
|
59
|
+
: using a System.ComponentModel.TypeConverter
|
60
|
+
: and then encoded with base64 encoding.
|
61
|
+
-->
|
62
|
+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
63
|
+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
64
|
+
<xsd:element name="root" msdata:IsDataSet="true">
|
65
|
+
<xsd:complexType>
|
66
|
+
<xsd:choice maxOccurs="unbounded">
|
67
|
+
<xsd:element name="metadata">
|
68
|
+
<xsd:complexType>
|
69
|
+
<xsd:sequence>
|
70
|
+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
71
|
+
</xsd:sequence>
|
72
|
+
<xsd:attribute name="name" use="required" type="xsd:string" />
|
73
|
+
<xsd:attribute name="type" type="xsd:string" />
|
74
|
+
<xsd:attribute name="mimetype" type="xsd:string" />
|
75
|
+
<xsd:attribute ref="xml:space" />
|
76
|
+
</xsd:complexType>
|
77
|
+
</xsd:element>
|
78
|
+
<xsd:element name="assembly">
|
79
|
+
<xsd:complexType>
|
80
|
+
<xsd:attribute name="alias" type="xsd:string" />
|
81
|
+
<xsd:attribute name="name" type="xsd:string" />
|
82
|
+
</xsd:complexType>
|
83
|
+
</xsd:element>
|
84
|
+
<xsd:element name="data">
|
85
|
+
<xsd:complexType>
|
86
|
+
<xsd:sequence>
|
87
|
+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
88
|
+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
89
|
+
</xsd:sequence>
|
90
|
+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
91
|
+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
92
|
+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
93
|
+
<xsd:attribute ref="xml:space" />
|
94
|
+
</xsd:complexType>
|
95
|
+
</xsd:element>
|
96
|
+
<xsd:element name="resheader">
|
97
|
+
<xsd:complexType>
|
98
|
+
<xsd:sequence>
|
99
|
+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
100
|
+
</xsd:sequence>
|
101
|
+
<xsd:attribute name="name" type="xsd:string" use="required" />
|
102
|
+
</xsd:complexType>
|
103
|
+
</xsd:element>
|
104
|
+
</xsd:choice>
|
105
|
+
</xsd:complexType>
|
106
|
+
</xsd:element>
|
107
|
+
</xsd:schema>
|
108
|
+
<resheader name="resmimetype">
|
109
|
+
<value>text/microsoft-resx</value>
|
110
|
+
</resheader>
|
111
|
+
<resheader name="version">
|
112
|
+
<value>2.0</value>
|
113
|
+
</resheader>
|
114
|
+
<resheader name="reader">
|
115
|
+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
116
|
+
</resheader>
|
117
|
+
<resheader name="writer">
|
118
|
+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
119
|
+
</resheader>
|
120
|
+
<data name="ResourceLanguage" xml:space="preserve">
|
121
|
+
<value><%= @language %></value>
|
122
|
+
<comment>Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.</comment>
|
123
|
+
</data>
|
124
|
+
<%
|
125
|
+
@segments.each do |term|
|
126
|
+
if term.is_comment? %>
|
127
|
+
<!-- <%= term.translation %> -->
|
128
|
+
<% else %> <data name="<%= term.key %>" xml:space="preserve">
|
129
|
+
<value><![CDATA[<%= term.translation %>]]></value>
|
130
|
+
<comment/>
|
131
|
+
</data>
|
132
|
+
<% end
|
133
|
+
end
|
134
|
+
%>
|
135
|
+
|
136
|
+
</root>
|
data/lib/localio/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'localio/template_handler'
|
2
|
+
require 'localio/segments_list_holder'
|
3
|
+
require 'localio/segment'
|
4
|
+
require 'localio/formatter'
|
5
|
+
|
6
|
+
class ResXWriter
|
7
|
+
def self.write(languages, terms, path, formatter, options)
|
8
|
+
puts 'Writing .NET ResX translations...'
|
9
|
+
default_language = options[:default_language]
|
10
|
+
resource_file = options[:resource_file].nil? ? "Resources" : options[:resource_file]
|
11
|
+
|
12
|
+
languages.keys.each do |lang|
|
13
|
+
file_name = "#{resource_file}.#{lang}.resx"
|
14
|
+
file_name = "#{resource_file}.resx" if default_language == lang
|
15
|
+
|
16
|
+
# We have now to iterate all the terms for the current language, extract them, and store them into a new array
|
17
|
+
|
18
|
+
segments = SegmentsListHolder.new lang
|
19
|
+
terms.each do |term|
|
20
|
+
key = Formatter.format(term.keyword, formatter, method(:resx_key_formatter))
|
21
|
+
translation = term.values[lang]
|
22
|
+
segment = Segment.new(key, translation, lang)
|
23
|
+
segment.key = nil if term.is_comment?
|
24
|
+
segments.segments << segment
|
25
|
+
end
|
26
|
+
|
27
|
+
TemplateHandler.process_template 'resx_localizable.erb', path, file_name, segments
|
28
|
+
puts " > #{lang.yellow}"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def self.resx_key_formatter(key)
|
36
|
+
key.space_to_underscore.strip_tag.camel_case.gsub("_", "").capitalize
|
37
|
+
end
|
38
|
+
end
|
data/localio.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Localio::VERSION
|
9
9
|
spec.authors = ["Nacho Lopez"]
|
10
10
|
spec.email = ["nacho@nlopez.io"]
|
11
|
-
spec.description = %q{Automatic Localizable file generation for multiple platforms (Rails YAML, Android, Java Properties, iOS, JSON)}
|
11
|
+
spec.description = %q{Automatic Localizable file generation for multiple platforms (Rails YAML, Android, Java Properties, iOS, JSON, .NET ResX)}
|
12
12
|
spec.summary = %q{Automatic Localizable file generation for multiple type of files, like Android string.xml, Xcode Localizable.strings, JSON files, Rails YAML files, Java properties, etc. reading from Google Drive and Excel spreadsheets as base.}
|
13
13
|
spec.homepage = "http://github.com/mrmans0n/localio"
|
14
14
|
spec.license = "MIT"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nacho Lopez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '1.6'
|
125
125
|
description: Automatic Localizable file generation for multiple platforms (Rails YAML,
|
126
|
-
Android, Java Properties, iOS, JSON)
|
126
|
+
Android, Java Properties, iOS, JSON, .NET ResX)
|
127
127
|
email:
|
128
128
|
- nacho@nlopez.io
|
129
129
|
executables:
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/localio/templates/java_properties_localizable.erb
|
159
159
|
- lib/localio/templates/json_localizable.erb
|
160
160
|
- lib/localio/templates/rails_localizable.erb
|
161
|
+
- lib/localio/templates/resx_localizable.erb
|
161
162
|
- lib/localio/templates/swift_constant_localizable.erb
|
162
163
|
- lib/localio/term.rb
|
163
164
|
- lib/localio/version.rb
|
@@ -166,6 +167,7 @@ files:
|
|
166
167
|
- lib/localio/writers/java_properties_writer.rb
|
167
168
|
- lib/localio/writers/json_writer.rb
|
168
169
|
- lib/localio/writers/rails_writer.rb
|
170
|
+
- lib/localio/writers/resx_writer.rb
|
169
171
|
- lib/localio/writers/swift_writer.rb
|
170
172
|
- localio.gemspec
|
171
173
|
homepage: http://github.com/mrmans0n/localio
|