Hi All,
Has anyone else had any trouble with language overrides in a plugin on upgrading to Elgg1.5. It is simply not working for me. Has the mechanism for language overrides changed?
Thanks.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Cash@costelloc
Cash - 0 likes
- Matt Leifer@mleifer
Matt Leifer - 0 likes
- Cash@costelloc
Cash - 0 likes
- Marcus Povey@marcus
Marcus Povey - 0 likes
- Cash@costelloc
Cash - 0 likes
- LKLaRose@lauren
LKLaRose - 0 likes
- Cash@costelloc
Cash - 0 likes
You must log in to post replies.Matt, Elgg 1.5 broke language overrides. You need to modify add_translation() to get it working again.
It should look like this:
$CONFIG->translations[$country_code] = array_merge($CONFIG->translations[$country_code],$language_array);
And not like this:
//$CONFIG->translations[$country_code] += $language_array;
Thanks a lot. What file is add_translation() located in? Also, have you reported this as a bug on trac?
Yes, I've reported it (http://trac.elgg.org/elgg/ticket/883). The file is /engine/lib/languages.php
This is a known problem.
The issue with the array_merge method is that it turns out to be dog slow, causing an unacceptible performance hit as the number of plugins and language files increased.
I'm surprised that += doesn't clobber existing keys, but since it doesn't perhaps the following logic would work and still maintain the performance boost of using the operator rather than array_merge:
$language_array += $CONFIG->translations[$country_code];
$CONFIG->translations[$country_code] = $language_array;
According to the PHP documentation "The + operator appends elements of remaining keys from the right handed array to the left handed, whereas duplicated keys are NOT overwritten." Both + and += map to the same function add_function() which calls a hash merge function with the override parameter set to off.
If language file loading is a significant part of the page load time, it would seem that caching the results would be very useful.
@Cash
Your suggestion didn't work for me except that is broke anything related to that function.
@Marcus Povey
Your solution gave me this:
Fatal error: Unsupported operand types in /mysite/elgg/engine/lib/languages.php on line 39
I think they both should work. Mine was just the original code from Elgg 1.2.
Try this:
$CONFIG->translations[$country_code] = $language_array + $CONFIG->translations[$country_code];