public class TranslationUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
JCR_CONTENT_STR |
static String |
LANGUAGE_DETECTED_DATE_PROP |
static String |
LANGUAGE_PROP |
static String |
POST_EDITED_PROP |
static String |
TRANSLATION_DATE_PROP |
static String |
TRANSLATION_NODE_NAME |
Constructor and Description |
---|
TranslationUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
addLanguageCode(Resource resource,
Session session,
String property,
TranslationConstants.ContentType contentType,
TranslationManager tm) |
static boolean |
doDisplayTranslation(ResourceResolver resourceResolver,
Resource resource,
ClientUtilities clientUtils)
Gets the UGCTranslationMeta of the current node and determines if show the translation button Show translation
button only when UGC and page languages are valid and different.
|
static String |
getLanguageCode(String content,
TranslationConstants.ContentType contentType,
Resource resource,
TranslationManager tm) |
static Resource |
getNonUgcResource(Resource resource) |
static String |
getPageLanguage(ResourceResolver resourceResolver,
Resource ugcResource,
String uri,
String referer)
First the uri is checked to see if it is a request to /content/usergenerated,
if it is NOT the uri page locale is used
if it is we check if the "Common Store" solution is applied to the ugc resource
if the "Common Store" is NOT applied we use the locale of the ugc resource
if it is applied, we use the result of getUserLanguage()
if there is no applied user language we use the referer uri for locale.
|
static String |
getResourceLanguage(ResourceResolver rr,
Resource resource) |
static TranslationResults |
getTranslation(String fromLan,
String toLan,
String[] properties,
Resource resource,
TranslationManager tm) |
static TranslationResult |
getTranslation(String fromLan,
String toLan,
String str,
Resource resource,
TranslationManager tm) |
static TranslationUpdate |
getTranslationUpdate(String fromLan,
String toLan,
Resource resource,
TranslationManager tm,
String[] properties)
A functional implementation of a Translation Update - with no mutable side effects.
|
static String |
getUGCLanguage(Resource resource) |
static String |
getUserLanguage(ResourceResolver resourceResolver,
String userId) |
static Boolean |
languagesAreEquivalent(String fromLan,
String toLan)
Compares the language codes to determine if they are equivalent
|
static void |
saveTranslation(String toLan,
Map<String,String> translation,
Resource resource,
Session session) |
static void |
translateOnSave(String fromLan,
String toLan,
Resource resource,
Session session,
TranslationManager tm,
String[] properties) |
static UGCTranslationMeta |
ugcTranslationMeta(ResourceResolver resourceResolver,
Resource resource,
String toLanguage,
String[] properties,
String pagePath,
String userId)
Gets the UGC translation information including what to translate, ugc language and page language.
|
static String |
uriToResourcePath(String uri) |
public static final String TRANSLATION_NODE_NAME
public static final String LANGUAGE_PROP
public static final String TRANSLATION_DATE_PROP
public static final String LANGUAGE_DETECTED_DATE_PROP
public static final String POST_EDITED_PROP
public static final String JCR_CONTENT_STR
public static String addLanguageCode(Resource resource, Session session, String property, TranslationConstants.ContentType contentType, TranslationManager tm)
resource
- The UGC node that has been detected the language codesession
- The session to save the changes. If null, the session will not be saved.public static String getLanguageCode(String content, TranslationConstants.ContentType contentType, Resource resource, TranslationManager tm)
content
- The content to get language detected.public static Resource getNonUgcResource(Resource resource)
public static boolean doDisplayTranslation(ResourceResolver resourceResolver, Resource resource, ClientUtilities clientUtils)
resourceResolver
- ResourceResolver of the UGC noderesource
- Resource of the UGC nodepublic static String getUserLanguage(ResourceResolver resourceResolver, String userId)
public static String getUGCLanguage(Resource resource)
public static String getPageLanguage(ResourceResolver resourceResolver, Resource ugcResource, String uri, String referer)
resourceResolver
- ugcResource
- uri
- referer
- public static String getResourceLanguage(ResourceResolver rr, Resource resource)
public static UGCTranslationMeta ugcTranslationMeta(ResourceResolver resourceResolver, Resource resource, String toLanguage, String[] properties, String pagePath, String userId)
resource
- From User generated noderesourceResolver
- The Resource Resolverpublic static TranslationResult getTranslation(String fromLan, String toLan, String str, Resource resource, TranslationManager tm)
fromLan
- From which languagetoLan
- To which languagestr
- The string to translatepublic static void saveTranslation(String toLan, Map<String,String> translation, Resource resource, Session session)
toLan
- To which languagetranslation
- The string to translateresource
- The comment node resource to translatesession
- Session to save the changes in jcr. If the session is null, then the session will not be saved
and no version will be checked inpublic static void translateOnSave(String fromLan, String toLan, Resource resource, Session session, TranslationManager tm, String[] properties)
fromLan
- From which languagetoLan
- To which languageresource
- The comment node to translatesession
- Session to save the changespublic static TranslationUpdate getTranslationUpdate(String fromLan, String toLan, Resource resource, TranslationManager tm, String[] properties)
fromLan
- From which languagetoLan
- To which languageresource
- The comment node to translatetm
- TranslationManager serviceproperties
- Translation propertiespublic static TranslationResults getTranslation(String fromLan, String toLan, String[] properties, Resource resource, TranslationManager tm)
fromLan
- From which languagetoLan
- To which language"Copyright © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"