8000 Validate single quotes in themes by ahus1 · Pull Request #37931 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Validate single quotes in themes - #37931

Merged
ahus1 merged 2 commits into
keycloak:mainfrom
ahus1:is-37930-check-single-quotes
Mar 17, 2025
Merged

ahus1 merged 2 commits into
keycloak:mainfrom
ahus1:is-37930-check-single-quotes

Conversation

@ahus1
@ahus1 ahus1 commented Mar 7, 2025
Copy link
Copy Markdown
Member

Closes #37930

@ahus1 ahus1 self-assigned this Mar 7, 2025
@ahus1
ahus1 force-pushed the is-37930-check-single-quotes branch from caa49cc to c3f1d43 Compare March 7, 2025 21:25
@ahus1
ahus1 commented Mar 7, 2025
Copy link
Copy Markdown
Member Author

@jonkoops: can you please comment on my change in the frontend that would prevent showing double quotes?

Thanks!

cc: @robson90

@ahus1
ahus1 requested a review from jonkoops March 7, 2025 21:26
@ahus1
ahus1 force-pushed the is-37930-check-single-quotes branch 3 times, most recently from e48891a to 8831a24 Compare March 10, 2025 13:35
@ahus1
ahus1 marked this pull request as ready for review March 10, 2025 14:48
@ahus1
ahus1 requested review from a team as code owners March 10, 2025 14:48
Comment thread js/apps/account-ui/src/i18n.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think rather than solving this here on the front-end the API should normalize these values. This will avoid other consumers from having to do the same.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was thinking the same first, but then wasn't sure if someone might want to use the original Java Messageformat to do a replacement. WDYT - should I still do it only in the backend?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My vote is to do it on the backend. Unless I am somehow misunderstanding the formatting here. What is the purpose of the double ''? I thought it was properties file specific trait, and not related to MessageFormat.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The '' is related to MessageFormat only, that is when you have placeholders in the string. Not all strings in the property file are then processed by a MessageFormat.

The logic of MessageFormat in a nutshell: If you want to escape a something that would normally be a placeholder, put it in single quotes. It will then be printed without the single quotes. If you then want to print one single quote, have two single quotes in the original string.

I assume no-one is consume this strings except the original admin UI and account UI, so it doesn't really matter. I'll move it to the backend in the next commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, sounds like it can be handled in the API then. At some point we should really look to unify these messages. There is a standard MessageFormat API proposal in the works for JavaScript that will implement the MessageFormat 2 standard.

@ahus1
ahus1 force-pushed the is-37930-check-single-quotes branch from 8831a24 to a2803c4 Compare March 16, 2025 13:07
@ahus1
ahus1 marked this pull request as draft March 16, 2025 13:08
@ahus1
ahus1 marked this pull request as ready for review March 17, 2025 07:24
@ahus1
ahus1 commented Mar 17, 2025
Copy link
Copy Markdown
Member Author

@jonkoops - I gave it a thought to convert the message resources on the backend, but then it would affect all resource themes, not only those used in the React UI.

So I chose to update the docs that in Admin/Account UI theme you MUST NOT use '', while you MUST use '' in the base themes.

WDYT? I think it is a step in the right direction, but there is a lot more to clean up around translations...

@ahus1
ahus1 requested a review from jonkoops March 17, 2025 07:26
jonkoops
jonkoops previously approved these changes Mar 17, 2025
@jonkoops jonkoops left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with the approach of using the MessageFormat syntax only for the Java related messages and adding some instructions. Long-term, we need to reach an agreement on a unified format for translations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As per the mailing list, we no longer need to include copyright notices in every file.

@ahus1
ahus1 commented Mar 17, 2025
Copy link
Copy Markdown
Member Author

Thank you for the approval of this next step in the journey. There are some conflicts that I need to resolve. As this one is touching a lot of files, I've now locked the Weblate translations. Once the last Weblate changes are merged, I'll rebase this one.

Once this PR is merged, I'll unlock Weblate.

ahus1 added 2 commits March 17, 2025 12:55
Closes keycloak#37930

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
Closes keycloak#37930

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
@ahus1
ahus1 force-pushed the is-37930-check-single-quotes branch from a2803c4 to b2d477f Compare March 17, 2025 11:57
@ahus1
ahus1 merged commit 7aa5130 into keycloak:main Mar 17, 2025
@ahus1
ahus1 commented Mar 17, 2025
Copy link
Copy Markdown
Member Author

@jmallach / @Ecron / @EdoardoTona / @GioviQ:

With this change in place, you now need to check where you add quotes: While typographic quotes are preferred, it is ' in the Admin UI and Account UI, and '' in the basic themes. Let me know if you have questions around that.
I hope we can in the future have a more aligned process around that.

8BD0

@jmallach
Copy link
Copy Markdown
Contributor

Thanks for this specific clarification: people were saying all around that '' was always needed, but it was clearly not the case.

We should try to search&replace all apostrophe's in our Catalan translations to use ‘ instead, and use ' only where it is really needed.

@ahus1
ahus1 commented Mar 17, 2025
Copy link
Copy Markdown
Member Author

@jmallach - we are learning and are untangling this bit by bit. Sometimes we might take a detour, or correct previous assumptions. We try to keep the translation.md file up-to-date as we go.

To do the search-and-replace, you can choose to create a pull request for the files if you don't want to use the UI for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent use of single quotes in message resources

4 participants

0