/**
 * Created by roobm on 21.03.2017.
 */ import { TranslationMessagesFileFactory , ITranslationMessagesFile } from '@ngx-i18nsupport/ngx-i18nsupport-lib' ; import { FileUtil } from '../common/file-util' ; import { XmlReader } from './xml-reader' ; /**
 * Helper class to read translation files depending on format.
 */ export class TranslationMessagesFileReader { param i18nFormat param path param encoding param optionalMasterFilePath return public static fromFile ( i18nFormat , path , encoding , optionalMasterFilePath ? ) { const xmlContent = XmlReader . readXmlFileContent ( path , encoding ) ; const optionalMaster = TranslationMessagesFileReader . masterFileContent ( optionalMasterFilePath , encoding ) ; return TranslationMessagesFileFactory . fromFileContent ( i18nFormat , xmlContent . content , path , xmlContent . encoding , optionalMaster ) ; } param path param encoding param optionalMasterFilePath return public static fromUnknownFormatFile ( path , encoding , optionalMasterFilePath ? ) { const xmlContent = XmlReader . readXmlFileContent ( path , encoding ) ; const optionalMaster = TranslationMessagesFileReader . masterFileContent ( optionalMasterFilePath , encoding ) ; return TranslationMessagesFileFactory . fromUnknownFormatFileContent ( xmlContent . content , path , xmlContent . encoding , optionalMaster ) ; } param optionalMasterFilePath param encoding return private static masterFileContent ( optionalMasterFilePath , encoding ) { if ( optionalMasterFilePath ) { const masterXmlContent = XmlReader . readXmlFileContent ( optionalMasterFilePath , encoding ) ; return { xmlContent : masterXmlContent . content , path : optionalMasterFilePath , encoding : masterXmlContent . encoding } ; } else { return null ; } } param messagesFile param beautifyOutput public static save ( messagesFile , beautifyOutput ? ) { FileUtil . replaceContent ( messagesFile . filename ( ) , messagesFile . editedContent ( beautifyOutput ) , messagesFile . encoding ( ) ) ; } }