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

Abstract out repetitive localization code #6727

Open
andrewdavidwong opened this issue Jun 22, 2021 · 0 comments
Open

Abstract out repetitive localization code #6727

andrewdavidwong opened this issue Jun 22, 2021 · 0 comments
Labels
C: website P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: enhancement Type: enhancement. A new feature that does not yet exist or improvement of existing functionality.

Comments

@andrewdavidwong
Copy link
Member

andrewdavidwong commented Jun 22, 2021

The problem you're addressing (if any)

There's a repetitive code pattern in the new localization code (website repo). Here's a grep of the first line of it:

$ grep -r --exclude-dir=_site --exclude-dir=.git '% if page.lang'
_includes/sec-qsb.html:{% if page.lang == nil or page.lang == "en" %}
_includes/doc-alert-advanced.html:{% if page.lang == nil or page.lang == "en" %}
_includes/header.html:        {% if page.lang == nil or page.lang == "en" %}
_includes/style-guide.html:{% if page.lang == nil or page.lang == "en" %}
_includes/doc-widget.html:{% if page.lang == nil or page.lang == "en" %}
_includes/doc-widget.html:{% if page.lang == nil or page.lang == "en" %}
_includes/downloads.html:{% if page.lang == nil or page.lang == "en" %}
_includes/head.html:{% if page.lang %}
_includes/doc-content.html:{% if page.lang == nil or page.lang == "en" %}
_includes/news-categories.html:{% if page.lang == nil or page.lang == "en" %}
_includes/team.html:{% if page.lang == nil or page.lang == "en" %}
_includes/news-widget.html:{% if page.lang == nil or page.lang == "en" %}
_includes/doc-alert-translated.html:{% if page.lang == nil or page.lang == "en" %}
_includes/team-simple.html:{% if page.lang == nil or page.lang == "en" %}
_includes/home-news.html:{% if page.lang == nil or page.lang == "en" %}
_includes/doc-alert-external.html:{% if page.lang == nil or page.lang == "en" %}
_includes/experts.html:{% if page.lang == nil or page.lang == "en" %}
_includes/sec-xsa.html:{% if page.lang == nil or page.lang == "en" %}
_includes/news-heading.html:{% if page.lang == nil or page.lang == "en" %}
_includes/news.html:{% if page.lang == nil or page.lang == "en" %}
_includes/sec-canary.html:{% if page.lang == nil or page.lang == "en" %}
_includes/team-heading.html:{% if page.lang == nil or page.lang == "en" %}
_includes/heading.html:    {% if page.lang == nil or page.lang == "en" %}
_includes/hcl.html:{% if page.lang == nil or page.lang == "en" %}
_includes/doc-index.html:{% if page.lang == nil or page.lang == "en" %}
_includes/footer.html:{% if page.lang == nil or page.lang == "en" %}
_includes/doc-heading.html:{% if page.lang == nil or page.lang == "en" %}
_includes/news-post-author.html:{% if page.lang == nil or page.lang == "en" %}

As you can see, this pattern gets repeated a lot, and the whole thing is usually around 10 lines long.

The subsequent lines usually follow a similar pattern to each other but are not exactly the same each time, so it isn't a simple matter of deduplication.

Describe the solution you'd like

@maiska, would you mind taking a look to see if there's a way to abstract this out into an include so that it's not repeated so many times?

Where is the value to a user, and who might that user be?

Code duplication makes things more difficult for website contributors and maintainers. By practicing DRY, we make it easier for people to collaborate on the website codebase.

Describe alternatives you've considered

None.

Additional context

Discovered while refactoring and cleaning up the website code (QubesOS/qubesos.github.io@72f41a0 and surrounding commits).

Relevant documentation you've consulted

Newly-added section, based on recent refactoring and cleanup experience:

https://www.qubes-os.org/doc/doc-guidelines/#coding-conventions

Related, non-duplicate issues

None found.

@andrewdavidwong andrewdavidwong added T: enhancement Type: enhancement. A new feature that does not yet exist or improvement of existing functionality. C: website P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. labels Jun 22, 2021
@andrewdavidwong andrewdavidwong added this to the Ongoing milestone Jun 22, 2021
@andrewdavidwong andrewdavidwong removed this from the Non-release milestone Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: website P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: enhancement Type: enhancement. A new feature that does not yet exist or improvement of existing functionality.
Projects
None yet
Development

No branches or pull requests

1 participant