2013-05-01 08:46:16 +04:00
|
|
|
/*
|
2013-05-14 08:00:24 +04:00
|
|
|
* OpenSeadragon - getString/setString
|
2013-05-01 08:46:16 +04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 CodePlex Foundation
|
2013-05-14 07:32:09 +04:00
|
|
|
* Copyright (C) 2010-2013 OpenSeadragon contributors
|
2013-05-01 08:46:16 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* - Neither the name of CodePlex Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
2011-12-06 07:50:25 +04:00
|
|
|
|
|
|
|
(function( $ ){
|
2013-06-19 21:33:25 +04:00
|
|
|
|
|
|
|
//TODO: I guess this is where the i18n needs to be reimplemented. I'll look
|
2012-01-12 03:22:13 +04:00
|
|
|
// into existing patterns for i18n in javascript but i think that mimicking
|
|
|
|
// pythons gettext might be a reasonable approach.
|
2012-01-24 07:48:45 +04:00
|
|
|
var I18N = {
|
2011-12-06 07:50:25 +04:00
|
|
|
Errors: {
|
2012-04-03 11:08:27 +04:00
|
|
|
Dzc: "Sorry, we don't support Deep Zoom Collections!",
|
|
|
|
Dzi: "Hmm, this doesn't appear to be a valid Deep Zoom Image.",
|
|
|
|
Xml: "Hmm, this doesn't appear to be a valid Deep Zoom Image.",
|
|
|
|
ImageFormat: "Sorry, we don't support {0}-based Deep Zoom Images.",
|
|
|
|
Security: "It looks like a security restriction stopped us from " +
|
|
|
|
"loading this Deep Zoom Image.",
|
2013-06-28 02:10:23 +04:00
|
|
|
Status: "This space unintentionally left blank ({0} {1}).",
|
2013-09-26 21:16:10 +04:00
|
|
|
OpenFailed: "Unable to open {0}: {1}"
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
Tooltips: {
|
2012-04-03 11:08:27 +04:00
|
|
|
FullPage: "Toggle full page",
|
|
|
|
Home: "Go home",
|
|
|
|
ZoomIn: "Zoom in",
|
|
|
|
ZoomOut: "Zoom out",
|
|
|
|
NextPage: "Next page",
|
2014-03-03 20:28:28 +04:00
|
|
|
PreviousPage: "Previous page",
|
|
|
|
RotateLeft: "Rotate left",
|
2018-04-04 13:31:18 +03:00
|
|
|
RotateRight: "Rotate right",
|
|
|
|
Flip: "Flip Horizontally"
|
2012-01-24 07:48:45 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-11-25 20:48:44 +04:00
|
|
|
$.extend( $, /** @lends OpenSeadragon */{
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-15 23:50:27 +04:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @param {String} property
|
|
|
|
*/
|
2012-01-12 03:22:13 +04:00
|
|
|
getString: function( prop ) {
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-01-12 03:22:13 +04:00
|
|
|
var props = prop.split('.'),
|
2012-04-03 11:08:27 +04:00
|
|
|
string = null,
|
2012-01-12 03:22:13 +04:00
|
|
|
args = arguments,
|
2013-04-03 22:33:47 +04:00
|
|
|
container = I18N,
|
2012-01-12 03:22:13 +04:00
|
|
|
i;
|
|
|
|
|
2017-01-08 17:52:57 +03:00
|
|
|
for (i = 0; i < props.length - 1; i++) {
|
2012-04-03 11:08:27 +04:00
|
|
|
// in case not a subproperty
|
2013-04-03 22:33:47 +04:00
|
|
|
container = container[ props[ i ] ] || {};
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
2013-04-03 22:33:47 +04:00
|
|
|
string = container[ props[ i ] ];
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2018-05-11 20:53:16 +03:00
|
|
|
if ( typeof ( string ) != "string" ) {
|
2017-02-10 01:29:13 +03:00
|
|
|
$.console.log( "Untranslated source string:", prop );
|
2013-06-28 02:08:06 +04:00
|
|
|
string = ""; // FIXME: this breaks gettext()-style convention, which would return source
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return string.replace(/\{\d+\}/g, function(capture) {
|
2013-02-13 07:40:08 +04:00
|
|
|
var i = parseInt( capture.match( /\d+/ ), 10 ) + 1;
|
2013-06-19 21:33:25 +04:00
|
|
|
return i < args.length ?
|
|
|
|
args[ i ] :
|
2012-01-12 03:22:13 +04:00
|
|
|
"";
|
2011-12-06 07:50:25 +04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-02-15 23:50:27 +04:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @param {String} property
|
|
|
|
* @param {*} value
|
|
|
|
*/
|
2012-01-12 03:22:13 +04:00
|
|
|
setString: function( prop, value ) {
|
|
|
|
|
|
|
|
var props = prop.split('.'),
|
2013-04-27 01:18:27 +04:00
|
|
|
container = I18N,
|
2012-01-12 03:22:13 +04:00
|
|
|
i;
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-01-12 03:22:13 +04:00
|
|
|
for ( i = 0; i < props.length - 1; i++ ) {
|
|
|
|
if ( !container[ props[ i ] ] ) {
|
|
|
|
container[ props[ i ] ] = {};
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
2012-01-12 03:22:13 +04:00
|
|
|
container = container[ props[ i ] ];
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
|
|
|
|
2012-01-12 03:22:13 +04:00
|
|
|
container[ props[ i ] ] = value;
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
|
|
|
|
2012-01-24 07:48:45 +04:00
|
|
|
});
|
2011-12-06 07:50:25 +04:00
|
|
|
|
|
|
|
}( OpenSeadragon ));
|