bisu 2.0.0 → 2.1.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: 668059c0670a554d5a7ab95f88ab90133a0d367eaa7e08bba2c2c5a9d5ed36cb
4
- data.tar.gz: fb276b9ef26e4941fb3264a366fbe9cc8404d0c296441afe5b294df652444e6d
3
+ metadata.gz: a53a95f2c8ca08de5f1b44a56f5648f3b3430d22f191a9a5637f9b6daa37bee9
4
+ data.tar.gz: b51d192672fdf321ba29f2ac1a4fdaf0728a615885f03fad317c566264531053
5
5
  SHA512:
6
- metadata.gz: 2250bd0fd198197e78a399be3c519c97ef0700564932feb4de4821573cf5a886fd056d5992180f9d18691145dbc55a9bbffc4bfc44993d1e9d34643954c2b529
7
- data.tar.gz: 81e01705e4a8a3e4144b2d64f11d6f04c60d0a75fc50d05b1781b43cfb15f87351c3dab66092ae0b51507760046677efee7bc67c2f9cd7087823884a802318aa
6
+ metadata.gz: 50543ddcc08ea0d0c09626e4d7cee4cc1dec6f575f81e229dce5d263c2b460237fafedc6a13256178cc4a87ccf4eedb290edd83cb5b8c7ca672d5ad6aea9f969
7
+ data.tar.gz: d7ecec10c7249f263566589dbb62af318ea9a59adb346265bc9500248c048d00507047ce55eab2e2f3527403910bbd67ed995eb16282fda2b6595ab1fbcbc848
data/CHANGELOG.md CHANGED
@@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## [2.1.0](https://github.com/hole19/bisu/releases/tag/v2.1.0)
7
8
 
9
+ #### Fixed
10
+ - Fixes handling of % character on iOS localization
8
11
 
9
12
  ## [2.0.0](https://github.com/hole19/bisu/releases/tag/v2.0.0)
10
13
  Released on 2023/12/07
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bisu (1.10.2)
4
+ bisu (2.0.0)
5
5
  colorize
6
6
  rubyzip (>= 2.0.0)
7
7
  safe_yaml (>= 1.0.0)
data/README.md CHANGED
@@ -105,7 +105,7 @@ Setup your configuration file
105
105
  file_name: <ONE-SKY-FILE-NAME>
106
106
  ```
107
107
 
108
- Create translation templates
108
+ Create translatable file templates
109
109
  -----
110
110
 
111
111
  Create a \*.translatable version for your platform specific localization files:
@@ -114,19 +114,10 @@ Create a \*.translatable version for your platform specific localization files:
114
114
  *example: Localizable.strings.translatable*
115
115
 
116
116
  ```
117
- // $specialKComment1$
118
- // $specialKComment2$
119
-
120
- // Locale: $specialKLocale$; Language used: $specialKLanguage$
121
-
122
- /***********
123
- * General
124
- ************/
125
-
126
- "klGeneral_Delete" = "$kDelete$";
127
- "klGeneral_Cancel" = "$kCancel$";
128
- "klGeneral_Close" = "$kClose$";
129
- "klRequestName" = "$kRequestName{user_name: %@}$";
117
+ "delete" = "$general.delete$";
118
+ "cancel" = "$general.cancel$";
119
+ "close" = "$general.close$";
120
+ "requestName" = "$request.name{user_name: %@}$";
130
121
  ```
131
122
 
132
123
  ##### Android
@@ -135,15 +126,11 @@ Create a \*.translatable version for your platform specific localization files:
135
126
  ```
136
127
  <?xml version="1.0" encoding="utf-8"?>
137
128
 
138
- <!-- $specialKComment1$ -->
139
- <!-- $specialKComment2$ -->
140
- <!-- Locale: $specialKLocale$; Language used: $specialKLanguage$ -->
141
-
142
129
  <resources>
143
- <string name="delete">$kDelete$</string>
144
- <string name="cancel">$kCancel$</string>
145
- <string name="close">$kClose$</string>
146
- <string name="request_name">$kRequestName{user_name: %s}$</string>
130
+ <string name="delete">$general.delete$</string>
131
+ <string name="cancel">$general.cancel$</string>
132
+ <string name="close">$general.close$</string>
133
+ <string name="request_name">$request.name{user_name: %s}$</string>
147
134
  </resources>
