-
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
Add test for internationalization and translations #1138
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -787,3 +787,62 @@ def test_empty_templates(sphinx_build_factory): | |
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build() | ||
toc_items = sphinx_build.html_tree("page1.html").select(".toc-item") | ||
assert not any(ii.select(".tocsection.sourcelink") for ii in toc_items) | ||
|
||
|
||
def test_translations(sphinx_build_factory): | ||
"""Test that basic translation functionality works. | ||
|
||
This will build our test site with the French language, and test | ||
that a few phrases are in French. | ||
|
||
TODO: At first, we expect some of these phrases to be *incorrectly* in | ||
English. This is because we haven't added translation files for them. | ||
We should change this test to the appropriate French versions once we add | ||
support for other languages. | ||
|
||
Then, we use this test to catch regressions if we change wording without | ||
changing the translation files.""" | ||
|
||
confoverrides = { | ||
"language": "fr", | ||
"html_context": { | ||
"github_user": "pydata", | ||
"github_repo": "pydata-sphinx-theme", | ||
"github_version": "main", | ||
}, | ||
"html_theme_options": { | ||
"use_edit_page_button": True, | ||
}, | ||
} | ||
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build() | ||
|
||
# Use a section page so that we have section navigation in the sidebar | ||
index = sphinx_build.html_tree("section1/index.html") | ||
|
||
# TODO: Add translations where there are english phrases below | ||
sidebar_primary = index.select(".bd-sidebar-primary")[0] | ||
assert "Site Navigation" in str(sidebar_primary) | ||
assert "Section Navigation" in str(sidebar_primary) | ||
|
||
# TODO: Add translations where there are english phrases below | ||
sidebar_secondary = index.select(".bd-sidebar-secondary")[0] | ||
assert "Montrer le code source" in str(sidebar_secondary) | ||
assert "Edit this page" in str(sidebar_secondary) | ||
|
||
# TODO: Add translations where there are english phrases below | ||
header = index.select(".bd-header")[0] | ||
assert "light/dark" in str(header) | ||
|
||
# TODO: Add translations where there are english phrases below | ||
footer = index.select(".bd-footer")[0] | ||
assert "Copyright" in str(footer) | ||
assert "Created using" in str(footer) | ||
assert "Built with the" in str(footer) | ||
|
||
footer_article = index.select(".bd-footer-article")[0] | ||
assert "précédent" in str(footer_article) | ||
assert "suivant page" in str(footer_article) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here it should just be "Suivant" or "Page suivante" |
||
|
||
# Search bar | ||
# TODO: Add translations where there are english phrases below | ||
assert "Search the docs" in str(index.select(".bd-search")[0]) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this a translation that you came up with or is it from sphinx?
I'm a native speaker and that sounds very weird compared to "Voir code source"
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 believe this is just what sphinx spat out - was not my translation! Another good reason to add out own translations? 🙂