pseudolocalization 0.9.0 → 0.10.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
  SHA256:
3
- metadata.gz: ca597fc6e2ea40f05915ef289dc48d3deb1c95872aec4a8b69474caeabfc8b39
4
- data.tar.gz: 7485fd957362b90aeedd711c4197c96b8629d641896fa65e77f016a613a486b6
3
+ metadata.gz: '090ec80bbdb475a3a34314d973d911af6ae22121c50bb5bf9ca0fc9e9801df4c'
4
+ data.tar.gz: 6850bb50f3ccd2767ad8b5080c1616a7e82a7d5321d30568adb419efc1f06140
5
5
  SHA512:
6
- metadata.gz: 6d238815d07f095314e6fbbca25a71ea44543e8a8d57a1b4c3fc2f7d55a5e76b56d75cd7a8f308ed89757ee3710fd4e5e0dcfd4d5ce3968ca065535a4e01a824
7
- data.tar.gz: 35e98480b647dc3203e2c09248db82dd060d08d77032c410cfc76492eaa4775e214a07fe9582429a57025a1da7e641bde3cb95cf4ef9f9029777abd61fb350bf
6
+ metadata.gz: 319d0c9e1f9aa8ac9439312e1ddba612a7a9f403f989cb056b79a8d909103425be7bcaa89ed45d89368b1b692ea7ae706ca055f72a8081055f0211a3cd1784f1
7
+ data.tar.gz: 967d013f09fbe58c769b441e3bfcc43154d0fb94922e7ab2e8c46c50dc02a106a7ef3fb97bd1e280412778e1b7526d5b206da417172c3c381054027b6bf75d9b
@@ -0,0 +1,12 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: bundler
5
+ directory: "/"
6
+ schedule:
7
+ interval: weekly
8
+ time: "10:00"
9
+ timezone: America/Toronto
10
+ open-pull-requests-limit: 99
11
+ reviewers:
12
+ - Shopify/intl-languages
@@ -0,0 +1,22 @@
1
+ name: Contributor License Agreement (CLA)
2
+
3
+ on:
4
+ pull_request_target:
5
+ types: [opened, synchronize]
6
+ issue_comment:
7
+ types: [created]
8
+
9
+ jobs:
10
+ cla:
11
+ runs-on: ubuntu-latest
12
+ if: |
13
+ (github.event.issue.pull_request
14
+ && !github.event.issue.pull_request.merged_at
15
+ && contains(github.event.comment.body, 'signed')
16
+ )
17
+ || (github.event.pull_request && !github.event.pull_request.merged)
18
+ steps:
19
+ - uses: Shopify/shopify-cla-action@v1
20
+ with:
21
+ github-token: ${{ secrets.GITHUB_TOKEN }}
22
+ cla-token: ${{ secrets.CLA_TOKEN }}
@@ -6,26 +6,32 @@ on:
6
6
  - '**'
7
7
  push:
8
8
  branches:
9
- - master
9
+ - main
10
10
 
11
11
  jobs:
12
12
  build:
13
13
  name: Ruby ${{ matrix.version }} ${{ matrix.gemfile }}
14
- runs-on: ubuntu-latest
14
+ runs-on: ubuntu-24.04
15
15
  env:
16
16
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
17
17
  strategy:
18
+ # Report every Ruby independently. Without this, one failing job
19
+ # cancels its siblings and hides their results.
20
+ fail-fast: false
18
21
  matrix:
22
+ # Quoted on purpose. Unquoted, YAML reads 3.0 as the number 3 and
23
+ # setup-ruby then installs "latest 3.x" instead of Ruby 3.0.
19
24
  version:
20
- - 2.4
21
- - 2.5
22
- - 2.6
23
- - 2.7
24
- - 3.0
25
+ - '2.7'
26
+ - '3.0'
27
+ - '3.1'
28
+ - '3.2'
29
+ - '3.3'
30
+ - '3.4'
25
31
  gemfile:
