-
Notifications
You must be signed in to change notification settings - Fork 18
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
Added script for updating messages and basic usage help for other message scripts #1000
base: clarin-dev
Are you sure you want to change the base?
Conversation
…r message scripts
Aha, also made the existing scripts independent of dspace-l10n-check.py, which is still python2 (and perhaps not worth updating?). |
Just to clarify: the scripts are now in Python 3. That's part of the reason why I've made them independent of the pre-existing dspace-l10n-check.py, which is still in python2. |
Does this deprecate dspace-l10n-check.py, can it be removed? |
I would say so. But that sort of assumes that users everywhere prefer my script. :)
It doesn't make anything on that page obsolete, but it does offer an extra (and I hope preferable) script for the last section: https://github.com/ufal/clarin-dspace/wiki/Language-localisation#checking-for-message-key-changes-when-upgrading. If you like, I can edit that section myself, but I'd ask you to test out my new script first yourself. |
Feel free to draft the wiki update here in the comments. I'll let you know if I got the desired output based on the draft. Does that sound ok? |
Right, I think you or Jozef pointed me to this script when I took this up. I added it and used it, but did not change it. So I agree and removed it.
Ok, I suggest this:
|
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.
@cyplas can you have a look at my review comments?
for element in message.xpath('descendant-or-self::*'): | ||
element.tag = element.tag[element.tag.index('}')+1:] |
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 do these lines do? Seems that you are looking for }
in the tag name?
moreover
sources/clarin-dspace$ (gh-merge/1000)> python utilities/project_helpers/scripts/update-message-xml-translations.py sl
Constructing temporary joint xml /tmp/messages-en.xml from all English messages.xml:
/mnt/c/Users/ko_ok/sources/clarin-dspace/dspace-xmlui/src/main/webapp/i18n/messages.xml
/mnt/c/Users/ko_ok/sources/clarin-dspace/dspace-xmlui/src/main/resources/aspects/SwordClient/i18n/messages.xml
/mnt/c/Users/ko_ok/sources/clarin-dspace/dspace-xmlui/src/main/resources/aspects/Discovery/i18n/messages.xml
/mnt/c/Users/ko_ok/sources/clarin-dspace/dspace-xmlui/src/main/resources/aspects/XMLWorkflow/i18n/messages.xml
Traceback (most recent call last):
File "utilities/project_helpers/scripts/update-message-xml-translations.py", line 42, in <module>
element.tag = element.tag[element.tag.index('}')+1:]
ValueError: substring not found
But I must say python utilities/project_helpers/scripts/update-message-xml-translations.py sl
finished on one of four runs, which is even more confusing
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.
Yeah, this is hacky, and, as your test runs indicate, not robust. Curly braces are used to wrap a namespace in tag names (e.g., "{http://apache.org/cocoon/i18n/2.1}message
"). In constructing the temporary joint English messages.xml (which is in check_message_lib.py, already from before), I had to deal with the fact that for some reason, some of the English messages.xml files have a default namespace (xmlns attribute) and others don't. But it looks like the order in which I construct the joint xml isn't deterministic (oops, set instead of list!), and that the namespace in the joint xml is not guaranteed. If and when this joint xml doesn't have a default namespace, your ValueError must be triggered.
Ok, I can fix the joint xml construction, and maybe it's best to make sure it does not have a namespace (since messages_cs.xml and messages_sl.xml don't). And then these lines can and must be removed.
|
||
import argparse | ||
import os | ||
import lxml.etree as lxml |
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'll be a bit nitpicky here, but do we need lxml
?
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.
Aha, probably not. I'll try without.
Main change: new script update-message-xml-translations.py, which may be handy on forks with other languages during upgrades.