Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

github.dismiss_out_of_range_messages

unless respond_to?(:translation_context_checker)
require 'bundler'
require 'tmpdir'

gem_dir = Dir.mktmpdir('i18n-context-generator-gems')
installed = Bundler.with_unbundled_env do
system(
'gem', 'install', 'i18n-context-generator', '--version', '0.5.1',
'--no-document', '--install-dir', gem_dir
)
end
raise 'Could not install i18n-context-generator 0.5.1' unless installed

Dir.glob(File.join(gem_dir, 'gems', '*', 'lib')).each { |path| $LOAD_PATH.unshift(path) }
require 'i18n_context_generator'

Dir.mktmpdir('dangermattic-translation-context') do |plugin_dir|
cloned = system(
'git', 'clone', '--quiet', '--depth', '1', '--branch', 'iangmaia/add-translation-context-plugin',
'https://github.com/Automattic/dangermattic.git', plugin_dir
)
raise 'Could not load Dangermattic translation context plugin' unless cloned

danger.import_plugin(File.join(plugin_dir, 'lib/dangermattic/plugins/translation_context_checker.rb'))
end
end

translation_context_checker.check_context_suggestions(
discovery_mode: :translations,
source_paths: ['WooCommerce/src/main/kotlin/'],
translation_paths: 'WooCommerce/src/main/res/values/strings.xml',
inline_mode: :translation_suggestion,
report_type: :warning
)

# `files: []` forces rubocop to scan all files, not just the ones modified in the PR
rubocop.lint(files: [], force_exclusion: true, inline_comment: true, fail_on_inline_comment: true, include_cop_names: true)

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source 'https://rubygems.org'

gem 'danger-dangermattic', '~> 1.4'
gem 'danger-dangermattic', git: 'https://github.com/Automattic/dangermattic.git', branch: 'iangmaia/add-translation-context-plugin'
gem 'fastlane', '~> 2.237'
gem 'fastlane-plugin-firebase_app_distribution', '~> 1.0'
gem 'rubocop', '~> 1.88'
Expand Down
38 changes: 32 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
GIT
remote: https://github.com/Automattic/dangermattic.git
revision: 21a63ef9531f011aff31a07c46128eff4b080570
branch: iangmaia/add-translation-context-plugin
specs:
danger-dangermattic (1.4.0)
danger (~> 9.6)
danger-plugin-api (~> 1.0)
danger-rubocop (~> 0.13)
i18n-context-generator (~> 0.5)
rubocop (~> 1.63)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -75,11 +87,6 @@ GEM
octokit (>= 4.0)
pstore (~> 0.1)
terminal-table (>= 1, < 5)
danger-dangermattic (1.4.0)
danger (~> 9.5, >= 9.5.3)
danger-plugin-api (~> 1.0)
danger-rubocop (~> 0.13)
rubocop (~> 1.63)
danger-plugin-api (1.0.0)
danger (> 2.0)
danger-rubocop (0.13.0)
Expand All @@ -91,6 +98,7 @@ GEM
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20240107)
dotenv (2.8.1)
dotstrings (0.6.0)
drb (2.2.3)
emoji_regex (3.2.3)
excon (1.5.0)
Expand Down Expand Up @@ -255,6 +263,14 @@ GEM
mutex_m
i18n (1.14.8)
concurrent-ruby (~> 1.0)
i18n-context-generator (0.5.1)
concurrent-ruby (~> 1.2)
csv (~> 3.3)
dotstrings (~> 0.6)
oj (~> 3.16)
rexml (~> 3.2)
thor (~> 1.5)
tty-progressbar (~> 0.18)
java-properties (0.3.0)
jmespath (1.6.2)
json (2.20.0)
Expand Down Expand Up @@ -286,6 +302,9 @@ GEM
octokit (6.1.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
oj (3.17.4)
bigdecimal (>= 3.0)
ostruct (>= 0.2)
open4 (1.3.4)
openssl (4.0.2)
options (2.3.2)
Expand Down Expand Up @@ -347,11 +366,18 @@ GEM
simctl (1.6.10)
CFPropertyList
naturally
strings-ansi (0.2.0)
terminal-notifier (2.0.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.5.0)
trailblazer-option (0.1.2)
tty-cursor (0.7.1)
tty-progressbar (0.18.3)
strings-ansi (~> 0.2)
tty-cursor (~> 0.7)
tty-screen (~> 0.8)
unicode-display_width (>= 1.6, < 3.0)
tty-screen (0.8.2)
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
Expand All @@ -377,7 +403,7 @@ PLATFORMS
ruby

DEPENDENCIES
danger-dangermattic (~> 1.4)
danger-dangermattic!
faraday (~> 1.10)
fastlane (~> 2.237)
fastlane-plugin-firebase_app_distribution (~> 1.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.woocommerce.android.ui.test

import android.content.Context
import com.woocommerce.android.R

/**
* Test-only resource usages for exercising translation-context suggestions.
*/
internal object TranslationContextPluginTest {
fun orderEditorLabels(context: Context): List<String> = listOf(
context.getString(R.string.translation_context_test_order_save_button),
context.getString(R.string.translation_context_test_order_processing_status),
context.getString(R.string.translation_context_test_order_note_hint)
)
}
3 changes: 3 additions & 0 deletions WooCommerce/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4777,4 +4777,7 @@
<string name="ai_assistant_confirmation_product_variation_update_title_with_name" a8c-src-lib="module:ai-assistant-feature">Update variation %1$s (#%2$s) for product #%3$s</string>
<string name="error_site_url_certificate_validity" a8c-src-lib="module:login">We couldn\'t establish a secure connection. Check that your device date and time are correct, then try again.</string>
<string name="error_site_url_remote_certificate" a8c-src-lib="module:login">We couldn\'t verify this site\'s security certificate. Contact your hosting provider or site administrator, then try again.</string>
<string name="translation_context_test_order_save_button">Save</string>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<string name="translation_context_test_order_save_button">Save</string>
<!-- A button label in an order editor screen that saves the current order when tapped. -->
<string name="translation_context_test_order_save_button">Save</string>

Generated by 🚫 Danger

<string name="translation_context_test_order_processing_status">Processing</string>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<string name="translation_context_test_order_processing_status">Processing</string>
<!-- A status label displayed in the order editor screen indicating that an order is currently being processed. -->
<string name="translation_context_test_order_processing_status">Processing</string>

Generated by 🚫 Danger

<string name="translation_context_test_order_note_hint">Add a note</string>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<string name="translation_context_test_order_note_hint">Add a note</string>
<!-- Placeholder hint text shown inside a text input field in an order editor screen, prompting the user to type an internal note for the order. -->
<string name="translation_context_test_order_note_hint">Add a note</string>

Generated by 🚫 Danger

</resources>
Loading