String from "l10n" Folder

DrWaves7 years ago

Hi Anton !

I'm trying to modify the traccar Web interface to an newer version of ext JS.
I migrated the Store files, model files and the folder L10n, I modified application.js (to look like the application.Js of your web app).
If I understood well, the file load.Js load the different files from L10n. So I added the following code to my index.html

<div id="attribution">Powered by Traccar GPS Tracking System</div> <script id="loadScript" src="load.js"></script>

Nevertheless, I still have errors in store/model when I have to use "XXXX : strings.YYYY"

exemple :

"name: Strings.mapCarto,"
"name: Strings.sharedKm,"

with the error message : "ReferenceError: Can't find variable: Strings"

Wich mistake I did ?

best regards,

Anton Tananaev7 years ago

I'm not sure why you need to migrate anything. All you need to do is update version number in the load.js file. Also, there is no newer version of ExtJS.

DrWaves7 years ago

Sorry I will detail more. I want to modify the interface, so I use the cmd sencha to generate an app based on a template. I copy/paste the model/store files. However, I have a problem with

xemple :

“name: Strings.mapCarto,”
“name: Strings.sharedKm,”

with the error message : “ReferenceError: Can’t find variable: Strings”

Do you know how I can fix this problem ?

Anton Tananaev7 years ago

Do you mean default Sencha template? It would have completely different structure than current app. If you really want to do, you should study the code first to fully understand how it works now.

What is the reason for the change?

DrWaves7 years ago

Firstly, thanks for your answers !

No, I use the admin Dashboard template. I studied the application to understand but I still have this problem. here, I just copy/paste the model and store.

I think I don't "connect" the folder "l10n" and the app like it should be.

Anton Tananaev7 years ago

It sounds like you are trying to do significant modifications to the app. I won't be able to help you with it unless you want to go for a paid support option.

DrWaves7 years ago

Okay ! I will try to fix it these days.
Nevertheless, I probably will go for a paid support

Thanks !

DrWaves7 years ago

Hi Anton,

I studied the code. I just begin to adapt the login features to an app generated by Cmd Sencha.

If I understood well, The loads.js will set a variable "Strings"



Ext.Ajax.request({
            url: 'l10n/' + Locale.language + '.json',
            callback: function (options, success, response) {
                window.Strings = Ext.decode(response.responseText);

                if (debugMode) {
                    addScriptFile('app.js');
                } else {
                    addScriptFile('app.min.js');
                }
            }
        });

After that, "Application.Js" create the function set Server:


models: [
        'Server'
    ],

    stores: [
         'Languages'
    ],
     controllers: [
        'Root'
    ],
 setServer: function (data) {
        var reader = Ext.create('Ext.data.reader.Json', {
            model: 'Traccar.model.Server'
        });
        this.server = reader.readRecords(data).getRecords()[0];
    },

    getServer: function () {
        return this.server;
    },

and root will launch Login

   onLaunch: function () {
        Ext.Ajax.request({
            scope: this,
            url: 'api/server',
            callback: this.onServerReturn
        });
    },

    onServerReturn: function (options, success, response) {
        var token, parameters = {};
        if (success) {
            Traccar.app.setServer(Ext.decode(response.responseText));
            token = Ext.Object.fromQueryString(window.location.search).token;
            if (token) {
                parameters.token = token;
            }
            Ext.Ajax.request({
                scope: this,
                url: 'api/session',
                method: 'GET',
                params: parameters,
                callback: this.onSessionReturn
            });
        } else {
            Traccar.app.showError(response);
        }
    },

    onSessionReturn: function (options, success, response) {
        Ext.get('spinner').setVisible(false);
        if (success) {
            Traccar.app.setUser(Ext.decode(response.responseText));
            this.loadApp();
        } else {
            this.login = Ext.create('widget.login', {
                listeners: {
                    scope: this,
                    login: this.onLogin
                }
            });
            this.login.show();
        }
    },

    onLogin: function () {
        this.login.close();
       // this.loadApp();
    }

But the variable "Strings" Still not be established. and I don't understand what i did wrong ? I miss something ?

Anton Tananaev7 years ago

You should probably debug the code and see what happens.