public SoyMsgBundle createFromFile ( File inputFile ) throws IOException { // TODO: This is for backwards-compatibility. Figure out how to get rid of this. // We special-case English locales because they often don't have translated files and falling // back to the Soy source should be fine. if ( ! inputFile . exists ( ) && FIRST_WORD_IS_EN_PATTERN . matcher ( inputFile . getName ( ) ) . matches ( ) ) { return SoyMsgBundle . EMPTY ; } try { // reading the file as a byte array and then invoking the string constructor is the fastest // way to read a full file as a string. it avoids copies incurred by CharSource and picks a // faster path for charset decoding. String inputFileContent = Files . asCharSource ( inputFile , UTF_8 ) . read ( ) ; return msgPlugin . parseTranslatedMsgsFile ( inputFileContent ) ; } catch ( SoyMsgException sme ) { sme . setFileOrResourceName ( inputFile . toString ( ) ) ; throw sme ; } }
Reads a translated messages file and creates a SoyMsgBundle .