[BUG] Translations don't work properly/Route names with dots are broken [affects stable and dev]

Only PHP and not JS parts of dashboard are translated from .php translation file.

Console debug:

GET http://localhost:8000/cockpit.i18n.data net::ERR_ABORTED 404 (Not Found) dashboard:46

Problem seems to be with dots in route name in modules/Cockpit/admin.php.

Changing route from cockpit.i18n.data to one without dots like i18n and script name accordingly in modules/Cockpit/views/layouts/app.php on line 35 works:

  • /modules/Cockpit/admin.php:
   if ($translationspath = $this->path("#config:cockpit/i18n/{$locale}.php")) {
        $this->helper('i18n')->locale = $locale;
        $this->helper('i18n')->load($translationspath, $locale);
    }

-   $this->bind('/cockpit.i18n.data', function() {
+   $this->bind('/i18n', function() {
        $this->response->mime = 'js';
        $data = $this->helper('i18n')->data($this->helper('i18n')->locale);
        return 'if (i18n) { i18n.register('.(count($data) ? json_encode($data):'{}').'); }';
    });
  • /modules/Cockpit/views/layouts/app.php:
    {{ $app->assets($app('admin')->data->get('assets'), $app['debug'] ? time() : $app['cockpit/version']) }}

-   <script src="@route('/cockpit.i18n.data')"></script>
+   <script src="@route('/i18n')"></script>

    <script>
        App.$data = {{ json_encode($app('admin')->data->get('extract')) }};
        UIkit.modal.labels.Ok = App.i18n.get(UIkit.modal.labels.Ok);
        UIkit.modal.labels.Cancel = App.i18n.get(UIkit.modal.labels.Cancel);
    </script>

Removing dots from route solves problem.

1 Like