Alexander Nazarov (nfokz) wrote in changelog,
Alexander Nazarov
nfokz
changelog

[livejournal] r22072: LJSUP-11158: Make alias LJ.ml for LiveJo...

Committer: anazarov
LJSUP-11158: Make alias LJ.ml for LiveJournal.getLocalizedStr
U   trunk/htdocs/js/basic.js
U   trunk/htdocs/js/livejournal.js
Modified: trunk/htdocs/js/basic.js
===================================================================
--- trunk/htdocs/js/basic.js	2012-05-25 13:53:41 UTC (rev 22071)
+++ trunk/htdocs/js/basic.js	2012-05-28 06:35:36 UTC (rev 22072)
@@ -582,6 +582,25 @@
 	}
 };
 
+LJ.ml = function(key, dict, def) {
+	var str = '', tmpl;
+	dict = dict || {};
+
+	if (Site.ml_text.hasOwnProperty(key)) {
+		str = Site.ml_text[key];
+
+		for (tmpl in dict) {
+			if (dict.hasOwnProperty(tmpl)) {
+				str = str.replace('%' + tmpl + '%', dict[tmpl]);
+			}
+		}
+	} else {
+		str = def || '[' + key + ']';
+	}
+
+	return str;
+};
+
 /**
  * @namespace LJ.Support The namespace should contain variables to check whether some funcionality is availible in the current browser.
  * If this part will become hige enough, we should switch to modernizr.

Modified: trunk/htdocs/js/livejournal.js
===================================================================
--- trunk/htdocs/js/livejournal.js	2012-05-25 13:53:41 UTC (rev 22071)
+++ trunk/htdocs/js/livejournal.js	2012-05-28 06:35:36 UTC (rev 22072)
@@ -457,22 +457,8 @@
 	}
 };
 
-LiveJournal.getLocalizedStr = function(key, dict, def) {
-	dict = dict || {};
-	var str = '';
-	if (key in Site.ml_text) {
-		str = Site.ml_text[ key ];
+LiveJournal.getLocalizedStr = LJ.ml;
 
-		for (var tmpl in dict) {
-			str = str.replace('%' + tmpl + '%', dict[ tmpl ]);
-		}
-	} else {
-		str = def || '[' + key + ']';
-	}
-
-	return str;
-};
-
 LiveJournal.JSON = function() {
 	/**
 	 * Formats integers to 2 digits.

Tags: anazarov, js, livejournal, nfokz
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments