translation_diff 1.0.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.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +84 -0
  3. data/.github/workflows/release.yml +28 -0
  4. data/.gitignore +11 -0
  5. data/.rubocop.yml +39 -0
  6. data/.ruby-version +1 -0
  7. data/CHANGELOG.md +723 -0
  8. data/Gemfile +61 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +158 -0
  11. data/Rakefile +41 -0
  12. data/data/languages/azure.json +285 -0
  13. data/data/languages/deepl.json +220 -0
  14. data/data/languages/google.json +399 -0
  15. data/data/languages/modernmt.json +413 -0
  16. data/docs/caching.md +185 -0
  17. data/docs/configuration.md +205 -0
  18. data/docs/contracts.md +187 -0
  19. data/docs/development.md +34 -0
  20. data/docs/errors.md +92 -0
  21. data/docs/how-it-works.md +145 -0
  22. data/docs/instrumentation.md +96 -0
  23. data/docs/languages.md +94 -0
  24. data/docs/providers.md +379 -0
  25. data/docs/sql-cache.md +366 -0
  26. data/lib/generators/translation_diff/install_generator.rb +15 -0
  27. data/lib/generators/translation_diff/templates/create_translation_diff_tables.rb.erb +24 -0
  28. data/lib/translation_diff/active_record/support.rb +34 -0
  29. data/lib/translation_diff/active_record.rb +3 -0
  30. data/lib/translation_diff/batch.rb +98 -0
  31. data/lib/translation_diff/call_preparation.rb +47 -0
  32. data/lib/translation_diff/capabilities.rb +9 -0
  33. data/lib/translation_diff/configuration/cache_guard_options.rb +39 -0
  34. data/lib/translation_diff/configuration/cache_ttl_option.rb +30 -0
  35. data/lib/translation_diff/configuration/option_table.rb +38 -0
  36. data/lib/translation_diff/configuration/provider_option_owners.rb +40 -0
  37. data/lib/translation_diff/configuration.rb +135 -0
  38. data/lib/translation_diff/context.rb +23 -0
  39. data/lib/translation_diff/dispatcher.rb +57 -0
  40. data/lib/translation_diff/document.rb +23 -0
  41. data/lib/translation_diff/errors.rb +44 -0
  42. data/lib/translation_diff/fragment.rb +33 -0
  43. data/lib/translation_diff/http_provider.rb +128 -0
  44. data/lib/translation_diff/instrumentation.rb +25 -0
  45. data/lib/translation_diff/languages/refresh.rb +70 -0
  46. data/lib/translation_diff/languages/set.rb +53 -0
  47. data/lib/translation_diff/languages.rb +30 -0
  48. data/lib/translation_diff/leaves.rb +22 -0
  49. data/lib/translation_diff/markup.rb +85 -0
  50. data/lib/translation_diff/passage.rb +149 -0
  51. data/lib/translation_diff/preview.rb +3 -0
  52. data/lib/translation_diff/previewer.rb +78 -0
  53. data/lib/translation_diff/provider.rb +91 -0
  54. data/lib/translation_diff/providers/amazon.rb +126 -0
  55. data/lib/translation_diff/providers/azure.rb +78 -0
  56. data/lib/translation_diff/providers/deepl.rb +88 -0
  57. data/lib/translation_diff/providers/google.rb +64 -0
  58. data/lib/translation_diff/providers/libretranslate.rb +65 -0
  59. data/lib/translation_diff/providers/modernmt.rb +74 -0
  60. data/lib/translation_diff/providers/null.rb +20 -0
  61. data/lib/translation_diff/providers.rb +69 -0
  62. data/lib/translation_diff/railtie.rb +12 -0
  63. data/lib/translation_diff/rate_limiters/active_record.rb +92 -0
  64. data/lib/translation_diff/rate_limiters/redis.rb +59 -0
  65. data/lib/translation_diff/rate_limiters.rb +9 -0
  66. data/lib/translation_diff/redaction.rb +45 -0
  67. data/lib/translation_diff/registry.rb +31 -0
  68. data/lib/translation_diff/segment.rb +32 -0
  69. data/lib/translation_diff/segmenters/pragmatic.rb +102 -0
  70. data/lib/translation_diff/segmenters/simple.rb +122 -0
  71. data/lib/translation_diff/segmenters.rb +4 -0
  72. data/lib/translation_diff/sentence_cache.rb +76 -0
  73. data/lib/translation_diff/stores/active_record.rb +106 -0
  74. data/lib/translation_diff/stores/memory.rb +34 -0
  75. data/lib/translation_diff/stores/redis.rb +49 -0
  76. data/lib/translation_diff/stores.rb +9 -0
  77. data/lib/translation_diff/tasks/translation_diff.rake +21 -0
  78. data/lib/translation_diff/translation/request.rb +8 -0
  79. data/lib/translation_diff/translation/response.rb +35 -0
  80. data/lib/translation_diff/translation/usage.rb +8 -0
  81. data/lib/translation_diff/translator.rb +103 -0
  82. data/lib/translation_diff/version.rb +3 -0
  83. data/lib/translation_diff.rb +93 -0
  84. data/translation_diff.gemspec +56 -0
  85. metadata +243 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e974f47598986318fd29604f44d904138d71b6901ba36e94c941746f0f9daf03
