PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.4
Pods – Custom Content Types and Fields v2.8.23.4
2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / ui / js / pods-i18n.js
pods / ui / js Last commit date
blocks 2 weeks ago cleditor 2 weeks ago codemirror 2 weeks ago dfv 2 weeks ago marionette 2 weeks ago qtip 2 weeks ago selectWoo 2 weeks ago sprintf 2 weeks ago timepicker 2 weeks ago handlebars.js 2 weeks ago jquery.pods.js 2 weeks ago jquery.pods.upgrade.js 2 weeks ago pods-i18n.js 2 weeks ago pods-link-picker.js 2 weeks ago qtip.js 2 weeks ago
pods-i18n.js
63 lines
1 /*global podsLocalizedStrings, sprintf */
2 'use strict';
3 var PodsI18n = (function () {
4
5 /**
6 * Only visible to the closure, not exposed externally.
7 * @param {string} str
8 * @returns {string}
9 */
10 var translateString = function ( str ) {
11 var translated = str, ref;
12
13 if ( typeof podsLocalizedStrings !== 'undefined' ) {
14
15 /**
16 * Converts string into reference object variable
17 * Uses the same logic as PHP to create the same references
18 */
19 ref = '__' + str;
20
21 if ( typeof podsLocalizedStrings[ ref ] !== 'undefined' ) {
22 translated = podsLocalizedStrings[ ref ];
23 }
24 else if ( podsLocalizedStrings.debug ) {
25 console.log( 'PodsI18n: String not found "' + str + '" (reference used: "' + ref + '")' );
26 }
27 }
28
29 return translated;
30 };
31
32 /**
33 * The returned object, this is what we'll expose to the outside world
34 */
35 return {
36 /**
37 * @param {string} str
38 * @returns {string}
39 */
40 __: function ( str ) {
41 return translateString( str );
42 },
43
44 /**
45 * @param {string} single
46 * @param {string} plural
47 * @param {number} number
48 *
49 * @returns {string}
50 */
51 _n: function ( single, plural, number ) {
52
53 // Unary + will implicitly cast to numeric
54 if ( +number === 1 ) {
55 return translateString( single );
56 }
57 else {
58 return translateString( plural );
59 }
60 },
61 };
62
63 }());