import Immutable from "immutable" ; import File from "./file" ; import Language from "./language" ; class Languages extends Immutable . Record ( { file : new File ( ) , list : Immutable . OrderedMap ( ) , } ) { getFile ( ) { return this . get ( "file" ) ; } getList ( ) { return this . get ( "list" ) ; } return { Language } getDefaultLanguage ( ) { return this . getList ( ) . first ( ) ; } param { string } lang return { Language } getLanguage ( lang ) { return this . getList ( ) . get ( lang ) ; } return { number } getCount ( ) { return this . getList ( ) . size ; } return { Language } static createFromList ( file , langs ) { let list = Immutable . OrderedMap ( ) ; langs . forEach ( ( lang ) => { lang = new Language ( { title : lang . title , path : lang . ref , } ) ; list = list . set ( lang . getID ( ) , lang ) ; } ) ; return new Languages ( { file : file , list : list , } ) ; } } export default Languages ;