001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * matic 018 */ 019package org.nuxeo.ecm.platform.web.common.locale; 020 021import java.util.Locale; 022import java.util.TimeZone; 023 024import org.nuxeo.ecm.core.api.CoreSession; 025import org.nuxeo.ecm.core.api.DocumentModel; 026 027/** 028 * Provides locale and timezone. 029 * 030 * @since 5.6 031 */ 032public interface LocaleProvider { 033 034 /** 035 * @return the Locale to be used or null to let the caller decides. 036 */ 037 Locale getLocale(CoreSession session); 038 039 /** 040 * Gets the locale stored in the given user profile. 041 * 042 * @return the Locale to be used or null to let the caller decide 043 */ 044 Locale getLocale(DocumentModel userProfileDoc); 045 046 /** 047 * @return the Locale to be used or a default Locale 048 * @since 8.2 049 */ 050 Locale getLocaleWithDefault(CoreSession session); 051 052 /** 053 * @return the Locale stored in userProfile or a default Locale 054 * @since 8.2 055 */ 056 Locale getLocaleWithDefault(DocumentModel userProfileDoc); 057 058 /** 059 * @return the Timezone to be used or null to let the caller decides. 060 */ 061 TimeZone getTimeZone(CoreSession session); 062 063 /** 064 * Returns the default locale for given requested locale. 065 * <p> 066 * Checks if requested locale is part of supported locales, and fall-backs on a default locale if not (or if 067 * requested locale is empty). 068 * 069 * @since 8.4 070 */ 071 Locale getLocaleWithDefault(String requestedLocale); 072 073}