public class TranslationServiceGenerator extends AbstractAsyncGenerator
TranslationService
. This class is responsible for
scanning the classpath for all bundles, and then making them available during template
translation.
The TranslationService
can also be used directly in the Errai application by injecting
it. This allows translated strings to be used from Errai Java code, not just from templates.Constructor and Description |
---|
TranslationServiceGenerator() |
Modifier and Type | Method and Description |
---|---|
String |
generate(com.google.gwt.core.ext.TreeLogger logger,
com.google.gwt.core.ext.GeneratorContext context)
Called by
AbstractAsyncGenerator.generateAsync(TreeLogger, GeneratorContext) to carry out the actual code
generation. |
String |
generate(com.google.gwt.core.ext.TreeLogger logger,
com.google.gwt.core.ext.GeneratorContext context,
String typeName) |
protected static void |
generateI18nHelperFilesInto(Map<String,Set<String>> discoveredI18nMap,
Map<String,String> translationKeyFieldMap,
File destDir)
Generates all helper files that developers can use to assist with i18n work.
|
static String |
getLocaleFromBundlePath(String bundlePath)
Gets the locale information from the given bundle path.
|
protected static void |
recordBundleKeys(Map<String,Set<String>> discoveredI18nMap,
String locale,
String bundlePath)
Records all of the i18n keys found in the given bundle.
|
addCacheRelevantClass, addCacheRelevantClasses, generateAsync, getGeneratedCache, hasGenerationCache, isCacheValid, isRelevantNewClass, startAsyncGeneratorsAndWaitFor
public String generate(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.core.ext.GeneratorContext context, String typeName) throws com.google.gwt.core.ext.UnableToCompleteException
generate
in class com.google.gwt.core.ext.Generator
com.google.gwt.core.ext.UnableToCompleteException
public String generate(com.google.gwt.core.ext.TreeLogger logger, com.google.gwt.core.ext.GeneratorContext context)
AbstractAsyncGenerator
AbstractAsyncGenerator.generateAsync(TreeLogger, GeneratorContext)
to carry out the actual code
generation.generate
in class AbstractAsyncGenerator
context
- the generator context to use.protected static void recordBundleKeys(Map<String,Set<String>> discoveredI18nMap, String locale, String bundlePath)
discoveredI18nMap
- locale
- bundlePath
- public static String getLocaleFromBundlePath(String bundlePath)
bundlePath
- path to the message bundleprotected static void generateI18nHelperFilesInto(Map<String,Set<String>> discoveredI18nMap, Map<String,String> translationKeyFieldMap, File destDir)
discoveredI18nMap
- a map of keys found in all scanned bundlestranslationKeyFieldMap
- a map of translation keys found in TranslationKey
annotated fieldsdestDir
- where to write the *.json filescontext
- the generator contextCopyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.