Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javadoc generated in English has German language indicated in HTML tag #1048

Closed
mminella opened this issue Apr 6, 2020 · 3 comments
Closed
Assignees

Comments

@mminella
Copy link
Member

mminella commented Apr 6, 2020

The generated javadoc for Spring Data Mongodb (although I have not checked the other Spring Data projects), is generating the HTML tag with the de language. This causes Chrome to think it's in German and ask users if they want it translated. This lang attribute should either be changed to the actual language or removed entirely.

@odrotbohm odrotbohm self-assigned this Apr 6, 2020
@odrotbohm
Copy link
Member

Setting the Javadoc locale flag to en_US should do the trick here. Great catch!

@odrotbohm odrotbohm added this to the 2.3 RC2 (Neumann) milestone Apr 6, 2020
odrotbohm added a commit that referenced this issue Apr 6, 2020
Not setting the Javadoc's locale explicitly has cause the release building machine's local to end up as lang attribute in the HTML tag. Most releases build by folks in Germany, the "de" value causes browsers to suggest to translate the page content from German into the user's browser language in case that's not German in the first place. We now explicitly set the value to en_US, as we know the content is English anyway.

Getting this fixed has been a bit of a ride as it takes a special way of convincing the Javadoc tool actually receive the locale attribute. For whatever reason, the locale attribute needs to be the first attribute piped to the Javadoc tool (yeah, exactly^^), which is at odds with our usage of the <additionalJOptions /> usage to disable Javadoc linting. The options always appear *before* any other attributes handed to the Javadoc tool and thus caused the build to fail with:

javadoc: error - option -locale must be first on the command line.

Switching to rather use <additionalOptions /> (note the missing J) seems to pipe the attributes into the Javadoc tool in the order it would like to receive them.
mp911de pushed a commit that referenced this issue Apr 8, 2020
Not setting the Javadoc's locale explicitly has cause the release building machine's local to end up as lang attribute in the HTML tag. Most releases build by folks in Germany, the "de" value causes browsers to suggest to translate the page content from German into the user's browser language in case that's not German in the first place. We now explicitly set the value to en_US, as we know the content is English anyway.

Getting this fixed has been a bit of a ride as it takes a special way of convincing the Javadoc tool actually receive the locale attribute. For whatever reason, the locale attribute needs to be the first attribute piped to the Javadoc tool (yeah, exactly^^), which is at odds with our usage of the <additionalJOptions /> usage to disable Javadoc linting. The options always appear *before* any other attributes handed to the Javadoc tool and thus caused the build to fail with:

javadoc: error - option -locale must be first on the command line.

Switching to rather use <additionalOptions /> (note the missing J) seems to pipe the attributes into the Javadoc tool in the order it would like to receive them.
mp911de pushed a commit that referenced this issue Apr 8, 2020
Not setting the Javadoc's locale explicitly has cause the release building machine's local to end up as lang attribute in the HTML tag. Most releases build by folks in Germany, the "de" value causes browsers to suggest to translate the page content from German into the user's browser language in case that's not German in the first place. We now explicitly set the value to en_US, as we know the content is English anyway.

Getting this fixed has been a bit of a ride as it takes a special way of convincing the Javadoc tool actually receive the locale attribute. For whatever reason, the locale attribute needs to be the first attribute piped to the Javadoc tool (yeah, exactly^^), which is at odds with our usage of the <additionalJOptions /> usage to disable Javadoc linting. The options always appear *before* any other attributes handed to the Javadoc tool and thus caused the build to fail with:

javadoc: error - option -locale must be first on the command line.

Switching to rather use <additionalOptions /> (note the missing J) seems to pipe the attributes into the Javadoc tool in the order it would like to receive them.
@mp911de mp911de closed this as completed Apr 8, 2020
@kriegaex
Copy link

kriegaex commented Feb 1, 2024

I just noticed in another project that this seems to be broken again in JDK 20+ after having been fixed for JDK 15. Can you verify and confirm? For me, this switch has no effect on JDK 21. See https://bugs.openjdk.org/browse/JDK-8222793.

Actually, it is broken on 19+, not 20+. I just checked for myself, rather than believing what the last comment in the JDK issue says. The workaround is to set JAVA_TOOL_OPTIONS='-Duser.language=en -Duser.country=US' instead of relying on the Javadoc language option. But that always prints the value of the environment variable on the console, which might upset tests verifying console output in other cases during a build.

@kriegaex
Copy link

kriegaex commented Feb 1, 2024

I am too busy for contributing a PR just now, but found this workaround for my project that does not require setting JAVA_TOOL_OPTIONS, hoping it also helps you:

<!--
  Avoid non-English javadoc generation. Due to https://bugs.openjdk.org/browse/JDK-8222793 reoccurring at
  least in JDKs 19-21 and also being broken in some older JDKs, we cannot rely on just setting the locale
  parameter, but also need the 'user.language' and 'user.country' parameters in 'additionalJOptions' as a
  workaround.
-->
<locale>en</locale>
<additionalJOptions>
  <additionalJOption>-J-Dfile.encoding=UTF-8</additionalJOption>
  <additionalJOption>-J-Duser.language=en</additionalJOption>
  <additionalJOption>-J-Duser.country=US</additionalJOption>
</additionalJOptions>

See also eclipse-aspectj/aspectj@0cba9d1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants