PageSourceSearch

https://elle.hu/translate/asset

js elle.hu collected 2026-10-02 11:57:03 UTC 1,587 bytes, 51 lines download raw bytes

1/*
2* Usage:
3* console.log(yii.t('app', 'Hello'));
4* console.log(yii.t('app', 'Hello, World!'));
5* console.log(yii.t('app', 'Hello, {username}!', {username: 'John'}));
6* console.log(yii.t('app', 'Hello, {0}!', ['John']));
7* console.log(yii.t('app', 'Hello, {0} {1}!', ['John', 'Doe']));
8* */
9;(function () {
10if (!('yii' in window)) {
11   window.yii = {};
12  }
13  if (!('t' in window.yii)) {
14    var YII_I18N_JS = {"success":1,"data":[]};
15
16    yii.t = function (category, message, params) {
17	  const get = (category, message) => {
18		var acc;
19          try {
20			var newCategory = category.match(/\-/) ? '[\'' + category + '\']' : '.' + category;
21			var newMessage = message.match(/ /) || message.match(/\-/) ? '[\'' + message + '\']' : '.' + message;
22			var fullPath = 'YII_I18N_JS' + newCategory + newMessage;
23            acc = eval(fullPath);
24
25            if(typeof acc === 'undefined') {
26              throw "Undefined";
27			}
28          } catch (e) {
29            return message;
30          }
31          return acc;
32      }
33
34	  var translatedMessage = get(category, message);
35	  if (translatedMessage === null) {
36		  translatedMessage = message;
37	  }
38
39      if (params) {
40        Object.keys(params).map(function (key) {
41          var escapedParam =
42            // https://stackoverflow.com/a/6969486/4223982
43            key.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\^$\|]/g, '\$&');
44          var regExp = new RegExp('\\{' + escapedParam + '\\}', 'g');
45          translatedMessage = translatedMessage.replace(regExp, params[key]);
46        });
47      }
48      return translatedMessage;
49    };
50  }
51})();

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.