Skip to content

Commit 4786026

Browse files
Added new function ngLangDisplayName().
1 parent a44047e commit 4786026

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/ng_controls/controls.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,39 @@ function ngAddSupportedLang()
425425
return true;
426426
}
427427

428+
/**
429+
* Function: ngLangDisplayName
430+
* Gets language(s) display name.
431+
*
432+
* Syntax: mixed *ngLangDisplayName* (mixed id [, bool ucfirst=true])
433+
*
434+
* Returns:
435+
* Language display name(s).
436+
*/
437+
function ngLangDisplayName(lng, ucfirst)
438+
{
439+
if((typeof lng!=='undefined')&&(ngc_Lang)) {
440+
if(ng_IsObjVar(lng)) {
441+
var ret={};
442+
for(var i in lng) {
443+
var l=lng[i];
444+
if(l) ret[l]=ngLangDisplayName(l);
445+
}
446+
return ret;
447+
}
448+
lng = ngNormalizeLang(lng);
449+
if(lng=='cz') lng='cs';
450+
var t;
451+
if((lng!=='')&&(ng_IsObjVar(ngc_Lang[lng]))) {
452+
t=ngc_Lang[lng]['locale_language_native'];
453+
if(typeof t==='undefined') t=ngc_Lang[lng]['locale_language'];
454+
}
455+
if(typeof t==='undefined') t=lng.toUpperCase();
456+
else if(ngVal(ucfirst,true)) t=t.substr(0,1).toUpperCase()+t.substr(1);
457+
return t;
458+
}
459+
}
460+
428461
/**
429462
* Function: ngTxt
430463
* Gets locale text.

0 commit comments

Comments
 (0)