i18n_on_steroids 0.1.0 → 0.2.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 +4 -4
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +10 -1
- data/lib/i18n_on_steroids/translation_helper.rb +20 -9
- data/lib/i18n_on_steroids/version.rb +9 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5482b9d52b60ea2d856bcc1a26aab2d3805978a1445c27de768b985f58faa02c
|
4
|
+
data.tar.gz: ca5a1565ac889dbbf335ff9541e6a46787aefaec98321cd4aff72524dd0cd755
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01e7f5bb75dcf4167f1f0fdad5f7da3a2203ea76aa4e525fcc8f20a37f04eccc25ae5781d48dafd8187b91fff8db2b282d398c229ce479426ec1533691e12f6c
|
7
|
+
data.tar.gz: 71755126e980b49d907441ee660b5a1ac32266299eb44c859410a3c215b0530da1e464fa2cf566d6cd6810bda4448fc20572274a93d26281fd8bf73f02736fbf
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.1] - 2024-08-21
|
4
|
+
|
5
|
+
- Added ability to pipe regular strings. Because, why not?
|
6
|
+
`${ 'Hello, World!' | upcase } => HELLO, WORLD!`
|
7
|
+
Note: This needs to be done via `${}` instead of `%{}` otherwise Psych will throw an error.
|
8
|
+
- Started listening to `rubocop-performance` and apparently improved some performance.
|
9
|
+
- Enabled more `rubocop` cops.
|
10
|
+
- Lowered 'ActiveSupport' and 'ActionView' version requirements to allow more Ruby versions to be supported.
|
11
|
+
|
3
12
|
## [0.1.0] - 2024-08-22
|
4
13
|
|
5
|
-
- Initial release
|
14
|
+
- Initial release
|
@@ -20,33 +20,44 @@ module I18nOnSteroids
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def process_mixed_translation(translation, options)
|
23
|
-
parts = translation.split(/(
|
23
|
+
parts = translation.split(/(\$\{[^}]+\}|%\{[^}]+\})/)
|
24
24
|
processed_parts = parts.map do |part|
|
25
|
-
if part.start_with?("
|
25
|
+
if part.start_with?("${", "%{")
|
26
26
|
process_interpolation(part, options)
|
27
27
|
else
|
28
28
|
part
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
processed_parts.join
|
32
|
+
processed_parts.join
|
33
33
|
end
|
34
34
|
|
35
35
|
def process_interpolation(interpolation, options)
|
36
|
-
match_data = interpolation.match(/^(
|
36
|
+
match_data = interpolation.match(/^(\$\{|%\{)([^}]+)}$/)
|
37
37
|
|
38
38
|
return interpolation unless match_data
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
if value.nil?
|
44
|
-
interpolation
|
40
|
+
if (content = match_data[2].strip).start_with?("'", '"')
|
41
|
+
# This is a regular string with pipes: ${'Hello' | upcase}
|
42
|
+
process_string_with_pipes(content)
|
45
43
|
else
|
44
|
+
# This is a variable interpolation with pipes: ${name | upcase}
|
45
|
+
key, *pipes = content.split("|").map(&:strip)
|
46
|
+
value = options[key.to_sym]
|
47
|
+
|
48
|
+
return interpolation if value.nil?
|
49
|
+
|
46
50
|
apply_pipes(value, pipes, options)
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
54
|
+
def process_string_with_pipes(content)
|
55
|
+
string, *pipes = content.split("|").map(&:strip)
|
56
|
+
string = string[1...-1] if string.start_with?('"', "'")
|
57
|
+
|
58
|
+
apply_pipes(string, pipes, {})
|
59
|
+
end
|
60
|
+
|
50
61
|
# rubocop:disable Metrics/MethodLength
|
51
62
|
# rubocop:disable Metrics/AbcSize
|
52
63
|
# rubocop:disable Metrics/CyclomaticComplexity
|
@@ -1,5 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Reminder to self with how Semantic Versioning works:
|
4
|
+
#
|
5
|
+
# MAJOR version when you make incompatible API changes
|
6
|
+
# MINOR version when you add functionality in a backward compatible manner
|
7
|
+
# PATCH version when you make backward compatible bug fixes
|
8
|
+
#
|
9
|
+
# Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
|
10
|
+
|
3
11
|
module I18nOnSteroids
|
4
|
-
VERSION = "0.
|
12
|
+
VERSION = "0.2.0"
|
5
13
|
end
|