i18n_string translations could be handled by this module. The https://drupal.org/project/language_fallback module's 7.x-2.x branch does this, so I've created the attached patch that is based on the code from there.
To be honest, these two projects ought to merge probably. Language Hierarchy seems to me to use the most sensible approach generally, but doesn't quite cover all the same areas as Language Fallback's 7.x-2.x branch. But that's covered over in #2145151: Consider deprecating language_hierarchy in favor of entity_language_fallback.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | language-hierarchy-i18n_strings-2565711-11.patch | 20.96 KB | james.williams |
| #11 | language-hierarchy-i18n_strings-2565711-11-only-tests.patch | 5.63 KB | james.williams |
Comments
Comment #2
james.williamsSorry, that last patch missed the new class file. Take 2!
Comment #3
rafalenden commentedComment #4
james.williamsFixed a PHP notice caused by a slight difference between language hierarchy ancestors behaviour and language fallback chain behaviour.
Comment #5
steven jones commentedThis could do with some tests.
Comment #6
steven jones commentedAdding a tag so someone at ComputerMinds can pick this up.
Comment #7
james.williamsSince i18n 7.x-1.12, there is a i18n_string_textgroup_cached class that is used instead of i18n_string_textgroup_default for some i18n string objects (namely, fields), which the above patch(es) will not touch. A solution for language fallback (or at least Amazee Labs' fork of it) exists here: https://github.com/AmazeeLabs/language_fallback/commit/4fadff1ac937c11c7... - given that our patches are based on the Language Fallback work, this work would probably do the trick for LH too.
https://github.com/AmazeeLabs/language_fallback/commit/014d877040cfd9133... might also be necessary too, I'm not sure.Comment #8
james.williamsHere's a patch that includes support for the cached strings, based on the work mentioned above. Still needs tests, but one thing at a time, eh? :-)
Comment #9
james.williamsAnd here's a patch that actually tests our use of i18n_string, based on the tests in i18n_string itself and the existing LH tests :-)
Comment #10
steven jones commented@james.williams thanks very much for the patch and tests!
Could you provide a patch that has just the tests please, and not the fix/feature then we can see that the tests do indeed catch the fact that we don't get the expected behavior.
Also, a quick review of the patch:
I'd suggest changing the comments here to indicate what is expected, rather than leaving the reader to work out what the intention was. Something like:
etc.
Comment #11
james.williamsEt voilà.
Comment #12
james.williamsComment #14
steven jones commentedLovely stuff, thanks for the patch.