jfcherng-roundcube / plugin-cloudview

A Roundcube plugin which lets you view documents with cloud viewers.
https://packagist.org/packages/jfcherng-roundcube/cloudview
MIT License
10 stars 5 forks source link

Correct names of viewers are not displayed #6

Closed Programmierus closed 4 years ago

Programmierus commented 4 years ago

Hello,

Thanks for a nice plugin! I've installed it within my dockerized setup, but somehow I am getting the list of viewers as following no matter what language I select. Already tried installing via composer and manually:

image

Thanks!

jfcherng commented 4 years ago

What's the localization/version of your RC?

Programmierus commented 4 years ago

en-US. But I tried to change to others you have available, e.g. ru-RU: no change.

jfcherng commented 4 years ago

What's the version of your RC? Does the localization problem only happens on the list?

Programmierus commented 4 years ago

It's the latest dockerized RC with the image from here.

From what I can see the problem seems to be only on the list. Here is a full screenshot of the settings window with ru-RU localization:

image

(Partially translated, meaning the localization indeed kicks in).

jfcherng commented 4 years ago

Hmm... interesting. May investigate when I am available. Unfortunately I am quite busy recently :disappointed:

Programmierus commented 4 years ago

No rush here. I'll try to dig myself too and will let you know if I'll have any luck.

Let me know if you want me to conduct any more tests.

jfcherng commented 4 years ago

Could you try this patch for cloudview.php?

@@ -401,7 +401,7 @@ final class cloudview extends AbstractRoundcubePlugin
         return $localizations = $localizations ?? \array_map(
             function (string $fqcn): string {
                 // "...\CloudView\Viewer\GoogleDocsViewer" to "GoogleDocs"
-                $transKey = \substr(\basename($fqcn), 0, -6);
+                $transKey = \substr((new \ReflectionClass($fqcn))->getShortName(), 0, -6);
                 // "GoogleDocs" to "viewer_google_docs"
                 $transKey = 'viewer' . \strtolower(\preg_replace('/[A-Z]/S', '_$0', $transKey));

It looks like basename() works for \ only on Windows (which I am on) according to PHP doc.

image

Programmierus commented 4 years ago

Confirm working. I'll also submit a PR soon with my contribution to localizations :)