@ -2,14 +2,21 @@
"use strict" ;
"use strict" ;
/* globals RELATIVE_PATH, config, define */
/* globals RELATIVE_PATH, config, define */
var S ;
// export the class if we are in a Node-like system.
// export the class if we are in a Node-like system.
if ( typeof module === 'object' && module . exports === translator ) {
if ( typeof module === 'object' && module . exports === translator ) {
exports = module . exports = translator ;
exports = module . exports = translator ;
S = require ( 'string' ) ;
} else {
require ( [ 'string' ] , function ( stringLib ) {
S = stringLib ;
} ) ;
}
}
var languages = { } ,
var languages = { } ,
regexes = {
regexes = {
match : /\[\[\w+:[\w\.]+((?!\[\[|<|>|\(|\)).)*?\]\]/g , // see tests/translator.js for an explanation re: this monster
match : /\[\[\w+:[\w\.]+((?!\[\[ ).)*?\]\]/g, // see tests/translator.js for an explanation re: this monster
split : /[,][\s]*/ ,
split : /[,][\s]*/ ,
replace : /\]+$/
replace : /\]+$/
} ;
} ;
@ -187,8 +194,9 @@
function insertLanguage ( text , key , value , variables ) {
function insertLanguage ( text , key , value , variables ) {
if ( value ) {
if ( value ) {
var variable ;
for ( var i = 1 , ii = variables . length ; i < ii ; i ++ ) {
for ( var i = 1 , ii = variables . length ; i < ii ; i ++ ) {
var variable = variables [ i ] . replace ( ']]' , '' ) ;
variable = S ( variables [ i ] ) . chompRight ( ']]' ) . collapseWhitespace ( ) . escapeHTML ( ) . s ;
value = value . replace ( '%' + i , variable ) ;
value = value . replace ( '%' + i , variable ) ;
}
}