M i18n/en.txt => i18n/en.txt +4 -2
@@ 58,6 58,8 @@ CLEAR: CLEAR
# Other
Start!: Start!
Now: Now
-Upload: Upload
-to: to
+# Combines to "Upload to" with "Upload" linked.
+# Not great idea to split this phrase into 2 strings, but I don't want to link "to"...
+Upload Link: Upload
+Upload suffix: to
Restore defaults: Restore defaults
M src/Text/HTML/Form.hs => src/Text/HTML/Form.hs +12 -6
@@ 2,7 2,8 @@
-- | Parse webforms out of webpages
module Text.HTML.Form (Form(..), Input(..), OptionGroup(..), Option(..),
FileSelector(..), defaultFileData, ImageData(..), defaultImageData,
- TextArea(..), defaultTextArea, parseElement, parseDocument, ensureButtons) where
+ TextArea(..), defaultTextArea, parseElement, parseElement',
+ parseDocument, parseDocument', ensureButtons) where
import Data.Text (Text)
import qualified Data.Text as Txt
@@ 191,7 192,9 @@ mAttr :: Text -> Cursor -> Maybe Text
mAttr n = listToMaybe . laxAttribute n
-- | Parse a form from the selected HTML element.
parseElement :: Cursor -> Maybe Form
-parseElement el | _:_ <- laxElement "form" el = Just Form {
+parseElement = parseElement' "en"
+parseElement' :: Text -> Cursor -> Maybe Form
+parseElement' language el | _:_ <- laxElement "form" el = Just Form {
action = attr'' "action" el (fromMaybe nullURI . parseURIReference) ".",
enctype = attr "enctype" el "",
method = attr "method" el "GET",
@@ 202,7 205,8 @@ parseElement el | _:_ <- laxElement "form" el = Just Form {
formName = attr "name" el "",
rel = attr "rel" el "",
inputs = mapMaybe parseInput $ queryInputs el,
- lang = Txt.unpack $ attr "lang" el "en"
+ lang = Txt.unpack $ fromMaybe language $ listToMaybe $
+ mapMaybe (mAttr "lang") $ orSelf ancestor el
}
| otherwise = Nothing
@@ 434,10 438,12 @@ parseOptions el = [parseGroup opt
-- | Parse a named or numerically-indexed form from an HTML document.
parseDocument :: Document -> Text -> Maybe Form
-parseDocument doc n
+parseDocument = parseDocument' "en"
+parseDocument' :: Text -> Document -> Text -> Maybe Form
+parseDocument' language doc n
| Just n' <- readMaybe $ Txt.unpack n, n' < length (forms doc') =
- parseElement (forms doc' !! n')
- | el:_ <- (forms >=> attributeIs "name" n) doc' = parseElement el
+ parseElement' language (forms doc' !! n')
+ | el:_ <- (forms >=> attributeIs "name" n) doc' = parseElement' language el
| otherwise = Nothing
where
forms = orSelf descendant >=> laxElement "form"
M src/Text/HTML/Form/WebApp/Ginger.hs => src/Text/HTML/Form/WebApp/Ginger.hs +2 -0
@@ 29,6 29,7 @@ import qualified Data.Map as M
import Text.HTML.Form.Validate (inputErrorMessage')
import Text.HTML.Form.Query (applyQuery)
+import Text.HTML.Form.I18n (stringsJSON)
-- | A key-value query string.
type Query = [(ByteString, Maybe ByteString)]
@@ 56,6 57,7 @@ template' name form ix input query ctxt'
Prelude.zip [0..] $ inputs form
ctxt "input" = input2gval language (ix, input) query
ctxt "xURI" = fromFunction xURI
+ ctxt "_" = toGVal $ stringsJSON language
ctxt x = ctxt' x
xURI [(_, uri)] = let uri' = Txt.unpack $ asText uri in
return$toGVal$Txt.pack $ escapeURIString isUnescapedInURIComponent uri'
M tpl/cal/year-numpad.html => tpl/cal/year-numpad.html +1 -1
@@ 20,7 20,7 @@
<td><a href=":3{{Q}}">3</a></td>
</tr>
<tr>
- <td><a href="-{{Q}}">DEL</a></td>
+ <td><a href="-{{Q}}">{{ _["DEL"] }}</a></td>
<td><a href=":0{{Q}}">0</a></td>
<td><a href="..{{Q}}">✓</a></td>
</tr>
M tpl/gregorian.html => tpl/gregorian.html +12 -12
@@ 51,18 51,18 @@
<div class="multi">
{% if input.inputType != "time" %}
<ul>
- <li><a href="month=0{{Q}}">January</a></li>
- <li><a href="month=1{{Q}}">Febuary</a></li>
- <li><a href="month=2{{Q}}">March</a></li>
- <li><a href="month=3{{Q}}">April</a></li>
- <li><a href="month=4{{Q}}">May</a></li>
- <li><a href="month=5{{Q}}">June</a></li>
- <li><a href="month=6{{Q}}">July</a></li>
- <li><a href="month=7{{Q}}">August</a></li>
- <li><a href="month=8{{Q}}">September</a></li>
- <li><a href="month=9{{Q}}">October</a></li>
- <li><a href="month=10{{Q}}">November</a></li>
- <li><a href="month=11{{Q}}">December</a></li>
+ <li><a href="month=0{{Q}}">{{ _["January"] }}</a></li>
+ <li><a href="month=1{{Q}}">{{ _["February"] }}</a></li>
+ <li><a href="month=2{{Q}}">{{ _["March"] }}</a></li>
+ <li><a href="month=3{{Q}}">{{ _["April"] }}</a></li>
+ <li><a href="month=4{{Q}}">{{ _["May"] }}</a></li>
+ <li><a href="month=5{{Q}}">{{ _["June"] }}</a></li>
+ <li><a href="month=6{{Q}}">{{ _["July"] }}</a></li>
+ <li><a href="month=7{{Q}}">{{ _["August"] }}</a></li>
+ <li><a href="month=8{{Q}}">{{ _["September"] }}</a></li>
+ <li><a href="month=9{{Q}}">{{ _["October"] }}</a></li>
+ <li><a href="month=10{{Q}}">{{ _["November"] }}</a></li>
+ <li><a href="month=11{{Q}}">{{ _["December"] }}</a></li>
</ul>
{% endif %}
M tpl/image-button.html => tpl/image-button.html +1 -1
@@ 9,7 9,7 @@
<div>{{ input.description }}</div>
<hr />
<!-- TODO: Internationalize! -->
- <p><a href="_{{Q}}">Upload</a> to
+ <p><a href="_{{Q}}">{{ _["Upload Link"] }}</a> {{ _["Upload Suffix"] }}
<code>{{ input.form.action|default(form.action) }}
({{ input.form.method|default(form.method) }})</code></p>
</section>{%- endblock -%}
M tpl/keyboards/latin1.html => tpl/keyboards/latin1.html +3 -3
@@ 70,9 70,9 @@
<td colspan="2"><a href=":.org{{Q}}">.org</a>
</tr>{% endif %}
<tr>
- <td colspan="2"><a href=":%20{{Q}}">SPACE</a></td>
- <td colspan="2"><a href="-{{Q}}">DEL</a></td>
- <td colspan="2"><a href="={{Q}}">CLEAR</a></td>
+ <td colspan="2"><a href=":%20{{Q}}">{{ _["SPACE"] }}</a></td>
+ <td colspan="2"><a href="-{{Q}}">{{ _["DEL"] }}</a></td>
+ <td colspan="2"><a href="={{Q}}">{{ _["CLEAR"] }}</a></td>
</tr>
</table>
</section>{%- endblock -%}
M tpl/keyboards/latin1/latin1-accent-lower.html => tpl/keyboards/latin1/latin1-accent-lower.html +3 -3
@@ 62,9 62,9 @@
</tr>{% endif %}
<tr>
<td><a href=":{{'þ'|xURI}}{{Q}}">þ</a></td>
- <td><a href=":%20{{Q}}">SPACE</a></td>
- <td colspan="2"><a href="-{{Q}}">DEL</a></td>
- <td colspan="2"><a href="={{Q}}">CLEAR</a></td>
+ <td><a href=":%20{{Q}}">{{ _["SPACE"] }}</a></td>
+ <td colspan="2"><a href="-{{Q}}">{{ _["DEL"] }}</a></td>
+ <td colspan="2"><a href="={{Q}}">{{ _["CLEAR"] }}</a></td>
</tr>
</table>
</section>{%- endblock -%}
M tpl/keyboards/latin1/latin1-accent.html => tpl/keyboards/latin1/latin1-accent.html +3 -3
@@ 63,9 63,9 @@
</tr>{% endif %}
<tr>
<td><a href=":{{'Þ'|xURI}}{{Q}}">Þ</a></td>
- <td><a href=":%20{{Q}}">SPACE</a></td>
- <td colspan="2"><a href="-{{Q}}">DEL</a></td>
- <td colspan="2"><a href="={{Q}}">CLEAR</a></td>
+ <td><a href=":%20{{Q}}">{{ _["SPACE"] }}</a></td>
+ <td colspan="2"><a href="-{{Q}}">{{ _["DEL"] }}</a></td>
+ <td colspan="2"><a href="={{Q}}">{{ _["CLEAR"] }}</a></td>
</tr>
</table>
</section>{%- endblock -%}
M tpl/keyboards/latin1/latin1-symbol.html => tpl/keyboards/latin1/latin1-symbol.html +3 -3
@@ 103,9 103,9 @@
</tr>{% endif %}
<tr>
<td><a href=":{{'+'|xURI}}{{Q}}">+</a></td>
- <td colspan="2"><a href=":%20{{Q}}">SPACE</a></td>
- <td colspan="2"><a href="-{{Q}}">DEL</a></td>
- <td colspan="2"><a href="={{Q}}">CLEAR</a></td>
+ <td colspan="2"><a href=":%20{{Q}}">{{ _["SPACE"] }}</a></td>
+ <td colspan="2"><a href="-{{Q}}">{{ _["DEL"] }}</a></td>
+ <td colspan="2"><a href="={{Q}}">{{ _["CLEAR"] }}</a></td>
</tr>
</table>
</section>{%- endblock -%}
M tpl/keyboards/latin1/latin1-upper.html => tpl/keyboards/latin1/latin1-upper.html +3 -3
@@ 70,9 70,9 @@
<td colspan="2"><a href=":.org{{Q}}">.org</a>
</tr>{% endif %}
<tr>
- <td colspan="2"><a href=":%20{{Q}}">SPACE</a></td>
- <td colspan="2"><a href="-{{Q}}">DEL</a></td>
- <td colspan="2"><a href="={{Q}}">CLEAR</a></td>
+ <td colspan="2"><a href=":%20{{Q}}">{{ _["SPACE"] }}</a></td>
+ <td colspan="2"><a href="-{{Q}}">{{ _["DEL"] }}</a></td>
+ <td colspan="2"><a href="={{Q}}">{{ _["CLEAR"] }}</a></td>
</tr>
</table>
</section>{%- endblock -%}
M tpl/number.html => tpl/number.html +3 -3
@@ 16,19 16,19 @@
<td><a href=":4{{Q}}">4</a></td>
<td><a href=":5{{Q}}">5</a></td>
<td><a href=":6{{Q}}">6</a></td>
- <td><a href=":%20{{Q}}">SPACE</a></td>
+ <td><a href=":%20{{Q}}">{{ _["SPACE"] }}</a></td>
</tr>
<tr>
<td><a href=":1{{Q}}">1</a></td>
<td><a href=":2{{Q}}">2</a></td>
<td><a href=":3{{Q}}">3</a></td>
- <td><a href="-{{Q}}">DEL</a></td>
+ <td><a href="-{{Q}}">{{ _["DEL"] }}</a></td>
</tr>
<tr>
<td><a href=":.{{Q}}">.</a></td>
<td><a href=":0{{Q}}">0</a></td>
<td><a href=":,{{Q}}">,</a></td>
- <td><a href="={{Q}}">CLEAR</a></td>
+ <td><a href="={{Q}}">{{ _["CLEAR"] }}</a></td>
</tr>
</table>
</section>{%- endblock -%}
M tpl/reset.html => tpl/reset.html +1 -2
@@ 3,6 3,5 @@
{%- block main -%}<section>
<div>{{ input.description }}</div>
<hr />
- <!-- TODO: Internationalize! -->
- <p>Restore <a href="_">defaults</a>!</p>
+ <p><a href="_">{{ _["Restore defaults"] }}</a></p>
</section>{%- endblock -%}
M tpl/submit.html => tpl/submit.html +1 -1
@@ 9,6 9,6 @@
<code>{{ input.form.action|default(form.action) }}
({{ input.form.method|default(form.method) }})</code></p>
{% else %}
- <p>Please correct errors listed in sidebar before submitting this form!</p>
+ <p>{{ _["errored"] }}</p>
{% endif %}
</section>{%- endblock -%}
M tpl/tel.html => tpl/tel.html +2 -2
@@ 14,13 14,13 @@
<td><a href=":4{{Q}}">4</a></td>
<td><a href=":5{{Q}}">5</a></td>
<td><a href=":6{{Q}}">6</a></td>
- <td><a href=":%20{{Q}}">SPACE</a></td>
+ <td><a href=":%20{{Q}}">{{ _["SPACE"] }}</a></td>
</tr>
<tr>
<td><a href=":1{{Q}}">1</a></td>
<td><a href=":2{{Q}}">2</a></td>
<td><a href=":3{{Q}}">3</a></td>
- <td><a href="-{{Q}}">DEL</a></td>
+ <td><a href="-{{Q}}">{{ _["DEL"] }}</a></td>
</tr>
<tr>
<td><a href=":*{{Q}}">*</a></td>