Santhosh
Santhosh

Reputation: 1397

Issue with DOJO Localization

I am struggling for a long time with DOJO Localization.

My application folder structure is in following way.

enter image description here

And, the code to get localized strings is as follows.

 dojo.require("dojo.i18n");
    dojo.requireLocalization("CTop.recordings", "agent");
    dojo.addOnLoad(function () {
        //Returns a localized Object
        var localizedStrings = dojo.i18n.getLocalization("CTop.recordings", "agent", "de");

I am getting empty localizedStrings object.

If i move recordings folder to the level of dojo folder (i.e. under Scripts), the following code is working fine.

 dojo.require("dojo.i18n");
    dojo.requireLocalization("recordings", "agent");
    dojo.addOnLoad(function () {
        //Returns a localized Object
        var localizedStrings = dojo.i18n.getLocalization("recordings", "agent", "de");

What's the problem with adding CTop folder to structure? How to register the localization path?

I tried in following ways too but not succeeded.

dojo.require("dojo.i18n");
dojo.registerModulePath("myApp", "cTop.recordings.agent");
dojo.requireLocalization("myApp", "agent");
var localizedStrings = dojo.i18n.getLocalization("myApp", "agent", "de");

Please guide me resolving this

Thanks in advance.

Upvotes: 1

Views: 903

Answers (2)

Santhosh
Santhosh

Reputation: 1397

The problem was i have two folders with the same name CTop. Renamed the folder which does not need localization. Following code snippet is enough to localize.

dojo.i18n.getLocalization("CTop.recordings", "agent", "de");

Upvotes: 0

mschr
mschr

Reputation: 8641

Try this (with the cTop directory folder intact, as in your screenshot)

// point the top-level namespace (such like 'dojo' is) to a folder by relative URI
// path here is a relative to dojo.js
dojo.registerModulePath("myApp", "../cTop/recordings"); 
dojo.requireLocalization("myApp", "agent");
var localizedStrings = dojo.i18n.getLocalization("myApp", "agent", "de");

// if you were to have a module declared in a file called 'myModule.js' under 'cTop' folder
// one could require it by following
dojo.require("myApp.myModule");

Upvotes: 2

Related Questions