@@plone_portal_state/language override for mockup translations - #5
@@plone_portal_state/language override for mockup translations#5petschki wants to merge 3 commits into
@@plone_portal_state/language override for mockup translations#5Conversation
plone_portal_state override for mockup translations@@plone_portal_state/language override for mockup translations
mauritsvanrees
left a comment
There was a problem hiding this comment.
Thanks @petschki !
Sorry, I did not have time to review this.
I added two minor comments, but I tested it and it works.
But this patch seems too broad. I don't think I want to get English reported as language everywhere. I am not sure where it could go wrong, but I don't trust it.
Ah, I have an example. The site where I want to use it is https://sfia-online.org. This site has been translated into 13 languages. Let's take this German page:
https://sfia-online.org/de/sfia-8/sfia-8.
This is the SFIA framework version 8. On the left you see "Das aktuelle Framework ist Version 9". So in English: "The current framework is version 9." The link is to the German version: de/sfia-9.
Now locally if I try your branch and am logged in as Manager, the link on the German page points to the English version: en/sfia-9. That is wrong.
This is in custom code, and I could change how this link is calculated, but I expect there are more places where this would be a problem.
So I now make a change in the main_template.pt that I was already customising in this project. In the html tag I make this change:
tal:attributes="
- lang lang;
+ lang context/@@editor-language;
"
And then I define this view:
<browser:page
name="editor-language"
for="*"
class=".views.EditorLanguage"
permission="zope.Public"
/>
and the class:
class EditorLanguage(BrowserView):
def __call__(self):
try:
language = get_editor_language(self.request)
if language:
return language
except Exception as e:
# Some defensive programming here
logger.error("Admin language force patch failed")
logger.exception(e)
return api.content.get_view(
name="plone_portal_state", context=self.context, request=self.request
).language()
That works for me.
This cannot be done in this add-on. Well, I could make a PR to add this view, if someone wants.
Anyway, summary: let's close this PR, as it makes a too large change.
| "qa", | ||
| "test", | ||
| "coverage", | ||
| "dependencies", |
There was a problem hiding this comment.
I would simply add the two missing dependencies to setup.py: Acquisition and plone.app.layout.
Actually, Acquisition would not be needed if we call super; see my next comment.
| return ( | ||
| self.request.get("LANGUAGE", None) | ||
| or aq_inner(self.context).Language() | ||
| or self.default_language() | ||
| ) |
There was a problem hiding this comment.
I would just call the super method:
| return ( | |
| self.request.get("LANGUAGE", None) | |
| or aq_inner(self.context).Language() | |
| or self.default_language() | |
| ) | |
| return super().language() |
And then we can remove the Acquisition import.
Just gave this a quick try to fix #3