001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.kernel.util.ResourceBundleLoader;
021    
022    import java.util.List;
023    import java.util.Locale;
024    import java.util.ResourceBundle;
025    import java.util.Set;
026    
027    import javax.portlet.PortletRequest;
028    
029    import javax.servlet.http.HttpServletRequest;
030    import javax.servlet.http.HttpServletResponse;
031    
032    /**
033     * @author Brian Wing Shun Chan
034     */
035    @ProviderType
036    public interface Language {
037    
038            public String format(
039                    HttpServletRequest request, String pattern, LanguageWrapper argument);
040    
041            public String format(
042                    HttpServletRequest request, String pattern, LanguageWrapper argument,
043                    boolean translateArguments);
044    
045            public String format(
046                    HttpServletRequest request, String pattern,
047                    LanguageWrapper[] arguments);
048    
049            public String format(
050                    HttpServletRequest request, String pattern, LanguageWrapper[] arguments,
051                    boolean translateArguments);
052    
053            public String format(
054                    HttpServletRequest request, String pattern, Object argument);
055    
056            public String format(
057                    HttpServletRequest request, String pattern, Object argument,
058                    boolean translateArguments);
059    
060            public String format(
061                    HttpServletRequest request, String pattern, Object[] arguments);
062    
063            public String format(
064                    HttpServletRequest request, String pattern, Object[] arguments,
065                    boolean translateArguments);
066    
067            public String format(Locale locale, String pattern, List<Object> arguments);
068    
069            public String format(Locale locale, String pattern, Object argument);
070    
071            public String format(
072                    Locale locale, String pattern, Object argument,
073                    boolean translateArguments);
074    
075            public String format(Locale locale, String pattern, Object[] arguments);
076    
077            public String format(
078                    Locale locale, String pattern, Object[] arguments,
079                    boolean translateArguments);
080    
081            public String format(
082                    ResourceBundle resourceBundle, String pattern, Object argument);
083    
084            public String format(
085                    ResourceBundle resourceBundle, String pattern, Object argument,
086                    boolean translateArguments);
087    
088            public String format(
089                    ResourceBundle resourceBundle, String pattern, Object[] arguments);
090    
091            public String format(
092                    ResourceBundle resourceBundle, String pattern, Object[] arguments,
093                    boolean translateArguments);
094    
095            public String get(
096                    HttpServletRequest request, ResourceBundle resourceBundle, String key);
097    
098            public String get(
099                    HttpServletRequest request, ResourceBundle resourceBundle, String key,
100                    String defaultValue);
101    
102            public String get(HttpServletRequest request, String key);
103    
104            public String get(
105                    HttpServletRequest request, String key, String defaultValue);
106    
107            public String get(Locale locale, String key);
108    
109            public String get(Locale locale, String key, String defaultValue);
110    
111            public String get(ResourceBundle resourceBundle, String key);
112    
113            public String get(
114                    ResourceBundle resourceBundle, String key, String defaultValue);
115    
116            public Set<Locale> getAvailableLocales();
117    
118            public Set<Locale> getAvailableLocales(long groupId);
119    
120            public String getBCP47LanguageId(HttpServletRequest request);
121    
122            public String getBCP47LanguageId(Locale locale);
123    
124            public String getBCP47LanguageId(PortletRequest portletRequest);
125    
126            public String getLanguageId(HttpServletRequest request);
127    
128            public String getLanguageId(Locale locale);
129    
130            public String getLanguageId(PortletRequest portletRequest);
131    
132            public Locale getLocale(long groupId, String languageCode);
133    
134            public Locale getLocale(String languageCode);
135    
136            public ResourceBundleLoader getPortalResourceBundleLoader();
137    
138            public Set<Locale> getSupportedLocales();
139    
140            public String getTimeDescription(
141                    HttpServletRequest request, long milliseconds);
142    
143            public String getTimeDescription(
144                    HttpServletRequest request, long milliseconds, boolean approximate);
145    
146            public String getTimeDescription(
147                    HttpServletRequest request, Long milliseconds);
148    
149            public String getTimeDescription(Locale locale, long milliseconds);
150    
151            public String getTimeDescription(
152                    Locale locale, long milliseconds, boolean approximate);
153    
154            public String getTimeDescription(Locale locale, Long milliseconds);
155    
156            public void init();
157    
158            public boolean isAvailableLanguageCode(String languageCode);
159    
160            public boolean isAvailableLocale(Locale locale);
161    
162            public boolean isAvailableLocale(long groupId, Locale locale);
163    
164            public boolean isAvailableLocale(long groupId, String languageId);
165    
166            public boolean isAvailableLocale(String languageId);
167    
168            public boolean isBetaLocale(Locale locale);
169    
170            public boolean isDuplicateLanguageCode(String languageCode);
171    
172            public boolean isInheritLocales(long groupId) throws PortalException;
173    
174            public String process(
175                    ResourceBundle resourceBundle, Locale locale, String content);
176    
177            public void resetAvailableGroupLocales(long groupId);
178    
179            public void resetAvailableLocales(long companyId);
180    
181            public void updateCookie(
182                    HttpServletRequest request, HttpServletResponse response,
183                    Locale locale);
184    
185    }