-
Notifications
You must be signed in to change notification settings - Fork 328
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
BUG - Fix i18n files and compilation for distribution #2042
Conversation
@@ -75,7 +75,7 @@ jobs: | |||
# if not we use the default version | |||
# example substitution: tox run -e compile-assets,i18n-compile,py39-tests | |||
else | |||
python -Im tox run -e compile,i18n-compile,py$(echo ${{ matrix.python-version }} | tr -d .)-tests | |||
python -Im tox run -e compile-assets,i18n-compile,py$(echo ${{ matrix.python-version }} | tr -d .)-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For whatever reason I had missed this when renaming to compile-assets
@@ -82,7 +82,7 @@ file, and visible to localizers. For example: | |||
|
|||
{# L10n: Navigation button at the bottom of the page #} | |||
<button type="button"> | |||
{{- _("Next page") -}} | |||
{{- _('Next page') -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit as we use single quotes in a lot of our localisable strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice detective work. There are some things I don't understand, so I left some questions inline.
webpack.config.js
Outdated
@@ -170,3 +172,21 @@ module.exports = { | |||
topLevelAwait: true, | |||
}, | |||
}; | |||
|
|||
module.exports = (env, argv) => { | |||
// since STB isolates the build, we need to compile the translations here for releases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide a link in this code comment to more info? What does it mean that STB isolates the build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under the hood stb
uses build
for perform stb package
(which in turn calls python -m build
).
build
builds the package in an isolated env to create the source distribution (https://build.pypa.io/en/stable/)
That means, when compiling assets from tox
(or even doing npm run build
during development or in our CI) it would result in something like
# note I added a simple console print to demonstrate
Webpack is building the theme in my-local-dir/pydata-sphinx-theme/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static
Locale will be located in my-local-dir/pydata-sphinx-theme/src/pydata_sphinx_theme/locale
When calling via stb package
or python -m build
(which is what we do to build the dist) this is instead
Webpack is building the theme in /private/var/folders/6p/062gm41556s5p63x1555cjzw0000gn/T/build-via-sdist-rmc_7ti7/pydata_sphinx_theme-0.16.1.dev0/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static
Locale will be located in /private/var/folders/6p/062gm41556s5p63x1555cjzw0000gn/T/build-via-sdist-rmc_7ti7/pydata_sphinx_theme-0.16.1.dev0/src/pydata_sphinx_theme/locale
so if you compile the translation files first with tox run -e i18n-compile
then the compiled .mo
will not be included in the distribution files by default (this isolation helps to avoid unwanted files and what not to be added to the distribution packages afterall)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked that this brought in new translations on a test Sphinx site of my own, so this seems to be working.
However, I do have one concern about pybabel sending output to stderr (see inline comment).
Co-authored-by: gabalafou <[email protected]>
@gabalafou, I needed to re-request a review since I added your suggestion. |
While investigating #2040 I noticed that our current release missed the updated
.mo
files.This was a bug I introduced in #1959 when reworking the localisation workflows.
TLD;R—Since we use
stb
to build the theme, I did not realise that compiling the i18n files had to be done within thestb package
(I removed it from the webpack file as this was causing the infinite reload while working on our docs).Since this was an easy miss, I added our build and inspect job to the
pre-release
workflow that runs on a chron job to check our build process periodically.Once we merge this, we can make a small release to patch the current issue.