148
135
  ```
149
136
 
@@ -153,9 +140,37 @@ Create a \*.translatable version for your platform specific localization files:
153
140
  ```
154
141
  $specialKLocale$:
155
142
  resources:
156
- delete: $kDelete$
157
- cancel: $kCancel$
158
- close: $kClose$
143
+ delete: $general.delete$
144
+ cancel: $general.cancel$
145
+ close: $general.close$
159
146
  messages:
160
- request_name: $kRequestName$
147
+ request_name: $request.name$
161
148
  ```
149
+
150
+ ### Translatable options
151
+
152
+ #### Parameters
153
+
154
+ Given a key with params such as "Missing ${attribute} value"
155
+ - `$some-key-with-params{param: %s}$`: `Missing $s value`
156
+ - `$some-key-with-params//ignore-params$`: `Missing ${attribute} value`
157
+
158
+ #### Formated strings (special characters)
159
+
160
+ ##### "%" character (iOS only)
161
+
162
+ When it should be localized as given such as "Perfect: 100 (%)"
163
+ - `$some-key-with-percentage$`: `Perfect: 100%`
164
+
165
+ When it should be localized as a formated string such as "Perfect: %{percentage} (%)"
166
+ - `$some-key-with-percentage{percentage: %d}//formatted-string$`: `Perfect: %d (%%)` (note the double `%`)
167
+
168
+ #### Locale (useful for Rails localization files)
169
+
170
+ - `$specialKLocale$`: the respective locale of this file
171
+ - `$specialKLanguage$`: the respective language on the translation platform
172
+
173
+ #### Special comments
174
+
175
+ - `$specialKComment1$`: `This file was automatically generated based on a translation template.`
176
+ - `$specialKComment2$`: `Remember to CHANGE THE TEMPLATE and not this file!`
@@ -19,7 +19,7 @@ module Bisu
19
19
 
20
20
  to_localize(t).map do |l|
21
21
  if localized = localize_key(l[:key], [language] + fallback_languages)
22
- localized = process(localized)
22
+ localized = process(localized, l[:is_formatted_string])
23
23
 
24
24
  l[:params].each do |param, value|
25
25
  if localized.match("%{#{param}}")
@@ -33,8 +33,8 @@ module Bisu
33
33
  Logger.warn("Could not find translation for #{l[:match]} in #{language}")
34
34
  end
35
35
 
36
- unless @type.eql?(:ror) || l[:ignore_param_warn] == true
37
- localized.scan(/%{[^}]+}/) { |match| Logger.error("Could not find translation param for #{match} in #{language}") }
36
+ unless @type.eql?(:ror) || l[:ignore_params] == true
37
+ localized.scan(/%{[^}]+}/) { |match| Logger.error("Could not find translation param for #{match} for #{l[:key]} in #{language}") }
38
38
  end
39
39
  else
40
40
  Logger.warn("Could not find translation for #{l[:match]} in #{language}")
@@ -57,7 +57,7 @@ module Bisu
57
57
  private
58
58
 
59
59
  def to_localize(text)
