Displaying literals with either current language tag or no language tag.

7 views
Skip to first unread message

Leif Warner

unread,
May 24, 2011, 9:58:22 PM5/24/11
to scardf
So, we can show a literal with something like
g/resource/property/asString
or one in a certain language with
g/resource/property/lexicIn(desired_language_tag)

I think for my cases, I would prefer to show the non-language-tagged
literal in the absence of a language specific one. (A label in
possibly the wrong language being better than no label, I'm thinking).

Do you know of a nice way of doing this with the existing converters,
or should I just run some kind of filter something like (_.langExt ==
"@en" || _.langExt == "")?

Hrm, now that I think of it, taking advantage of lexicIn return
Scala's Option type:
g/resource/property/lexicIn(en) orElse g/resource/property/
asString.option
works, just the g/r/p part is duplicated...

-Leif Warner

Hrvoje Simic

unread,
May 25, 2011, 5:02:38 AM5/25/11
to sca...@googlegroups.com
Just make a simple NodeBagConverter[Option[String]] that delegates to

b => b/lexicIn(en) orElse b/asString.option

If you call it "asEnStringOpt" you can use it everywhere:

graph/node/asEnStringOpt

How does that sound?

Again, this is off the top of my head.

Hrvoje

Reply all
Reply to author
Forward
0 new messages