Package com.google.gwt.i18n.linker
Class LocalePropertyProviderGenerator
java.lang.Object
com.google.gwt.i18n.linker.LocalePropertyProviderGenerator
- All Implemented Interfaces:
PropertyProviderGenerator
Generates a property provider implementation for the "locale" property.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongenerate
(TreeLogger logger, SortedSet<String> possibleValues, String fallback, SortedSet<ConfigurationProperty> configProperties) Generate a property provider.protected void
generateCookieLookup
(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body, String cookieName) Generate JS code that looks up the locale value from a cookie.protected void
generateInheritanceLookup
(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) Generate JS code that takes the value of the "locale" variable and finds parent locales until the value is a supported locale or the default locale.protected void
generateMetaLookup
(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) Generate JS code to fetch the locale from a meta property.protected void
generateQueryParamLookup
(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body, String queryParam) Generate JS code to get the locale from a query parameter.protected void
generateUserAgentLookup
(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) Generate JS code to fetch the locale from the user agent's compile-time locale.protected static boolean
Return true when the supplied value represents a true/yes/on value.protected boolean
validateCookieName
(String cookieName) Validate that a name is a valid cookie name.protected boolean
validateQueryParam
(String queryParam) Validate that a value is a valid query parameter name.
-
Field Details
-
LOCALE_QUERYPARAM
- See Also:
-
LOCALE_COOKIE
- See Also:
-
LOCALE_SEARCHORDER
- See Also:
-
LOCALE_USEMETA
- See Also:
-
LOCALE_USERAGENT
- See Also:
-
COOKIE_PATTERN
-
QUERYPARAM_PATTERN
-
-
Constructor Details
-
LocalePropertyProviderGenerator
public LocalePropertyProviderGenerator()
-
-
Method Details
-
isTrue
Return true when the supplied value represents a true/yes/on value.- Parameters:
value
-- Returns:
- true if the string represents true/yes/on
-
generate
public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback, SortedSet<ConfigurationProperty> configProperties) throws UnableToCompleteException Description copied from interface:PropertyProviderGenerator
Generate a property provider.- Specified by:
generate
in interfacePropertyProviderGenerator
- Parameters:
logger
- TreeLoggerpossibleValues
- the possible values of this propertyfallback
- the fallback value for this property, or nullconfigProperties
- the configuration properties for this module- Returns:
- the JS source of the property provider (the complete body of a JS function taking no arguments, including open/close braces), or null to use the default implementation in the property-provider tag
- Throws:
UnableToCompleteException
- after logging the message if processing is unable to continue
-
generateCookieLookup
protected void generateCookieLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body, String cookieName) throws UnableToCompleteException Generate JS code that looks up the locale value from a cookie.- Parameters:
logger
- logger to usebody
-cookieName
-- Throws:
UnableToCompleteException
-
generateInheritanceLookup
protected void generateInheritanceLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) throws UnableToCompleteException Generate JS code that takes the value of the "locale" variable and finds parent locales until the value is a supported locale or the default locale.- Parameters:
logger
- logger to usebody
-- Throws:
UnableToCompleteException
-
generateMetaLookup
protected void generateMetaLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) throws UnableToCompleteException Generate JS code to fetch the locale from a meta property.- Parameters:
logger
- logger to usebody
-- Throws:
UnableToCompleteException
-
generateQueryParamLookup
protected void generateQueryParamLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body, String queryParam) throws UnableToCompleteException Generate JS code to get the locale from a query parameter.- Parameters:
logger
- logger to usebody
- where to append JS outputqueryParam
- the query parameter to use- Throws:
UnableToCompleteException
-
generateUserAgentLookup
protected void generateUserAgentLookup(TreeLogger logger, com.google.gwt.user.rebind.SourceWriter body) throws UnableToCompleteException Generate JS code to fetch the locale from the user agent's compile-time locale.- Parameters:
logger
- logger to usebody
-- Throws:
UnableToCompleteException
-
validateCookieName
Validate that a name is a valid cookie name.- Parameters:
cookieName
-- Returns:
- true if cookieName is an acceptable cookie name
-
validateQueryParam
Validate that a value is a valid query parameter name.- Parameters:
queryParam
-- Returns:
- true if queryParam is a valid query parameter name.
-