You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
o.dictionary = false; // to supply the dictionary instead of loading it using $.ajax. A (big) javascript object containing your namespaced translations
70
-
o.lang = false; //specify a language to use i.e en-US
57
+
o.interpolationPrefix = '__';
58
+
o.interpolationSuffix = '__';
59
+
o.pluralSuffix = "_plural";
60
+
o.getSuffixMethod = function(count){ return "_foo"; } // A custom method to calculate the suffix if language rules differ
61
+
o.maxRecursion = 50; //used while applying reuse of strings to avoid infinite loop
62
+
o.reusePrefix = "$t("; //nested lookup prefix
63
+
o.reuseSuffix = ")"; //nested lookup suffix
64
+
o.fallbackLang = 'en-US'; // see Language fallback section
65
+
o.dicoPath = 'locales'; // see Dictionary section
66
+
o.keyseparator = "."; // keys passed to $.jsperanto.translate use this separator
o.dictionary = false; // to supply the dictionary instead of loading it using $.ajax. A (big) javascript object containing your namespaced translations
69
+
o.lang = false; //specify a language to use i.e en-US
71
70
72
71
Use init to switch language too :
73
72
74
-
$.jsperanto.init(someMethod,{lang:"fr"})
73
+
$.jsperanto.init(someMethod,{lang:"fr"})
75
74
76
75
**$.jsperanto.translate(key,options)**
77
76
@@ -81,7 +80,7 @@ looks up the key in the dictionary applying plural, interpolation & nested looku
81
80
82
81
**options** each prop name are are used for interpolation
83
82
84
-
**options.count** special prop that indicates to retrieve the counted version (**key**_aboveOne, _exactlyOne, _belowOne). Also used for interpolation
83
+
**options.count** special prop that indicates to retrieve the plural version (**key**_plural) if its greater than 1. Also used for interpolation
85
84
86
85
**options.defaultValue** specify default value if the key can't be resolved (the key itself will be sent back if no defaultValue is provided)
87
86
@@ -92,7 +91,7 @@ Dictionary loading
92
91
93
92
Using defaults, jsperanto uses a basic browser language detection
to determine what dictionary file to load. You can also instruct jsperanto to load a specific language (via init option _lang_).
98
97
@@ -105,7 +104,25 @@ Switching language
105
104
106
105
Simply use init again and specify a language (or dictionary) to use.
107
106
108
-
$.jsperanto.init(someMethod,{lang:"fr"})
107
+
$.jsperanto.init(someMethod,{lang:"fr"})
108
+
109
+
Custom suffixes
110
+
==================
111
+
112
+
At init time specify a method which will calculate the suffic to use if count is present. the argument passed to this method is the count and can be a string or number.
113
+
Anything other than a string returned will be disregarded.
114
+
115
+
$.jsperanto.init(someMethod, {
116
+
lang:"en-us",
117
+
getSuffixMethod : function(count){
118
+
if ( count === 0 ) {
119
+
return "_zero";
120
+
}
121
+
if ( count !== 1 ) {
122
+
return "_plural";
123
+
}
124
+
}
125
+
)
109
126
110
127
Licence
111
128
=======
@@ -142,11 +159,10 @@ Inspiration & similar projects
0 commit comments