-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
home/export_content_pages.py
Outdated
export_lang_code = "" | ||
for lang_code, lang_dn in get_content_languages().items(): | ||
if lang_dn == str(page.locale): | ||
export_lang_code = lang_code |
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.
Can we not just do page.locale.language_code
to get the language code for the current page?
home/import_content_pages.py
Outdated
@@ -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) |
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.
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,,[],,,,,, |
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.
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.
home/export_content_pages.py
Outdated
@@ -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(): |
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.
It's not just content pages that need language codes, it's also content index pages.
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.
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.
home/import_content_pages.py
Outdated
@@ -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) |
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.
We can remove this line instead of commenting it out
Purpose
Why does this exist?
Solution
_What changed, and does this address the problem? _
Checklist