diff options
author | Marcel Klehr <mklehr@gmx.net> | 2024-01-09 10:36:52 +0100 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2024-01-10 11:16:14 +0100 |
commit | 1fd0c2979e1edfb667cbb0e7abbc3c342f7d11f6 (patch) | |
tree | 89f0838978639e20fc2250c831f6a68ca96c2c4f /lib/private/Translation | |
parent | 50aeae6a858094d86d93d0db12889ca98d226ab0 (diff) | |
download | nextcloud-server-1fd0c2979e1edfb667cbb0e7abbc3c342f7d11f6.tar.gz nextcloud-server-1fd0c2979e1edfb667cbb0e7abbc3c342f7d11f6.zip |
enh(OCP\Translation): Add ITranslationProviderWithId
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/private/Translation')
-rw-r--r-- | lib/private/Translation/TranslationManager.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/private/Translation/TranslationManager.php b/lib/private/Translation/TranslationManager.php index 48a0e2cdebd..546ed595aaf 100644 --- a/lib/private/Translation/TranslationManager.php +++ b/lib/private/Translation/TranslationManager.php @@ -35,6 +35,7 @@ use OCP\Translation\CouldNotTranslateException; use OCP\Translation\IDetectLanguageProvider; use OCP\Translation\ITranslationManager; use OCP\Translation\ITranslationProvider; +use OCP\Translation\ITranslationProviderWithId; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use Psr\Log\LoggerInterface; @@ -73,13 +74,17 @@ class TranslationManager implements ITranslationManager { $precedence = json_decode($json, true); $newProviders = []; foreach ($precedence as $className) { - $provider = current(array_filter($providers, fn ($provider) => $provider::class === $className)); + $provider = current(array_filter($providers, fn ($provider) => + $provider instanceof ITranslationProviderWithId ? $provider->getId() === $className : $provider::class === $className)) + ; if ($provider !== false) { $newProviders[] = $provider; } } // Add all providers that haven't been added so far - $newProviders += array_udiff($providers, $newProviders, fn ($a, $b) => $a::class > $b::class ? 1 : ($a::class < $b::class ? -1 : 0)); + $newProviders += array_udiff($providers, $newProviders, fn ($a, $b) => + ($a instanceof ITranslationProviderWithId ? $a->getId() : $a::class) <=> ($b instanceof ITranslationProviderWithId ? $b->getId() : $b::class) + ); $providers = $newProviders; } |