In this page I found some nice ideas about translation in context: https://docs.moodle.org/dev/Languages_subsystem_improvements_2.0
Since the page is a bit long, I am quoting here the relevant parts:
[begin_quote]
From Martin in Dev chat: if you want crazy ideas, how about get_string returns some special tags and those tags get converted to ajax on the GUI so that translators can translate directly in the main Moodle GUI?
What a cool idea. Could be a special mode you have to turn on in the admin screens. Perhaps even if you turned this mode on, it would still only be active for people with certain roles, or perhaps when it was turned on, it would have to apply to all roles, so that you could edit strings for not-logged-in users. Anyway, when this mode was on, it would:
- Adds <span class="moodle-lang-string" id="lang_string|admin|langedit">Language editing</span> around each string on the page - to use one example.
- $PAGE->requires->js an extra JS file that adds an on-click handler to all such spans, so that when you click on it, it pops up the language editing UI in a YUI dialogue.
- David Mudrak 14:07, 23 November 2009 (UTC): the solution based on wrapping <span> around every string was already considered and dropped. It may badly break XHTML as the string itself may appear as a value of an HTML tag's attribute:
<img title="<span class="moodle-lang-string" ...
. We are unable to say the scope where the string will appear. - David's contra-proposal: get_string() could track all strings used at the current page and the AJAX form to edit them all could be rendered before the footer(). Or 'Edit system text on this page' link would appear there.
- [end_quote]
- Both of them are very good ideas. The first one is not impossible if you add an additional parameter to get_string() which tell it something about the scope where it is being used.
- The second idea (David's contra-proposal) is a very nice one as well and apparently it does not have any technical difficulties for being implemented. What happened to it? Did it get implemented?
- I think that translation in context is very important for the accuracy of translations.
- David Mudrak 14:07, 23 November 2009 (UTC): the solution based on wrapping <span> around every string was already considered and dropped. It may badly break XHTML as the string itself may appear as a value of an HTML tag's attribute: