mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
ENHANCEMENT: significant speed improvement for many locales
Iterating over an array of locales and querying for each one causes tons of unnecessary queries. This is especially evident when you get up to hundreds of translations of a page. It makes the CMS admin UI insufferably slow. This is a little tweak to query for all of them at once instead of individually.
This commit is contained in:
parent
42f048f34a
commit
9771d97e1f
@ -1010,12 +1010,11 @@ class Translatable extends DataExtension implements PermissionProvider {
|
|||||||
));
|
));
|
||||||
if(!$tab->fieldByName('existingtrans')) {
|
if(!$tab->fieldByName('existingtrans')) {
|
||||||
$existingTransHTML = '<ul>';
|
$existingTransHTML = '<ul>';
|
||||||
foreach($alreadyTranslatedLocales as $langCode) {
|
foreach($this->getTranslations() as $existingTranslation) {
|
||||||
$existingTranslation = $this->owner->getTranslation($langCode);
|
|
||||||
if($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
|
if($existingTranslation && $existingTranslation->hasMethod('CMSEditLink')) {
|
||||||
$existingTransHTML .= sprintf('<li><a href="%s">%s</a></li>',
|
$existingTransHTML .= sprintf('<li><a href="%s">%s</a></li>',
|
||||||
sprintf('%s/?locale=%s', $existingTranslation->CMSEditLink(), $langCode),
|
sprintf('%s/?locale=%s', $existingTranslation->CMSEditLink(), $existingTranslation->Locale),
|
||||||
i18n::get_locale_name($langCode)
|
i18n::get_locale_name($existingTranslation->Locale)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user