PageSourceSearch

https://world-fenix.ru/_s/js/components/gettext.js

js world-fenix.ru collected 2026-09-29 22:41:54 UTC 2,543 bytes, 98 lines download raw bytes

1function _( key ){
2	var
3		dict, str, n, lang, res;
4	
5	if ( ! arguments || arguments.length < 1 || ! RegExp ) {
6		return;
7		}
8	dict = window['__lang'] || {};
9	str = dict[ key ];
10	lang = window.LANG;
11	if (!lang && window.userSiteData) lang = window.userSiteData.lang;
12	if (!lang) lang = document.getElementsByTagName('html')[0].lang.split('-')[0];
13
14	if ( typeof str ==  'undefined' ){
15		str = key;
16		}
17	else if ( str != null && typeof( str ) == 'object' && typeof( str.unshift ) == 'function' ){
18		n = arguments[1];
19		str = str[ nplural(lang, n) ] || '';
20		}
21	arguments[0] = str;
22	try{
23		res = sprintf.apply(null, arguments);
24		}
25	catch (e){
26		return str;
27		}
28	
29	return res;
30		
31	function str_repeat(i, m) { 
32		for (var o = []; m > 0; o[--m] = i); return(o.join('')); 
33		}
34
35	function sprintf () {
36		var 
37			i = 0, 
38			a, 
39			f = arguments[i++], 
40			o = [], 
41			m, p, c, x;
42		while (f) {
43			if (m = /^[^\x25]+/.exec(f)) {
44				o.push(m[0]);
45				}
46			else if (m = /^\x25{2}/.exec(f)) {
47				o.push('%');
48				}
49			else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
50				if (((a = arguments[m[1] || i++]) == null) || (a == undefined)){
51				  	throw("Too few arguments.");
52				  	}
53				  if (/[^s]/.test(m[7]) && (typeof(a) != 'number')){
54					throw("Expecting number but found " + typeof(a));
55				  	}
56				switch (m[7]) {
57					case 'b': a = a.toString(2); break;
58					case 'c': a = String.fromCharCode(a); break;
59					case 'd': a = parseInt(a); break;
60					case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
61					case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
62					case 'o': a = a.toString(8); break;
63					case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
64					case 'u': a = Math.abs(a); break;
65					case 'x': a = a.toString(16); break;
66					case 'X': a = a.toString(16).toUpperCase(); break;
67					}
68				a = (/[def]/.test(m[7]) && m[2] && a > 0 ? '+' + a : a);
69				c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
70				x = m[5] - String(a).length;
71				p = m[5] ? str_repeat(c, x) : '';
72				o.push(m[4] ? a + p : p + a);
73				}
74		    else {
75		    	throw ("Huh ?!");
76				}
77			f = f.substr(m[0].length);
78			}
79		return o.join('');
80		}
81	
82	}
83
84function nplural(lang, n){
85		if ( lang == 'ru' ) {
86			return  ( 
87			( n % 10 == 1 && n % 100 != 11 ) 
88				? 0 
89				: ( n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20) ) 
90					? 1 
91					: 2 
92					);
93		} else if ( lang == 'en' ) {
94			return n == 1 ? 0 : 1;
95		} else {
96			return 0;
97		} 
98}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.