duanjingyu007 / jquery-i18n-properties

Automatically exported from code.google.com/p/jquery-i18n-properties
0 stars 0 forks source link

base namespace should be configurable #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
It would be nice if we could supply a base namespace (or scope) in the options 
passed to $.i18n.properties so that we don't have to define these in our 
resource bundles.

Original issue reported on code.google.com by d.de...@gmail.com on 7 Oct 2011 at 9:18

GoogleCodeExporter commented 8 years ago
I have made a similar change to the plugin for our internal use.  Basically the 
modification looks like this:

at line 60:
        encoding:       'UTF-8',
        object:         window,
        callback:       null,

at line 255:
        success:    function(data, status) {
                        parseData(data, settings.mode, settings.object); 
                    }

at line 262:
    /** Parse .properties files */
    function parseData(data, mode, obj) {

at line 300:
                   value = value.replace( /"/g, '\\"' ); // escape quotation mark (")
                   o = obj;
                   name = 'o.' + name;
                   // make sure namespaced key exists (eg, 'some.key')

Then you can pass the object you wish to attach the values to into the plugin 
through the options.

Original comment by Ross...@gmail.com on 7 Nov 2011 at 10:31

GoogleCodeExporter commented 8 years ago
Imo a namespace would be a better idea, because you don't have to ensure it 
exists. When you want to use 'msg.a' as a base object like you propose, you 
would have to create msg and msg.a by yourself. When using a base namespace, it 
is all done automagically for you.

Original comment by d.de...@gmail.com on 8 Nov 2011 at 7:29

GoogleCodeExporter commented 8 years ago
Patch containing the namespace change.

Original comment by d.de...@gmail.com on 8 Nov 2011 at 7:37

Attachments: