Example usage for java.util Locale getLanguage

List of usage examples for java.util Locale getLanguage

Introduction

In this page you can find the example usage for java.util Locale getLanguage.

Prototype

public String getLanguage() 

Source Link

Document

Returns the language code of this Locale.

Usage

From source file:om.edu.squ.squportal.portlet.dps.dao.db.DpsDbImpl.java

/**
 * /*from w  ww  . j a  v  a2s. co  m*/
 * method name  : getNextYearSemester
 * @param locale
 * @return
 * DpsDbImpl
 * return type  : YearSemester
 * 
 * purpose      : Get next year semester
 *
 * Date          :   Jan 16, 2017 3:02:26 PM
 */
public YearSemester getNextYearSemester(Locale locale) {
    String SQL_DPS_NEXT_YR_SEM = queryProps.getProperty(Constants.CONST_SQL_DPS_NEXT_YR_SEM);

    RowMapper<YearSemester> mapper = new RowMapper<YearSemester>() {

        public YearSemester mapRow(ResultSet rs, int rowNum) throws SQLException {
            YearSemester yearSemester = new YearSemester();
            yearSemester.setYear(rs.getInt(Constants.COST_COL_DPS_COURSE_YEAR));
            yearSemester.setSemesterCode(rs.getInt(Constants.COST_COL_DPS_SEMESTER_CODE));
            yearSemester.setSemesterAbbr(rs.getString(Constants.COST_COL_DPS_ABR_SEM));
            yearSemester.setSemesterName(rs.getString(Constants.COST_COL_DPS_SEMESTER_NAME));
            return yearSemester;
        }
    };

    Map<String, String> namedParameterMap = new HashMap<String, String>();
    namedParameterMap.put("paramLocale", locale.getLanguage());
    return nPJdbcTemplDps.queryForObject(SQL_DPS_NEXT_YR_SEM, namedParameterMap, mapper);
}

From source file:om.edu.squ.squportal.portlet.dps.dao.db.DpsDbImpl.java

/**
 * //from w ww .j av  a2  s .c o m
 * method name  : getCurrentYearSemester
 * @param locale
 * @return
 * DpsDbImpl
 * return type  : YearSemester
 * 
 * purpose      : Get Current Year Semester
 *
 * Date          :   Jan 16, 2017 11:10:09 AM
 */
public YearSemester getCurrentYearSemester(Locale locale) {
    String SQL_DPS_CURRENT_YR_SEM = queryProps.getProperty(Constants.CONST_SQL_DPS_CURRENT_YR_SEM);

    RowMapper<YearSemester> mapper = new RowMapper<YearSemester>() {

        public YearSemester mapRow(ResultSet rs, int rowNum) throws SQLException {
            YearSemester yearSemester = new YearSemester();
            yearSemester.setYear(rs.getInt(Constants.COST_COL_DPS_COURSE_YEAR));
            yearSemester.setSemesterCode(rs.getInt(Constants.COST_COL_DPS_SEMESTER_CODE));
            yearSemester.setSemesterAbbr(rs.getString(Constants.COST_COL_DPS_ABR_SEM));
            yearSemester.setSemesterName(rs.getString(Constants.COST_COL_DPS_SEMESTER_NAME));
            return yearSemester;
        }
    };

    Map<String, String> namedParameterMap = new HashMap<String, String>();
    namedParameterMap.put("paramLocale", locale.getLanguage());
    return nPJdbcTemplDps.queryForObject(SQL_DPS_CURRENT_YR_SEM, namedParameterMap, mapper);
}

From source file:com.frameworkset.platform.cms.driver.i18n.CmsLocaleManager.java

/**
 * Tries to find the given requested locale (eventually simplified) in the collection of available locales, 
 * if the requested locale is not found it will return the first match from the given list of default locales.<p>
 * //from w w  w. j a v a 2s .  c  o m
 * @param requestedLocale the requested locale, if this (or a simplified version of it) is available it will be returned
 * @param defaults a list of default locales to use in case the requested locale is not available
 * @param available the available locales to find a match in
 * 
 * @return the best matching locale name or null if no name matches
 */
public Locale getBestMatchingLocale(Locale requestedLocale, List defaults, Collection available) {

    if ((available == null) || available.isEmpty()) {
        // no locales are available at all
        return null;
    }

    // the requested locale is the match we want to find most
    if (available.contains(requestedLocale)) {
        // check if the requested locale is directly available
        return requestedLocale;
    }
    if (requestedLocale.getVariant().length() > 0) {
        // locale has a variant like "en_EN_whatever", try only with language and country 
        Locale check = new Locale(requestedLocale.getLanguage(), requestedLocale.getCountry(), "");
        if (available.contains(check)) {
            return check;
        }
    }
    if (requestedLocale.getCountry().length() > 0) {
        // locale has a country like "en_EN", try only with language
        Locale check = new Locale(requestedLocale.getLanguage(), "", "");
        if (available.contains(check)) {
            return check;
        }
    }

    // available locales do not match the requested locale
    if ((defaults == null) || defaults.isEmpty()) {
        // if we have no default locales we are out of luck
        return null;
    }

    // no match found for the requested locale, return the first match from the default locales
    return getFirstMatchingLocale(defaults, available);
}

From source file:om.edu.squ.squportal.portlet.dps.grade.gradechange.db.GradeChangeDBImpl.java

/**
 * // w  ww.  ja  v a  2  s.co  m
 * method name  : getGrades
 * @param locale
 * @return
 * GradeChangeDBImpl
 * return type  : List<Grade>
 * 
 * purpose      : list of all grade values
 *
 * Date          :   Nov 19, 2017 1:44:54 PM
 */
public List<Grade> getGrades(String lAbrCourseNo, Locale locale) {
    String SQL_GRADE_VALUE_LIST = queryGradeChange.getProperty(Constants.CONST_SQL_GRADE_VALUE_LIST);
    RowMapper<Grade> rowMapper = new RowMapper<Grade>() {

        @Override
        public Grade mapRow(ResultSet rs, int rowNum) throws SQLException {
            Grade grade = new Grade();
            grade.setGradeCode(rs.getInt(Constants.CONST_COLMN_GRADE_CODE));
            grade.setGradeVal(rs.getString(Constants.CONST_COLMN_GRADE_VAL));
            return grade;
        }
    };

    Map<String, String> namedParameterMap = new HashMap<String, String>();
    namedParameterMap.put("paramLocale", locale.getLanguage());
    namedParameterMap.put("paramLAbrCrsNo", lAbrCourseNo);

    return nPJdbcTemplDpsGradeChange.query(SQL_GRADE_VALUE_LIST, namedParameterMap, rowMapper);
}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerDlg.java

/**
 * Check the Database to see if the Locale is being used.
 * @param schemaTypeArg the which set of locales
 * @param locale the locale in question//from w w  w  . j a  v a 2 s  .  co m
 * @return true/false
 */
public boolean isLocaleInUseInDB(final Byte schemaTypeArg, final Locale locale) {

    Session session = HibernateUtil.getNewSession();
    try {
        String sql = String.format(
                "SELECT DISTINCT nms.language FROM SpLocaleContainer as ctn " + "INNER JOIN ctn.items as itm "
                        + "INNER JOIN itm.names nms " + "INNER JOIN ctn.discipline as d "
                        + "WHERE  d.userGroupScopeId = DSPLNID AND nms.language = '%s' AND ctn.schemaType = %d",
                locale.getLanguage(), schemaTypeArg);
        sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql);
        Query query = session.createQuery(sql);
        List<?> list = query.list();
        return list.size() > 0;

    } catch (Exception ex) {
        ex.printStackTrace();
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SchemaLocalizerDlg.class, ex);

    } finally {
        session.close();
    }
    return false;
}

From source file:com.globalsight.everest.projecthandler.MachineTranslateAdapter.java

public boolean isSupportsLocalePair(MachineTranslationProfile mt, Locale sourcelocale, Locale targetlocale) {
    boolean isSupportLocalePair = false;
    MachineTranslationExtentInfo result = null;

    EngineEnum ee = EngineEnum.getEngine(mt.getMtEngine());
    String lp = "";
    switch (ee) {
    case ProMT:/*  w w w. j  a v a2s.c  o  m*/
        lp = getLanguagePairNameForProMt(sourcelocale, targetlocale);
        break;
    case IPTranslator:
        return IPTranslatorUtil.supportsLocalePair(sourcelocale, targetlocale);
    case Asia_Online:
        lp = getLanguagePairNameForAo(sourcelocale, targetlocale);
        // Currently AO supports zh-CN, not support zh-HK and zh-TW.
        if (sourcelocale.getLanguage().equalsIgnoreCase("ZH")
                && !sourcelocale.getCountry().equalsIgnoreCase("CN")) {
            return false;
        }
        if (targetlocale.getLanguage().equalsIgnoreCase("ZH")
                && !targetlocale.getCountry().equalsIgnoreCase("CN")) {
            return false;
        }
        break;
    }
    try {
        Set lp2DomainCombinations = mt.getExInfo();
        if (lp2DomainCombinations != null && lp2DomainCombinations.size() > 0) {
            Iterator lp2DCIt = lp2DomainCombinations.iterator();
            while (lp2DCIt.hasNext()) {
                MachineTranslationExtentInfo aoLP2DC = (MachineTranslationExtentInfo) lp2DCIt.next();
                String lpName = aoLP2DC.getLanguagePairName();
                if (lpName != null && lpName.equalsIgnoreCase(lp)) {
                    result = aoLP2DC;
                    break;
                }
            }
        }
    } catch (Exception e) {
    }
    isSupportLocalePair = result == null ? false : true;

    return isSupportLocalePair;
}

From source file:be.fedict.eid.tsl.TrustServiceList.java

public void addSchemeType(String schemeType, Locale locale) {
    NonEmptyMultiLangURIType uri = this.objectFactory.createNonEmptyMultiLangURIType();
    uri.setLang(locale.getLanguage());
    uri.setValue(schemeType);/*from  w ww.  ja  va2  s.com*/

    TSLSchemeInformationType schemeInformation = getSchemeInformation();
    NonEmptyMultiLangURIListType schemeTypeList = schemeInformation.getSchemeTypeCommunityRules();

    if (null == schemeTypeList) {
        schemeTypeList = this.objectFactory.createNonEmptyMultiLangURIListType();
        schemeInformation.setSchemeTypeCommunityRules(schemeTypeList);
    }
    schemeTypeList.getURI().add(uri);
}