001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.language;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    
020    import java.util.List;
021    import java.util.Locale;
022    
023    import javax.portlet.PortletConfig;
024    import javax.portlet.PortletRequest;
025    
026    import javax.servlet.http.HttpServletRequest;
027    import javax.servlet.http.HttpServletResponse;
028    import javax.servlet.jsp.PageContext;
029    
030    /**
031     * @author Brian Wing Shun Chan
032     */
033    public interface Language {
034    
035            public String format(Locale locale, String pattern, List<Object> arguments);
036    
037            public String format(Locale locale, String pattern, Object argument);
038    
039            public String format(
040                    Locale locale, String pattern, Object argument,
041                    boolean translateArguments);
042    
043            public String format(Locale locale, String pattern, Object[] arguments);
044    
045            public String format(
046                    Locale locale, String pattern, Object[] arguments,
047                    boolean translateArguments);
048    
049            public String format(
050                    PageContext pageContext, String pattern, LanguageWrapper argument);
051    
052            public String format(
053                    PageContext pageContext, String pattern, LanguageWrapper argument,
054                    boolean translateArguments);
055    
056            public String format(
057                    PageContext pageContext, String pattern, LanguageWrapper[] arguments);
058    
059            public String format(
060                    PageContext pageContext, String pattern, LanguageWrapper[] arguments,
061                    boolean translateArguments);
062    
063            public String format(
064                    PageContext pageContext, String pattern, Object argument);
065    
066            public String format(
067                    PageContext pageContext, String pattern, Object argument,
068                    boolean translateArguments);
069    
070            public String format(
071                    PageContext pageContext, String pattern, Object[] arguments);
072    
073            public String format(
074                    PageContext pageContext, String pattern, Object[] arguments,
075                    boolean translateArguments);
076    
077            public String format(
078                    PortletConfig portletConfig, Locale locale, String pattern,
079                    Object argument);
080    
081            public String format(
082                    PortletConfig portletConfig, Locale locale, String pattern,
083                    Object argument, boolean translateArguments);
084    
085            public String format(
086                    PortletConfig portletConfig, Locale locale, String pattern,
087                    Object[] arguments);
088    
089            public String format(
090                    PortletConfig portletConfig, Locale locale, String pattern,
091                    Object[] arguments, boolean translateArguments);
092    
093            public String get(Locale locale, String key);
094    
095            public String get(Locale locale, String key, String defaultValue);
096    
097            public String get(PageContext pageContext, String key);
098    
099            public String get(PageContext pageContext, String key, String defaultValue);
100    
101            public String get(PortletConfig portletConfig, Locale locale, String key);
102    
103            public String get(
104                    PortletConfig portletConfig, Locale locale, String key,
105                    String defaultValue);
106    
107            public Locale[] getAvailableLocales();
108    
109            public Locale[] getAvailableLocales(long groupId);
110    
111            public String getBCP47LanguageId(HttpServletRequest request);
112    
113            public String getBCP47LanguageId(Locale locale);
114    
115            public String getBCP47LanguageId(PortletRequest portletRequest);
116    
117            public String getCharset(Locale locale);
118    
119            public String getLanguageId(HttpServletRequest request);
120    
121            public String getLanguageId(Locale locale);
122    
123            public String getLanguageId(PortletRequest portletRequest);
124    
125            public Locale getLocale(long groupId, String languageCode);
126    
127            public Locale getLocale(String languageCode);
128    
129            public Locale[] getSupportedLocales();
130    
131            public String getTimeDescription(Locale locale, long milliseconds);
132    
133            public String getTimeDescription(
134                    Locale locale, long milliseconds, boolean approximate);
135    
136            public String getTimeDescription(Locale locale, Long milliseconds);
137    
138            public String getTimeDescription(
139                    PageContext pageContext, long milliseconds);
140    
141            public String getTimeDescription(
142                    PageContext pageContext, long milliseconds, boolean approximate);
143    
144            public String getTimeDescription(
145                    PageContext pageContext, Long milliseconds);
146    
147            public void init();
148    
149            public boolean isAvailableLanguageCode(String languageCode);
150    
151            public boolean isAvailableLocale(Locale locale);
152    
153            public boolean isAvailableLocale(long groupId, Locale locale);
154    
155            public boolean isAvailableLocale(long groupId, String languageId);
156    
157            public boolean isAvailableLocale(String languageId);
158    
159            public boolean isBetaLocale(Locale locale);
160    
161            public boolean isDuplicateLanguageCode(String languageCode);
162    
163            public boolean isInheritLocales(long groupId)
164                    throws PortalException, SystemException;
165    
166            public void resetAvailableGroupLocales(long groupId);
167    
168            public void resetAvailableLocales(long companyId);
169    
170            public void updateCookie(
171                    HttpServletRequest request, HttpServletResponse response,
172                    Locale locale);
173    
174    }