private boolean isRelevant(Language lang) { if (lang==null) { return false; } return relevantLanguages.contains(lang.getCode()); } }
public RelevantLanguageSorter(List<Book> installedDocuments) { relevantLanguages = new HashSet<>(); String defaultLanguageCode = Locale.getDefault().getLanguage(); relevantLanguages.add(defaultLanguageCode); relevantLanguages.addAll(Arrays.asList(MAJOR_LANGUAGE_CODES)); for (Book doc : installedDocuments) { Language lang = doc.getLanguage(); if (lang!=null) { relevantLanguages.add(lang.getCode()); } } }
public String getAnalyzerValue(Language lang) { String key = lang.getCode() + ".Analyzer"; return myProperties.get(key); }
/** can we enable the main menu search button */ @Override public boolean isSearchable() { try { //TODO allow japanese search - japanese bibles use smartcn which is not available return !"ja".equals(getCurrentDocument().getLanguage().getCode()); } catch (Exception e) { Log.w(TAG, "Missing language code", e); return true; } } }
private List<Locale> calculateLocalePreferenceList(Book fromBook) { //calculate preferred locales to use for speech // Set preferred language to the same language as the book. // Note that a language may not be available, and so we have a preference list String bookLanguageCode = fromBook.getLanguage().getCode(); Log.d(TAG, "Book has language code:"+bookLanguageCode); List<Locale> localePreferenceList = new ArrayList<>(); if (bookLanguageCode.equals(Locale.getDefault().getLanguage())) { // for people in UK the UK accent is preferable to the US accent localePreferenceList.add( Locale.getDefault() ); } // try to get the native country for the lang String countryCode = getDefaultCountryCode(bookLanguageCode); if (countryCode!=null) { localePreferenceList.add( new Locale(bookLanguageCode, countryCode)); } // Speak ancient greek with modern greece. if(bookLanguageCode.equals("grc")) { bookLanguageCode = "el"; } // finally just add the language of the book localePreferenceList.add( new Locale(bookLanguageCode)); return localePreferenceList; }
@Override public void setBook(Book newBook) { book = newBook; stemmerName = null; if (book != null) { // stemmer name are same as language name, in most cases pickStemmer(book.getLanguage().getCode()); } }
Locale sortLocale = new Locale(book.getLanguage().getCode()); String target = searchRequest.toLowerCase(sortLocale);
public String getFontForBook(Book book) { String font = null; try { if (book!=null) { // sometimes an error occurs on following line - maybe due to missing language info in book metadata String langCode = book.getBookMetaData().getLanguage().getCode(); // is there a font for the book final String abbreviation = book.getAbbreviation(); font = fontProperties.getProperty(abbreviation); // is there a font for the language code if (StringUtils.isEmpty(font)) { font = fontProperties.getProperty(langCode); } log.debug("Book:" + abbreviation + " Language code:" + langCode + " Font:" + font); } } catch (Exception e) { // sometimes get here if a book has no initials - so do not attempt to print a books initials in the error log.warn("Problem getting font for book", e); } return font; }
private ArrayList<SpeakCommand> getSpeakCommandsForVerse(SpeakSettings settings, Book book, Key key) { try { BookData data = new BookData(book, key); Element frag = data.getOsisFragment(false); Document doc = frag.getDocument(); if (doc == null) { doc = new Document(frag); } SAXEventProvider osissep = new JDOMSAXEventProvider(doc); ContentHandler osisHandler = new OsisToBibleSpeak(settings, book.getLanguage().getCode()); osissep.provideSAXEvents(osisHandler); return ((OsisToBibleSpeak) osisHandler).getSpeakCommands(); } catch (Exception e) { Log.e(TAG, "Error getting text from book" , e); return new ArrayList<>(); } }
osisToHtmlParameters.setLanguageCode(book.getLanguage().getCode()); osisToHtmlParameters.setModuleBasePath(book.getBookMetaData().getLocation());