Skip to content

Commit

Permalink
Support (locale:da)
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfrees committed Jul 9, 2015
1 parent b19582d commit a58bfcc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.daisy.pipeline.braille.common.Transform.Provider.util.logCreate;
import static org.daisy.pipeline.braille.common.Transform.Provider.util.logSelect;
import static org.daisy.pipeline.braille.common.Transform.Provider.util.memoize;
import static org.daisy.pipeline.braille.common.util.Locales.parseLocale;
import org.daisy.pipeline.braille.common.WithSideEffect;
import org.daisy.pipeline.braille.common.XProcTransform;
import org.daisy.pipeline.braille.libhyphen.LibhyphenHyphenator;
Expand Down Expand Up @@ -59,6 +60,7 @@ private void activate(ComponentContext context, final Map<?,?> properties) {
* Recognized features:
*
* - translator: Will only match if the value is `nota'.
* - locale: Will only match if the language subtag is 'da'.
* - grade: `1' or `2'.
*
*/
Expand Down Expand Up @@ -89,6 +91,9 @@ protected Transform.Provider.MemoizingProvider<NotaCSSBlockTransform> _withConte
protected final Iterable<WithSideEffect<NotaCSSBlockTransform,Logger>> __get(String query) {
Map<String,Optional<String>> q = new HashMap<String,Optional<String>>(parseQuery(query));
Optional<String> o;
if ((o = q.remove("locale")) != null)
if (!"da".equals(parseLocale(o.get()).getLanguage()))
return empty;
if ((o = q.remove("translator")) != null)
if (o.get().equals("nota"))
if ((o = q.remove("grade")) != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/xprocspec/test_translator.xprocspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<p:add-attribute match="/*" attribute-name="style" attribute-value="hyphens:auto"/>
<p:add-attribute match="html:p" attribute-name="style" attribute-value="display:block"/>
<px:transform type="css-block">
<p:with-option name="query" select="concat('(translator:nota)(grade:',$grade,')')"/>
<p:with-option name="query" select="concat('(translator:nota)(locale:da)(grade:',$grade,')')"/>
</px:transform>
<p:delete match="@style"/>
</p:declare-step>
Expand Down

0 comments on commit a58bfcc

Please sign in to comment.