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

Add language column in import export #407

Merged
merged 6 commits into from
Jan 30, 2025

Conversation

Hlamallama
Copy link
Contributor

@Hlamallama Hlamallama commented Jan 28, 2025

Purpose

Why does this exist?

Solution

_What changed, and does this address the problem? _

Checklist

  • Added or updated unit tests
  • Added to release notes
  • Updated readme/documentation (if necessary)

home/export_content_pages.py Show resolved Hide resolved
export_lang_code = ""
for lang_code, lang_dn in get_content_languages().items():
if lang_dn == str(page.locale):
export_lang_code = lang_code
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not just do page.locale.language_code to get the language code for the current page?

@@ -268,7 +268,10 @@ def create_content_page_index_from_row(self, row: "ContentRow") -> None:
def create_shadow_content_page_from_row(
self, row: "ContentRow", row_num: int
) -> None:
locale = self.locale_from_display_name(row.locale)
if row.language_code:
locale = locale = Locale.objects.get(language_code=row.language_code)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if no Locale exists for the language code given in the row? In that case, we should raise an ImportException, similar to how locale_from_display_name does.

1. Quit tobacco 🚭
_Stop smoking with the help of a guided, 42-day program._
2. Manage your stress 🧘🏽‍♀️
_Learn how to cope with stress and improve your wellbeing._",,,3e5d77f7-4d34-430d-aad7-d9ca01f79732,self_help,,,English,,[],,,,,,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need so much and so long content for this test? Maybe we can reduce it to just what is necessary, so that it's easier to see what we're testing here.

@@ -208,6 +210,11 @@ def _export_content_page(self, page: ContentPage, structure: str) -> None:
* We should use the parent slug (which is expected to be unique per
locale (probably?)) instead of the parent title.
"""
export_lang_code = ""
for lang_code, lang_dn in get_content_languages().items():
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not just content pages that need language codes, it's also content index pages.

home/export_content_pages.py Show resolved Hide resolved
Copy link
Contributor

@rudigiesler rudigiesler left a comment

Choose a reason for hiding this comment

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

Looks good! Just one tiny comment, and then could we add this to CHANGELOG.md in this PR?

Then we'll also need to update the docs. Those are in the wiki though, so not something we can do in this PR, so will have to be done after merging this.

@@ -252,7 +259,7 @@ def create_content_page_index_from_row(self, row: "ContentRow") -> None:
# but optional for the default locale.
if row.translation_tag or locale != self.default_locale():
index.translation_key = row.translation_tag
locale = self.locale_from_display_name(row.locale)
# locale = self.locale_from_display_name(row.locale)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this line instead of commenting it out

@Hlamallama Hlamallama merged commit dbde0a0 into main Jan 30, 2025
2 checks passed
@Hlamallama Hlamallama deleted the add-language-column-in-import-export branch January 30, 2025 10:30
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

Successfully merging this pull request may close these issues.

2 participants