Skip to content

Commit

Permalink
Fix outdated branded words: (#51)
Browse files Browse the repository at this point in the history
- Red Hat Virtualization: Change from "RHEV" to "RHV"
- Red Hat Openstack Platform: Change from "RHEL Openstack Platform" to "Red Hat Openstack Platform"
- Fix link to docs for registering hosts using bootstrap script
- Simplify regular expressions
- Add test based on documentation strings
  • Loading branch information
Thorben-D authored Aug 22, 2024
1 parent c10c3d6 commit f78f229
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
43 changes: 14 additions & 29 deletions lib/foreman_theme_satellite/branded_words.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ module ForemanThemeSatellite
# For now, modifiers are not supported by the generator.
# Make sure the regexp works both with Ruby and JavaScript.
# Entries are processed in order and first wins.
# Occurrences of "proxy" should be treated as a bug as it is unclear whether the author refers to a HTTP(S) proxy or a Capsule
FOREMAN_BRAND = {
/%{proxy}/ => '%{proxy}',
/%{foreman}/ => '%{foreman}',
/\b[Pp]roxy [Hh][Tt][Tt][Pp]\b(?!-)/ => 'Proxy HTTP', # Workaround for French translation
/\b[Pp]roxies [Hh][Tt][Tt][Pp]\b(?!-)/ => 'Proxies HTTP', # Workaround for French translation
/\b[Hh][Tt][Tt][Pp] [Pp]roxy\b(?!-)/ => 'HTTP Proxy',
/\b[Hh][Tt][Tt][Pp] [Pp]roxies\b(?!-)/ => 'HTTP Proxies',
## BEGIN Remove after imprecise strings have been fixed in core
/\b[Hh][Tt][Tt][Pp](?:\([sS]\))? [Pp]roxy\b(?!-)/ => 'HTTP proxy',
/\b[Hh][Tt][Tt][Pp](?:\([sS]\))? [Pp]roxies\b(?!-)/ => 'HTTP proxies',
/\bHTTP\(S\) proxy\b(?!-)/ => 'HTTP(S) proxy',
/\bIgnore Proxy\b(?!-)/ => 'Ignore Proxy',
/\bIgnore proxy\b(?!-)/ => 'Ignore Proxy',
Expand All @@ -24,33 +26,16 @@ module ForemanThemeSatellite
%r{\bhttps://proxy.example.com:8080\b(?!-)} => 'https://proxy.example.com:8080',
/\bproxy for all outgoing HTTP connections\b(?!-)/ => 'proxy for all outgoing HTTP connections',
/\bperform various actions through those proxies\b(?!-)/ => 'perform various actions through those proxies',
/\bForeman\b(?!-)/ => 'Satellite',
/\bforeman\b(?!-)/ => 'satellite',
/\bsmart-proxy\b(?!-)/ => 'capsule',
/\bSmart-proxy\b(?!-)/ => 'Capsule',
/\bsmart proxies\b(?!-)/ => 'capsules',
/\bSmart proxies\b(?!-)/ => 'Capsules',
/\bsmart-proxies\b(?!-)/ => 'capsules',
/\bSmart-proxies\b(?!-)/ => 'Capsules',
/\bSmart Proxies\b(?!-)/ => 'Capsules',
/\bSmart Proxy\(ies\)(?!-)/ => 'Capsule(s)',
/\bSmart Proxy\b(?!-)/ => 'Capsule',
/\bsmart proxy\b(?!-)/ => 'capsule',
/\bSmart-Proxies\b(?!-)/ => 'Capsules',
/\bSmart proxy\b(?!-)/ => 'Capsule',
/\bSmart-Proxy\b(?!-)/ => 'Capsule',
/\boVirt\b(?!-)/ => 'RHEV',
/\bovirt\b(?!-)/ => 'RHEV',
/\bOvirt\b(?!-)/ => 'RHEV',
/\bFreeIPA\b(?!-)/ => 'Red Hat Identity Management',
/\bOpenStack\b(?!-)/ => 'RHEL OpenStack Platform',
/\bopenstack\b(?!-)/ => 'RHEL OpenStack Platform',
/\bOpenstack\b(?!-)/ => 'RHEL OpenStack Platform',
/\bProxy\b(?!-)/ => 'Capsule',
/\bproxy\b(?!-)/ => 'Capsule',
/\bProxies\b(?!-)/ => 'Capsules',
/\bproxies\b(?!-)/ => 'Capsules',
/\b[Kk]atello 4.0\b(?!-)/ => 'Satellite 6.11',
## END
/\b[Ff]oreman\b(?!-)/ => 'Satellite',
/\b[Ss]mart[- ]?[pP]roxy\b(?!-)/ => 'Capsule',
/\b[Ss]mart[- ]?[pP]roxies\b(?!-)/ => 'Capsules',
/\b[Pp]roxy\b(?!-)/ => 'Capsule',
/\b[Pp]roxies\b(?!-)/ => 'Capsules',
/\b[Oo][Vv]irt\b(?!-)/ => 'RHV',
/\bFreeIPA\b(?!-)/ => 'Red Hat Identity Management',
/\b[Oo]pen[Ss]tack\b(?!-)/ => 'Red Hat OpenStack Platform',
/\b[Kk]atello 4.0\b(?!-)/ => 'Satellite 6.11',
/\b[Kk]atello 4.10\b(?!-)/ => 'Satellite 6.15',
/\b[Kk]atello 4.11\b(?!-)/ => 'Satellite 6.15',
/\b[Kk]atello 4.12\b(?!-)/ => 'Satellite 6.16',
Expand Down
26 changes: 24 additions & 2 deletions test/unit/replacer_repository_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,30 @@ class TranslationsTest < ActiveSupport::TestCase
end

test 'Can work with whitelist branding' do
actual = _('HTTP proxy for proxy')
actual = _('http proxy for smart proxy')

assert_equal 'HTTP Proxy for Capsule', actual
assert_equal 'HTTP proxy for Capsule', actual
end

test 'random branding test' do
# Tests branding based on strings randomly picked from Foreman- and Satellite-documentation
test_strings = [
'An operating system is a collection of resources that define how Foreman server installs a base operating system on a host.',
'Installing the Infoblox CA certificate on Smart Proxy server',
'In the Foreman web UI, navigate to Infrastructure > Smart Proxies, select the Smart Proxy with the DHCP Infoblox module, and ensure that the dhcp feature is listed.',
'Foreman Server automatically manages the PXE configuration, organizes networking services, and provides the operating system and configuration for the host.',
'In Foreman, you can create an HTTP proxy and then assign the HTTP proxy to your EC2 compute resource.',
]
translated_strings = [
'An operating system is a collection of resources that define how Satellite server installs a base operating system on a host.', # Pr. Hosts: 2.3
'Installing the Infoblox CA certificate on Capsule server', # Pr. Hosts: 4.3
'In the Satellite web UI, navigate to Infrastructure > Capsules, select the Capsule with the DHCP Infoblox module, and ensure that the dhcp feature is listed.', # Pr. Hosts: 4.4
'Satellite Server automatically manages the PXE configuration, organizes networking services, and provides the operating system and configuration for the host.', # Pr. Hosts: 5.3
'In Satellite, you can create an HTTP proxy and then assign the HTTP proxy to your EC2 compute resource.', # Pr. Hosts: 14.4
]

test_strings.zip(translated_strings).each do |original, target|
assert_equal target, _(original)
end
end
end

0 comments on commit f78f229

Please sign in to comment.