26
32
  - Gemfile
27
33
  steps:
28
- - uses: actions/checkout@v2
34
+ - uses: actions/checkout@v7
29
35
 
30
36
  - name: Set up Ruby ${{ matrix.version }}
31
37
  uses: ruby/setup-ruby@v1
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.5
data/CHANGELOG.md CHANGED
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
6
  ## Unreleased
7
7
  Nil.
8
8
 
9
+ ## [0.10.0] - 2026-10-12
10
+ ### Fixed
11
+ - Fixed slow matching in `ESCAPED_REGEX` on strings with many unclosed `<`, `{{`, `%{` or `&` (CWE-1333). Lazy wildcards became character classes bounded by each token's own delimiters. Output is unchanged or improved for well-formed input; a token containing a nested opener of its own kind (`<b <i>x</i>`, `{{ a {b} }}`, `&a&amp;`) is no longer swallowed up to the first closer. Quoted HTML attribute values may now contain `<` and `>`.
12
+ - `ESCAPED_REGEX` now also preserves HTML comments (`<!-- -->`), Liquid tags (`{% %}`), markup spanning a newline, and `{`/`}` inside quoted Liquid strings; a `<` not followed by a letter, `/`, `!` or `?` is treated as text; a URL ends at `<` or `>`; only well-formed character references (`&name;`, `&#39;`, `&#x27;`) are kept. Output is unchanged for every string in Shopify Core's English locale files except 19 Liquid email subjects, where `{% if … %}` tags are now preserved instead of pseudolocalized.
13
+
14
+ ## [0.9.1] - 2024-06-27
15
+ ### Added
16
+ - Added support for pseudolocalized translations [#82](https://github.com/Shopify/pseudolocalization/pull/82)
17
+
9
18
  ## [0.9.0] - 2021-02-17
10
19
  ### Added
11
20
  - Added support for ignoring specific translation keys [#59](https://github.com/Shopify/pseudolocalization/pull/59)
@@ -52,7 +61,9 @@ Nil.
52
61
 
53
62
  Please refer to [GitHub releases](https://github.com/Shopify/pseudolocalization/releases) for releases prior to [0.8.0].
54
63
 
55
- [Unreleased]: https://github.com/Shopify/pseudolocalization/compare/0.9.0...HEAD
64
+ [Unreleased]: https://github.com/Shopify/pseudolocalization/compare/v0.10.0...HEAD
65
+ [0.10.0]: https://github.com/Shopify/pseudolocalization/compare/v0.9.1...v0.10.0
66
+ [0.9.1]: https://github.com/Shopify/pseudolocalization/compare/0.9.0...0.9.1
56
67
  [0.9.0]: https://github.com/Shopify/pseudolocalization/compare/0.8.4...0.9.0
57
68
  [0.8.4]: https://github.com/Shopify/pseudolocalization/compare/0.8.3...0.8.4
58
69
  [0.8.3]: https://github.com/Shopify/pseudolocalization/compare/0.8.2...0.8.3
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pseudolocalization (0.9.0)
4
+ pseudolocalization (0.10.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- minitest (5.14.3)
10
- rake (13.0.3)
9
+ minitest (5.25.4)
10
+ rake (13.2.1)
11
11
 
12
12
  PLATFORMS
13
13
  ruby
@@ -18,4 +18,4 @@ DEPENDENCIES
18
18
  rake (~> 13.0)
19
19
 
20
20
  BUNDLED WITH
21
- 2.2.4
21
+ 2.4.22
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Pseudolocalization
2
2
 
3
- [![Version][gem]][gem_url] [![Build Status](https://github.com/Shopify/pseudolocalization/workflows/CI/badge.svg?branch=master)](https://github.com/Shopify/pseudolocalization/actions?query=workflow%3ACI)
3
+ [![Version][gem]][gem_url] [![Build Status](https://github.com/Shopify/pseudolocalization/workflows/CI/badge.svg?branch=main)](https://github.com/Shopify/pseudolocalization/actions?query=workflow%3ACI)
4
4
 
5
5
  [About this repo](#about-this-repo) | [How to use this repo](#how-to-use-this-repo) | [Contribute to this repo](#contribute-to-this-repo)
6
6
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  Internationalization is a hard and tedious process. Different character sets, different average word length, different pluralization rules... There's a lot going on and it's impossible to test against all possible scenarios. As a side effect, most of us will simply test against one or two known languages and hope for the best. Unfortunately, this often leads to broken UI elements, texts going out of bounds, or forgotten non-translated strings making their way into a final release.
11
11
 
12
- As an example, let's examine the string "Set the power switch to 0.";
12
+ As an example, let's examine the string "Set the power switch to 0.":
13
13
 
14
14
  | Language | String | Characters | Percentage |
15
15
  |----------|--------|------------|------------|
@@ -25,6 +25,12 @@ In an attempt to ease this whole process, we created a small tool that gives you
25
25
  2. Expand words by doubling all vowels
26
26
  3. Use English lookalike UTF8 characters for readability
27
27
 
28
+ For the example above, this looks like:
29
+
30
+ | Language | String | Characters | Percentage |
31
+ |----------|--------|------------|------------|
32
+ | Pseudo-English | Ṣḛḛṭ ṭḥḛḛ ṗṓṓẁḛḛṛ ṡẁḭḭṭͼḥ ṭṓṓ 0. | 32 chars | 23% more
33
+
28
34
  ## How to use this repo
29
35
  ### Installation
30
36
 
data/dev.yml CHANGED
@@ -3,7 +3,7 @@ name: pseudolocalization
3
3
  type: ruby
4
4
 
5
5
  up:
6
- - ruby: 2.7.2
6
+ - ruby
7
7
  - bundler
8
8
 
9
9
  commands:
@@ -3,11 +3,13 @@ module Pseudolocalization
3
3
  class Pseudolocalizer
4
4
  ESCAPED_REGEX = Regexp.new("(#{
5
5
  [
6
- "<.*?>",
7
- "{{.*?}}",
8
- "%{.*?}",
9
- "https?:\/\/\\S+",
10
- "&\\S*?;"
6
+ "<!--(?:[^-]|-[^-])*-->", # HTML comment
7
+ "<[a-zA-Z/!?][^<>\"']*(?:(?:\"[^\"]*\"|'[^']*')[^<>\"']*)*>", # HTML tag, end tag, doctype
8
+ "{{[^{}\"']*(?:(?:\"[^\"]*\"|'[^']*')[^{}\"']*)*}}", # Liquid output
9
+ "{%-?\\s*[a-zA-Z#][^%\"']*(?:(?:\"[^\"]*\"|'[^']*')[^%\"']*)*%}", # Liquid tag
10
+ "%{[^{}\\n]*}", # Ruby I18n interpolation
11
+ "https?:\/\/[^\\s<>]+", # URL
12
+ "&(?:[a-zA-Z][a-zA-Z0-9]*|#[0-9]+|#[xX][0-9a-fA-F]+);", # HTML character reference
11
13
  ].join('|')
12
14
  })")
13
15
 
@@ -1,3 +1,3 @@
1
1
  module Pseudolocalization
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -31,6 +31,13 @@ module Pseudolocalization
31
31
  ::Pseudolocalization::I18n::Pseudolocalizer.pseudolocalize(original_backend.translate(locale, key, options))
32
32
  end
33
33
 
34
+ def translations
35
+ original = original_backend.translations
36
+ original.transform_values do |locale_translations|
37
+ pseudolocalize_node(locale_translations)
38
+ end
39
+ end
40
+
34
41
  private
35
42
 
36
43
  def key_ignored?(key)
@@ -48,6 +55,22 @@ module Pseudolocalization
48
55
  end
49
56
  end
50
57
  end
58
+
59
+ def pseudolocalize_node(node, scope = [])
60
+ if node.is_a?(Hash)
61
+ node.each_with_object({}) do |(key, value), memo|
62
+ memo[key] = pseudolocalize_node(value, scope + [key])
63
+ end
64
+ elsif !key_ignored?(scope.join('.'))
65
+ ::Pseudolocalization::I18n::Pseudolocalizer.pseudolocalize(node)
66
+ else
67
+ node
68
+ end
69
+ end
70
+
71
+ def init_translations
72
+ original_backend.send(:init_translations)
73
+ end
51
74
  end
52
75
  end
53
76
  end
@@ -10,6 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["christ.blais@gmail.com"]
11
11
  spec.licenses = ['MIT']
12
12
 
13
+ spec.required_ruby_version = ">= 2.7"
14
+
13
15
  spec.summary = %q{Internationalization development tool}
14
16
  spec.description = %q{Internationalization development tool to help identify missing translations}
15
17
  spec.homepage = "https://github.com/Shopify/pseudolocalization"
data/service.yml CHANGED
@@ -1,7 +1 @@
1
- org_line: Build
2
- owners:
3
- - Shopify/intl-languages
4
- slack_channels:
5
- - help-i18n-and-translation
6
- classification: library
7
- ci_url: https://github.com/Shopify/pseudolocalization/workflows/CI
1
+ --- {}
data/shipit.rubygems.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  ci:
2
2
  require:
3
- - 'Ruby 2.4 Gemfile'
4
- - 'Ruby 2.5 Gemfile'
5
- - 'Ruby 2.6 Gemfile'
6
3
  - 'Ruby 2.7 Gemfile'
7
- - 'Ruby 3 Gemfile'
4
+ - 'Ruby 3.0 Gemfile'
5
+ - 'Ruby 3.1 Gemfile'
6
+ - 'Ruby 3.2 Gemfile'
7
+ - 'Ruby 3.3 Gemfile'
8
+ - 'Ruby 3.4 Gemfile'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pseudolocalization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Blais
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2021-02-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -45,10 +44,11 @@ executables: []
45
44
  extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
48
- - ".dependabot/config.yml"
49
- - ".github/probots.yml"
47
+ - ".github/dependabot.yml"
48
+ - ".github/workflows/cla.yml"
50
49
  - ".github/workflows/ruby-ci.yml"
51
50
  - ".gitignore"
51
+ - ".ruby-version"
52
52
  - CHANGELOG.md
53
53
  - Gemfile
54
54
  - Gemfile.lock
@@ -69,7 +69,6 @@ licenses:
69
69
  - MIT
70
70
  metadata:
71
71
  allowed_push_host: https://rubygems.org
72
- post_install_message:
73
72
  rdoc_options: []
74
73
  require_paths:
75
74
  - lib
@@ -77,15 +76,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
76
  requirements:
78
77
  - - ">="
79
78
  - !ruby/object:Gem::Version
80
- version: '0'
79
+ version: '2.7'
81
80
  required_rubygems_version: !ruby/object:Gem::Requirement
82
81
  requirements:
83
82
  - - ">="
84
83
  - !ruby/object:Gem::Version
85
84
  version: '0'
86
85
  requirements: []
87
- rubygems_version: 3.0.3
88
- signing_key:
86
+ rubygems_version: 4.0.21
89
87
  specification_version: 4
90
88
  summary: Internationalization development tool
91
89
  test_files: []
@@ -1,12 +0,0 @@
1
- version: 1
2
- update_configs:
3
- - package_manager: "ruby:bundler"
4
- directory: "/"
5
- update_schedule: "weekly"
6
- automerged_updates:
7
- - match:
8
- dependency_type: "all"
9
- update_type: "all"
10
- version_requirement_updates: "auto"
11
- default_reviewers:
12
- - Shopify/intl-languages
data/.github/probots.yml DELETED
@@ -1,3 +0,0 @@
1
- # .github/probots.yml
2
- enabled:
3
- - cla