Problem/Motivation
When you have a lot of translated strings, it would be helpful to drill down by context, to allow a user to only see specific groups of strings.
Proposed resolution
Drupal allows any reference to the t() function to provide an optional context as a parameter (see Translation string sharing and context).
For example something like this:
// PHP code
t('May', array(), array('context' => 'Long month name');
\Drupal::translation()->formatPlural($count, '1 something',
'@count somethings', array(), array('context' => 'My context'));
I propose adding the ability to filter based on a list of defined contexts in the system.
Remaining tasks
Write Functionality
Update Tests
Add Screenshot
User interface changes
- Adds a "context" filter to the locale source plugin UI.
- Adds a "context" column to the local source plugin table results.
API changes
None
Data model changes
None
Comments
Comment #2
WidgetsBurritos commentedI am presently working on a patch to introduce this functionality.
Comment #3
WidgetsBurritos commentedHere is an initial patch with what I'm proposing
Comment #4
WidgetsBurritos commentedI actually updated my previous patch a little bit, to also show context in the table itself, as it helps provide clarity between different instances of the same string.
Comment #5
WidgetsBurritos commentedComment #6
WidgetsBurritos commentedUpdating the issue summary. As these are merely UI changes, not sure there's much to test, unless we want some browser test cases, but adding that to the list just in case.
Comment #8
WidgetsBurritos commentedWell those test failures answered my question about UI test cases. So I've gone ahead and updated the tests to reflect both that context is visible in the table, and that filtering by context works.
Comment #9
WidgetsBurritos commentedHere is a screenshot of what this might look like:

Comment #11
berdirNice work, nothing to complain about except the use of $_GET, but lets clean up all usages of that at once in a separate issue. Patches for that very welcome :)
Comment #12
WidgetsBurritos commentedFor sure about those $_GET references. I just didn’t want to break the established convention here. When I get a chance I’ll be happy to help clean some of that up