4
+ data.tar.gz: 7822ddcf52fff47ccc00091e80198427ca12d7c9871245745f7897a3c5d51417
5
+ SHA512:
6
+ metadata.gz: 28624bb12271c2b81076bb7b9e79ac6fc0be2d0fd23e90799fd33b0355fe8f7315007d387584de7ec164c0333849f900943fc7bc446373fec9b0386b3b7855bd
7
+ data.tar.gz: fafc0a73a65ccf336d809f3d6e73e78062d4133d63259fafad519323842fe2d067a1ba9e5f306c9a47e268ca473a504b78c33f47d1d193572c78c35c08b44b8e
@@ -0,0 +1,84 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ ruby: ["3.4", "4.0"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+ bundler-cache: true
23
+
24
+ - run: bundle exec rake test
25
+
26
+ postgres:
27
+ runs-on: ubuntu-latest
28
+
29
+ services:
30
+ postgres:
31
+ image: postgres:18
32
+ env:
33
+ POSTGRES_PASSWORD: postgres
34
+ options: >-
35
+ --health-cmd pg_isready --health-interval 10s
36
+ --health-timeout 5s --health-retries 5
37
+ ports: ["5432:5432"]
38
+
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+ - uses: ruby/setup-ruby@v1
42
+ with:
43
+ ruby-version: "3.4"
44
+ bundler-cache: true
45
+ - run: bundle exec rake test
46
+ env:
47
+ TRANSLATION_DIFF_DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
48
+
49
+ mysql:
50
+ runs-on: ubuntu-latest
51
+
52
+ services:
53
+ mysql:
54
+ image: mysql:8
55
+ env:
56
+ MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
57
+ MYSQL_DATABASE: translation_diff_test
58
+ options: >-
59
+ --health-cmd "mysqladmin ping" --health-interval 10s
60
+ --health-timeout 5s --health-retries 5
61
+ ports: ["3306:3306"]
62
+
63
+ steps:
64
+ - uses: actions/checkout@v4
65
+ - uses: ruby/setup-ruby@v1
66
+ with:
67
+ ruby-version: "3.4"
68
+ bundler-cache: true
69
+ - run: bundle exec rake test
70
+ env:
71
+ TRANSLATION_DIFF_DATABASE_URL: trilogy://root@127.0.0.1:3306/translation_diff_test
72
+
73
+ lint:
74
+ runs-on: ubuntu-latest
75
+
76
+ steps:
77
+ - uses: actions/checkout@v4
78
+
79
+ - uses: ruby/setup-ruby@v1
80
+ with:
81
+ ruby-version: "3.4"
82
+ bundler-cache: true
83
+
84
+ - run: bundle exec rubocop
@@ -0,0 +1,28 @@
1
+ name: Release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ push:
10
+ runs-on: ubuntu-latest
11
+
12
+ permissions:
13
+ # Push the version tag when `rake release` creates one.
14
+ contents: write
15
+ # Mint the OIDC token RubyGems trusted publishing authenticates with.
16
+ id-token: write
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: "3.4"
24
+ bundler-cache: true
25
+
26
+ - run: bundle exec rake test
27
+
28
+ - uses: rubygems/release-gem@v1
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /test/reports/
9
+ /tmp/
10
+
11
+ test.rb
data/.rubocop.yml ADDED
@@ -0,0 +1,39 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.4
3
+ NewCops: enable
4
+
5
+ Style/Documentation:
6
+ Enabled: false
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
10
+
11
+ Style/ClassAndModuleChildren:
12
+ EnforcedStyle: compact
13
+
14
+ Metrics/BlockLength:
15
+ Exclude:
16
+ - test/**/*
17
+
18
+ Layout/LineLength:
19
+ Max: 120
20
+
21
+ Gemspec/DevelopmentDependencies:
22
+ EnforcedStyle: gemspec
23
+
24
+ # Ruby 3.4 chills string literals in files without this comment, and the
25
+ # supported floor is now 3.4.
26
+ Style/FrozenStringLiteralComment:
27
+ Enabled: false
28
+
29
+ # Translator#initialize takes its collaborators as keyword arguments -- values, from:, to:, provider:, config:,
30
+ # assume_supported: and the provider's own options -- which read perfectly well named at a call site, unlike
31
+ # pulling them out of an undocumented options hash, which is the confusion this cop guards against.
32
+ Metrics/ParameterLists:
33
+ CountKeywordArgs: false
34
+
35
+ Metrics/ClassLength:
36
+ Max: 100
37
+ Exclude:
38
+ # Test classes are mostly tables of cases.
39
+ - test/**/*
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 4.0.5