Skip to content

Commit a3af12c

Browse files
ahus1pedroigor
authored andcommitted
Avoid surplus blanks in source strings
Closes #37582 Signed-off-by: Alexander Schwartz <[email protected]>
1 parent 873d363 commit a3af12c

File tree

7 files changed

+95
-36
lines changed

7 files changed

+95
-36
lines changed

js/apps/account-ui/maven-resources/theme/keycloak.v3/account/messages/messages_en.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ systemDefined=System defined
148148
hasAccessTo=Has access to
149149
internalApp=Internal
150150
updateError=Could not update the resource due to\: {{error}}
151-
accessGrantedOn=Access granted on\:
151+
accessGrantedOn=Access granted on\:
152152
editTheResource=Edit the resource - {{name}}
153153
permissionRequests=Permission requests
154154
shareSuccess=Resource successfully shared.
@@ -164,7 +164,7 @@ termsOfService=Terms of service
164164
jumpToSection=Jump to section
165165
linkError=Could not link due to\: {{error}}
166166
requestor=Requestor
167-
shareWith=Share with
167+
shareWith=Share with
168168
updateCredAriaLabel=Update credential
169169
error-pattern-no-match='{{0}}' doesn't match required format.
170170
application=Application

js/apps/account-ui/src/resources/ShareTheResource.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export const ShareTheResource = ({
177177
</InputGroupItem>
178178
</InputGroup>
179179
{fields.length > 1 && (
180-
<ChipGroup categoryName={t("shareWith")}>
180+
<ChipGroup categoryName={t("shareWith") + " "}>
181181
{fields.map(
182182
(field, index) =>
183183
index !== fields.length - 1 && (

js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties

Lines changed: 26 additions & 26 deletions
Large diffs are not rendered by default.

misc/theme-verifier/src/main/java/org/keycloak/themeverifier/VerifyMessageProperties.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public List<String> verify() throws MojoExecutionException {
4949
String contents = Files.readString(file.toPath());
5050
verifyNoDuplicateKeys(contents);
5151
verifySafeHtml();
52+
verifyProblematicBlanks();
5253
} catch (IOException e) {
5354
throw new MojoExecutionException("Can not read file " + file, e);
5455
}
@@ -114,6 +115,39 @@ private void verifySafeHtml() {
114115
});
115116
}
116117

118+
/**
119+
* Double blanks and blanks at the beginning of end of the string are difficult to translation in the translation tools and
120+
* are easily missed. If a blank before or after the string is needed in the UI, add it in the HTML template.
121+
*/
122+
private void verifyProblematicBlanks() {
123+
if (!file.getName().endsWith("_en.properties")) {
124+
// Only check EN original files, as the other files are checked by the translation tools
125+
return;
126+
}
127+
PropertyResourceBundle bundle;
128+
try (FileInputStream fis = new FileInputStream(file)) {
129+
bundle = new PropertyResourceBundle(fis);
130+
} catch (IOException e) {
131+
throw new RuntimeException("unable to read file " + file, e);
132+
}
133+
134+
bundle.getKeys().asIterator().forEachRemaining(key -> {
135+
String value = bundle.getString(key);
136+
137+
if (value.contains(" ")) {
138+
messages.add("Duplicate blanks in " + key + " for file " + file + ": '" + value);
139+
}
140+
141+
if (value.startsWith(" ")) {
142+
messages.add(key + " starts with a blank in file " + file + ": '" + value);
143+
}
144+
145+
if (value.endsWith(" ")) {
146+
messages.add(key + " ends with a blank in file " + file + ": '" + value);
147+
}
148+
});
149+
}
150+
117151
private String normalizeValue(String key, String value) {
118152
if (key.equals("templateHelp")) {
119153
// Allow "CLAIM.<NAME>" here

misc/theme-verifier/src/test/java/org/keycloak/themeverifier/VerifyMessagePropertiesTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ void verifyNoChangedAnchors() throws MojoExecutionException {
5151
MatcherAssert.assertThat(verify, Matchers.hasItem(Matchers.containsString("Didn't find anchor tag")));
5252
}
5353

54+
@Test
55+
void verifyNoExtraBlanks() throws MojoExecutionException {
56+
List<String> verify = getFile("blanks_en.properties").verify();
57+
MatcherAssert.assertThat(verify, Matchers.hasItem(Matchers.containsString("Duplicate blanks")));
58+
MatcherAssert.assertThat(verify, Matchers.hasItem(Matchers.containsString("starts with a blank")));
59+
MatcherAssert.assertThat(verify, Matchers.hasItem(Matchers.containsString("ends with a blank")));
60+
}
61+
5462
private static VerifyMessageProperties getFile(String fixture) {
5563
URL resource = VerifyMessageProperties.class.getResource("/" + fixture);
5664
if (resource == null) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright 2025 Red Hat, Inc. and/or its affiliates
3+
# and other contributors as indicated by the @author tags.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
key=\ word word\

themes/src/main/resources/theme/base/login/messages/messages_en.properties

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ errorDeletingAccount=Error happened while deleting account
2020
deletingAccountForbidden=You do not have enough permissions to delete your own account, contact admin.
2121
kerberosNotConfigured=Kerberos Not Configured
2222
kerberosNotConfiguredTitle=Kerberos Not Configured
23-
bypassKerberosDetail=Either you are not logged in by Kerberos or your browser is not set up for Kerberos login. Please click continue to login in through other means
24-
kerberosNotSetUp=Kerberos is not set up. You cannot login.
23+
bypassKerberosDetail=Either you are not logged in by Kerberos or your browser is not set up for Kerberos login. Please click continue to login in through other means
24+
kerberosNotSetUp=Kerberos is not set up. You cannot login.
2525
registerTitle=Register
2626
loginAccountTitle=Sign in to your account
2727
loginTitle=Sign in to {0}
@@ -33,13 +33,13 @@ unknownUser=Unknown user
3333
loginTotpTitle=Mobile Authenticator Setup
3434
loginProfileTitle=Update Account Information
3535
loginIdpReviewProfileTitle=Update Account Information
36-
loginTimeout=Your login attempt timed out. Login will start from the beginning.
36+
loginTimeout=Your login attempt timed out. Login will start from the beginning.
3737
reauthenticate=Please re-authenticate to continue
3838
authenticateStrong=Strong authentication required to continue
3939
oauthGrantTitle=Grant Access to {0}
4040
oauthGrantTitleHtml={0}
4141
oauthGrantInformation=Make sure you trust {0} by learning how {0} will handle your data.
42-
oauthGrantReview=You could review the
42+
oauthGrantReview=You could review the
4343
oauthGrantTos=terms of service.
4444
oauthGrantPolicy=privacy policy.
4545
errorTitle=We are sorry...
@@ -373,7 +373,7 @@ credentialSetupRequired=Cannot login, credential setup required.
373373
identityProviderNotUniqueMessage=Realm supports multiple identity providers. Could not determine which identity provider should be used to authenticate with.
374374
emailVerifiedMessage=Your email address has been verified.
375375
emailVerifiedAlreadyMessage=Your email address has been verified already.
376-
staleEmailVerificationLink=The link you clicked is an old stale link and is no longer valid. Maybe you have already verified your email.
376+
staleEmailVerificationLink=The link you clicked is an old stale link and is no longer valid. Maybe you have already verified your email.
377377
identityProviderAlreadyLinkedMessage=Federated identity returned by {0} is already linked to another user.
378378
confirmAccountLinking=Confirm linking the account {0} of identity provider {1} with your account.
379379
confirmEmailAddressVerification=Confirm validity of e-mail address {0}.
@@ -415,7 +415,7 @@ console-otp=One Time Password:
415415
console-new-password=New Password:
416416
console-confirm-password=Confirm Password:
417417
console-update-password=Update of your password is required.
418-
console-verify-email=You need to verify your email address. We sent an email to {0} that contains a verification code. Please enter this code into the input below.
418+
console-verify-email=You need to verify your email address. We sent an email to {0} that contains a verification code. Please enter this code into the input below.
419419
console-email-code=Email Code:
420420
console-accept-terms=Accept Terms? [y/n]:
421421
console-accept=y
@@ -429,7 +429,7 @@ openshift.scope.list-projects=List projects
429429
# SAML authentication
430430
saml.post-form.title=Authentication Redirect
431431
saml.post-form.message=Redirecting, please wait.
432-
saml.post-form.js-disabled=JavaScript is disabled. We strongly recommend to enable it. Click the button below to continue.
432+
saml.post-form.js-disabled=JavaScript is disabled. We strongly recommend to enable it. Click the button below to continue.
433433
saml.artifactResolutionServiceInvalidResponse=Unable to resolve artifact.
434434

435435
#authenticators

0 commit comments

Comments
 (0)