@@ -244,7 +244,12 @@ export class Polyglot {
244244 if ( ! this . _isTruespeech ( lang ) && ( lang === this . omniglot || lang === this . comprehendLanguages ) ) {
245245 continue ;
246246 }
247- const label = this . languageProvider . languages [ lang ] ?. label || lang . capitalize ( ) ;
247+ const option = {
248+ id : lang ,
249+ group : "known" ,
250+ label : this . languageProvider . languages [ lang ] ?. label || lang . capitalize ( ) ,
251+ $order : lang === defaultLanguage ? 1 : 1000 // Sorting Order
252+ } ;
248253 if ( game . user . isGM ) {
249254 if ( ownedActors . length ) {
250255 const usersThatKnowLang = filteredUsers . filter ( ( u ) =>
@@ -262,17 +267,12 @@ export class Polyglot {
262267 const { name, color, actorsOwnedByUser } = user ;
263268 users . push ( { bgColor : color , userName : name , ownedActors : actorsOwnedByUser . join ( ", " ) } ) ;
264269 }
265- options . push ( { id : lang , group : "known" , label, users } ) ;
266- continue ;
267- }
268- }
269- options . push ( { id : lang , group : "unknown" , label } ) ;
270- } else {
271- options . push ( { id : lang , group : "known" , label } ) ;
270+ option . users = users ;
271+ } else option . group = "unknown" ;
272+ } else option . group = "unknown" ;
272273 }
274+ options . push ( option ) ;
273275 }
274- options . sort ( ( a , b ) => a . label . localeCompare ( b . label ) ) ;
275- options . unshift ( { id : "" , group : "known" , label : "None" } ) ;
276276
277277 const select = this . chatElement . querySelector ( ".polyglot-lang-select select" ) ;
278278 const selectedLanguage = this . lastSelection || select . value || defaultLanguage ;
@@ -288,9 +288,9 @@ export class Polyglot {
288288 optgroupValueField : "id" ,
289289 lockOptgroupOrder : true ,
290290 searchField : [ "label" ] ,
291+ sortField : [ { field : "$order" } , { field : "label" } ] ,
291292 plugins : [ "optgroup_columns" ] ,
292293
293- allowEmptyOption : true ,
294294 create : false ,
295295 controlInput : null ,
296296 render : {
0 commit comments