Class I18nHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.workflow.support.I18nHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
Helper for saxing i18n catalogs
-
Field Summary
Modifier and TypeFieldDescriptionprotected CurrentUserProvider
The current user providerprotected I18nUtils
I18n Utilsprotected ObservationManager
The observation managerprotected SourceResolver
The source resolverprotected WorkflowHelper
The workflow helperprotected WorkflowLanguageManager
The workflow language managerprotected WorkflowSessionHelper
The workflow session helperstatic final String
The helper role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
_saveI18nCatalog
(Map<I18nizableText, String> i18nMessages, String catalogPath, String language) Save the i18n catalog with new valuesstatic String
buildI18nWorkflowKey
(String workflowName) Build an i18n key for workflows like "WORKFLOW_[WORKFLOW_NAME]"void
Clear the i18n caches (ametys and cocoon)createNewI18nCatalogs
(Map<I18nizableText, Map<String, String>> translationsToConvert) Generate i18n catalog from workflow's new i18n translationsgenerateI18nKey
(String workflowName, String type, int workflowElementId) Generate unique key for workflow element labelGet the default language to use for the i18n translationgetPrefixCatalogLocation
(String catalogName) Get the overridable catalog location for a plugin, workspace or application.getWorkflowLabelKey
(String workflowName) Transform workflow name in unique I18n keyreadI18nCatalog
(Map<String, Map<I18nizableText, String>> i18nCatalogs, String path, String currentCatalog) Read existing i18n catalogvoid
saveCatalogs
(Map<String, Map<I18nizableText, String>> newI18nMessages, String currentCatalog) Sax new messages into i18N catalogsvoid
service
(ServiceManager manager) translateKey
(String workflowName, I18nizableText i18nKey, I18nizableText defaultKey) Translate i18n label for workflow element, return a default name if translation is not foundMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The helper role -
_i18nUtils
I18n Utils -
_workflowHelper
The workflow helper -
_workflowSessionHelper
The workflow session helper -
_workflowLanguageManager
The workflow language manager -
_sourceResolver
The source resolver -
_observationManager
The observation manager -
_currentUserProvider
The current user provider
-
-
Constructor Details
-
I18nHelper
public I18nHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getI18nDefaultLanguage
Get the default language to use for the i18n translation- Returns:
- a language code
-
translateKey
Translate i18n label for workflow element, return a default name if translation is not found- Parameters:
workflowName
- the workflow's unique namei18nKey
- an i18n key pointing to workflow element's labeldefaultKey
- a default i18n key for workflow element- Returns:
- a translated label
-
getWorkflowLabelKey
Transform workflow name in unique I18n key- Parameters:
workflowName
- the workflow's unique name- Returns:
- the workflow label I18n Key
-
generateI18nKey
Generate unique key for workflow element label- Parameters:
workflowName
- the workflow's unique nametype
- the workflow's element typeworkflowElementId
- the element's id- Returns:
- a unique i18n key
-
saveCatalogs
public void saveCatalogs(Map<String, Map<I18nizableText, throws ExceptionString>> newI18nMessages, String currentCatalog) Sax new messages into i18N catalogs- Parameters:
newI18nMessages
- catalog of the new i18N messages, key is language, value is map of i18nKeys, translationcurrentCatalog
- the current catalog- Throws:
Exception
- exception while reading file
-
clearCaches
Clear the i18n caches (ametys and cocoon) -
createNewI18nCatalogs
public Map<String,Map<I18nizableText, createNewI18nCatalogsString>> (Map<I18nizableText, Map<String, String>> translationsToConvert) Generate i18n catalog from workflow's new i18n translations- Parameters:
translationsToConvert
- the workflow to save's translation list: keys are future i18n key, values are maps of language codes and translations- Returns:
- a map of i18n catalogs : keys are languages, values are pair of i18nkey, translation
-
readI18nCatalog
public Map<I18nizableText,String> readI18nCatalog(Map<String, Map<I18nizableText, String>> i18nCatalogs, String path, String currentCatalog) Read existing i18n catalog- Parameters:
i18nCatalogs
- map of already read catalogspath
- the path to the file to readcurrentCatalog
- the catalog of the current workflow- Returns:
- the messages in the catalog as map
-
_saveI18nCatalog
protected void _saveI18nCatalog(Map<I18nizableText, String> i18nMessages, String catalogPath, String language) Save the i18n catalog with new values- Parameters:
i18nMessages
- the messages to savecatalogPath
- the path to the cataloglanguage
- the language of the translations
-
getPrefixCatalogLocation
Get the overridable catalog location for a plugin, workspace or application.- Parameters:
catalogName
- The catalog name- Returns:
- the location
-
buildI18nWorkflowKey
Build an i18n key for workflows like "WORKFLOW_[WORKFLOW_NAME]"- Parameters:
workflowName
- the workflow name- Returns:
- the built key
-