com.google.caja.plugin.templates
Class Localizer
java.lang.Object
com.google.caja.plugin.templates.Localizer
public class Localizer
- extends java.lang.Object
Replaces message strings in IHTML with ones from a message bundle.
This does not require that the IHTML document contain any templates, so can
be used on a subset of IHTML that only includes ihtml:message
,
ihtml:ph
and ihtml:eph
to do message message substitution
that returns plain HTML.
This assumes that the input has been sanitized
.
- Author:
- mikesamuel@gmail.com
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
mq
private final MessageQueue mq
XML_NS
private static final java.lang.String XML_NS
- See Also:
- Constant Field Values
Localizer
public Localizer(MessageQueue mq)
- Parameters:
mq
- receives errors and warnings about undefined messages; and
missing, and extraneous placeholders.
localize
public void localize(org.w3c.dom.Element root,
IhtmlL10NContext cx)
- Replace
ihtml:message
elements with the messages in cx.
extractPlaceholders
private java.util.List<Localizer.Placeholder> extractPlaceholders(org.w3c.dom.Element message)
byName
private java.util.Map<java.lang.String,Localizer.Placeholder> byName(java.util.List<Localizer.Placeholder> phs)
extractMessages
public IhtmlL10NContext extractMessages(org.w3c.dom.Element ihtmlRoot)
messageToLocalizedHtml
private LocalizedHtml messageToLocalizedHtml(org.w3c.dom.Element message)
allMessages
private static java.lang.Iterable<org.w3c.dom.Element> allMessages(org.w3c.dom.Element root)
snapshot
private static <T> java.util.List<T> snapshot(java.lang.Iterable<T> it)
notifyUntranslatedMessage
private void notifyUntranslatedMessage(org.w3c.dom.Element message,
java.util.Locale locale)
notifyMissingPlaceholder
private void notifyMissingPlaceholder(FilePosition phLoc)
notifyMalformedMessage
private void notifyMalformedMessage(org.w3c.dom.Element message,
java.lang.String name)
notifyDupeMessage
private void notifyDupeMessage(org.w3c.dom.Element a,
org.w3c.dom.Element b)
notifyDupePlaceholder
private void notifyDupePlaceholder(Localizer.Placeholder ph,
Localizer.Placeholder orig)
tokensFromNode
public static java.lang.Iterable<Token<HtmlTokenType>> tokensFromNode(org.w3c.dom.Node n)
emitTokens
private static boolean emitTokens(org.w3c.dom.Node n,
java.util.List<Token<HtmlTokenType>> out)
emitEndOf
private static void emitEndOf(org.w3c.dom.Node n,
java.util.List<Token<HtmlTokenType>> out)
tagName
private static java.lang.String tagName(org.w3c.dom.Element e)
Copyright (C) 2008 Google Inc.
Licensed under the Apache License, Version 2.0