60
- all_matches = text.to_enum(:scan, /\$([^\$\{\/]+)(?:\{(.+)\})?(\/\/ignore-params)?\$/).map { Regexp.last_match }
60
+ all_matches = text.to_enum(:scan, /\$([^\$\{\/]+)(?:\{(.+)\})?(\/\/[A-Za-z-]+)*\$/).map { Regexp.last_match }
61
61
  all_matches.map do |match|
62
62
  params = if match[2]
63
63
  params = match[2].split(",").map(&:strip).map do |param|
@@ -71,12 +71,13 @@ module Bisu
71
71
  match: match[0],
72
72
  key: match[1],
73
73
  params: params || {},
74
- ignore_param_warn: text.include?("//ignore-params")
74
+ ignore_params: text.include?("//ignore-params"),
75
+ is_formatted_string: text.include?("//formatted-string"),
75
76
  }
76
77
  end
77
78
  end
78
79
 
79
- def process(text)
80
+ def process(text, is_formatted_string)
80
81
  text = text.gsub("\n", "\\n")
81
82
 
82
83
  if @type.eql?(:android)
@@ -88,7 +89,7 @@ module Bisu
88
89
 
89
90
  elsif @type.eql?(:ios)
90
91
  text = text.gsub(/\"/, "\\\\\"")
91
- text = text.gsub(/%(?!{)/, "%%")
92
+ text = text.gsub(/%(?!{)/, "%%") if is_formatted_string
92
93
  end
93
94
 
94
95
  text
data/lib/bisu/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bisu
2
- VERSION = '2.0.0'
3
- VERSION_UPDATED_AT = '2023-12-07'
2
+ VERSION = '2.1.0'
3
+ VERSION_UPDATED_AT = '2023-12-18'
4
4
  end
@@ -66,10 +66,11 @@ describe Bisu::Localizer do
66
66
 
67
67
  it { translates("$kDoubleQuoted$", to: expected[:double_quoted]) }
68
68
  it { translates("$kSingleQuoted$", to: expected[:single_quoted]) }
69
- it { translates("$kEllipsis$", to: expected[:ellipsis]) }
70
- it { translates("$kAmpersand$", to: expected[:ampersand]) }
71
- it { translates("$kAtSign$", to: expected[:at_sign]) }
72
- it { translates("$kPercentage$", to: expected[:percentage]) }
69
+ it { translates("$kEllipsis$", to: expected[:ellipsis]) }
70
+ it { translates("$kAmpersand$", to: expected[:ampersand]) }
71
+ it { translates("$kAtSign$", to: expected[:at_sign]) }
72
+ it { translates("$kPercentage$", to: expected[:percentage]) }
73
+ it { translates("$kPercentage//formatted-string$", to: expected[:percentage_formatted]) }
73
74
 
74
75
  # error handling
75
76
 
@@ -130,10 +131,11 @@ describe Bisu::Localizer do
130
131
  let(:type_dependent_defaults) { {
131
132
  double_quoted: keys[language]["kDoubleQuoted"],
132
133
  single_quoted: keys[language]["kSingleQuoted"],
133
- ellipsis: keys[language]["kEllipsis"],
134
- ampersand: keys[language]["kAmpersand"],
135
- at_sign: keys[language]["kAtSign"],
136
- percentage: keys[language]["kPercentage"]
134
+ ellipsis: keys[language]["kEllipsis"],
135
+ ampersand: keys[language]["kAmpersand"],
136
+ at_sign: keys[language]["kAtSign"],
137
+ percentage: keys[language]["kPercentage"],
138
+ percentage_formatted: keys[language]["kPercentage"],
137
139
  } }
138
140
 
139
141
  describe "of type iOS" do
@@ -141,7 +143,8 @@ describe Bisu::Localizer do
141
143
 
142
144
  let(:expected) { type_dependent_defaults.merge(
143
145
  double_quoted: "Não sabes nada \\\"João das Neves\\\"",
144
- percentage: "Sabes 0%% João das Neves."
146
+ percentage: "Sabes 0% João das Neves.",
147
+ percentage_formatted: "Sabes 0%% João das Neves.",
145
148
  ) }
146
149
 
147
150
  it_behaves_like "a localizer"
@@ -182,7 +185,8 @@ describe Bisu::Localizer do
182
185
  ellipsis: "Não sabes nada João das Neves…",
183
186
  ampersand: "Não sabes nada João das Neves &amp; Pícaros",
184
187
  at_sign: "\\@johnsnow sabes alguma coisa?",
185
- percentage: "Sabes 0\\%% João das Neves."
188
+ percentage: "Sabes 0\\%% João das Neves.",
189
+ percentage_formatted: "Sabes 0\\%% João das Neves.",
186
190
  ) }
187
191
 
188
192
  it_behaves_like "a localizer"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bisu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - joaoffcosta
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-07 00:00:00.000000000 Z
11
+ date: 2023-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml
@@ -103,7 +103,7 @@ homepage: https://github.com/hole19/bisu
103
103
  licenses:
104
104
  - MIT
105
105
  metadata: {}
106
- post_install_message:
106
+ post_install_message:
107
107
  rdoc_options: []
108
108
  require_paths:
109
109
  - lib
@@ -118,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubygems_version: 3.2.33
122
- signing_key:
121
+ rubygems_version: 3.1.6
122
+ signing_key:
123
123
  specification_version: 4
124
124
  summary: A localization automation service
125
125
  test_files: []