Package org.ametys.core.resources
Class I18nTextResourceHandler
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.resources.SimpleResourceHandler
-
- org.ametys.core.resources.I18nTextResourceHandler
-
- All Implemented Interfaces:
ResourceHandler,LogEnabled,Contextualizable,Serviceable
- Direct Known Subclasses:
JSResourceHandler
public class I18nTextResourceHandler extends SimpleResourceHandler implements Contextualizable
This class generates a translated version of an input file. It is designed to handle the following notation : {{i18n x}}
When encountering this pattern, we instantiate anI18nizableTextwith x and try to translate it.
Unknown translations are logged and do not prevent the generation process from continuing.
-
-
Field Summary
Fields Modifier and Type Field Description protected Context_contextThe application context-
Fields inherited from class org.ametys.core.resources.SimpleResourceHandler
_objectModel, _parameters, _readForDownload, _requestedLocation, _resolver, _source
-
-
Constructor Summary
Constructors Constructor Description I18nTextResourceHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcontextualize(Context context)voidgenerate(OutputStream out)Generate the resource configured during setup, and output itSerializablegetKey()Get the unique key for this resource, for cache purpose.protected StringgetLocale()Retrieve the locale from the parametersvoidservice(ServiceManager serviceManager)Sourcesetup(String location, Map objectModel, Parameters parameters, boolean readForDownload)Initialize the resource handler with a resource.-
Methods inherited from class org.ametys.core.resources.SimpleResourceHandler
getLastModified, getMimeType, getValidity
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.core.resources.ResourceHandler
acceptRanges, generate, getLength, shouldUseSourceContentLength
-
-
-
-
Constructor Detail
-
I18nTextResourceHandler
public I18nTextResourceHandler()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classSimpleResourceHandler- Throws:
ServiceException
-
setup
public Source setup(String location, Map objectModel, Parameters parameters, boolean readForDownload) throws ProcessingException, IOException
Description copied from interface:ResourceHandlerInitialize the resource handler with a resource.- Specified by:
setupin interfaceResourceHandler- Overrides:
setupin classSimpleResourceHandler- Parameters:
location- The source uriobjectModel- The object modelparameters- The parametersreadForDownload- if the resource is to be downloaded and not rendered.- Returns:
- the resolved source
- Throws:
ProcessingException- If an error occursIOException- If an error occurs
-
getLocale
protected String getLocale()
Retrieve the locale from the parameters- Returns:
- The locale, or null
-
generate
public void generate(OutputStream out) throws IOException, ProcessingException
Description copied from interface:ResourceHandlerGenerate the resource configured during setup, and output it- Specified by:
generatein interfaceResourceHandler- Overrides:
generatein classSimpleResourceHandler- Parameters:
out- The output stream to write to- Throws:
IOException- If an error occursProcessingException- If an error occurs
-
getKey
public Serializable getKey()
Description copied from interface:ResourceHandlerGet the unique key for this resource, for cache purpose.- Specified by:
getKeyin interfaceResourceHandler- Overrides:
getKeyin classSimpleResourceHandler- Returns:
- The cache key.
-
-