How do I feature multiple languages for my articles without messing up the navigation?
#95
Closed
opened 4 years ago by kolstadmagnus
·
5 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
I’m working on a blog for my studies in journalism. So far, it’s pure HTML & CSS—which is a nightmare to manage, of course. Migrating to Pollen, I’ve now hit a dead end.
Many of my articles are in two languages. (Sort of—it’s two standards of the same language.) I have my main language, Norwegian Bokmål, and then I have a different article in Norwegian Nynorsk available through a link at the beginning of the articles that feature it. However, since I don’t want these translated articles to be a part of the main-language website’s bottom navigation, I don’t include them in the
index.ptree
file. (I don’t want the user to have to click through to the same article twice—albeit in a different language—when navigating the website.)Of course, what I then get is an empty navigation bar at the bottom.
I figured I had to create a separate pagetree and template for these translated articles —
template-nynorsk.html.p
(as opposed to the maintemplate.html.p
) andnynorsk.ptree
(as opposed to the mainindex.ptree
). For the translated articles’ source files I include a◊(define-meta template "template-nynorsk.html")
. In this template, I include◊(define-meta pagetree "nynorsk.ptree")
. This new pagetree is the same as the old one, but with the articles I’ve translated into Nynorsk instead of the original ones.This didn’t solve my problem. The Pollen source files can’t find their previous and next articles—even though the new pagetree does feature these source files at
localhost:8080/nynorsk.ptree
.What must I do to get the navigation up and running?
(BTW: sincere apologies if the solution already resides somehwere in the Pollen documentation or here on GitHub.)
Pollen only recognizes one pagetree at a time (stored in the parameter
current-pagetree
). So the result here doesn’t surprise me. Your Nyorsk pages are in a pagetree that Pollen never reads. So the built-in pagetree functions likeprevious
andnext
don’t do anything.I would go about this a different way. I will assume that in cases where you have a Nyorsk translation, you want the navigation to be the same as the corrresponding Bokmål page. If that is so, then I would:
Use a single
template.html.p
for all the pages.Name the Nyorsk pages with some consistent convention. For instance, a Bokmål page
"klokken.html"
would have a translated version called"klokken-nyorsk.html"
.In your
template.html.p
, create your ownprevious
andnext
functions.First, the function will call
previous
(ornext
) frompollen/pagetree
and see if it gets a valid result. This should be true for all the Bokmål pages, since they are all listed inindex.ptree
.But if the result of this function call is
#false
, then you must be on a Nyorsk page. So derive the name of the corresponding Bokmål page (by operating onhere
), and callprevious
(ornext
) frompollen/pagetree
using this Bokmål pagenode. Since all the Bokmål pages are in the pagetree, this should give you the navigation you want.Alternative #1
You can use
parameterize
withcurrent-pagetree
to change the pagetree to"nyorsk.ptree"
when you’re on a Nyorsk page, like so:This will force
previous
(ornext
) to use a different pagetree. This would be useful if you wanted to link all the Nyorsk pages in a parallel navigation scheme. But if my assumption is correct that you want to duplicate the Bokmål navigation, then this approach wouldn’t work.Alternative #2
In cases where you have a Nyorsk translation, you could nest it inside the existing Bokmål page — thereby eliminating all the Nyorsk-specific source files — and use some other method (e.g. JavaScript) to switch between them. This won’t work if you specifically need a separate URL for the Nyorsk translation.
Thank you so much! I ended up choosing alternative #1, as that’s the result I was going for.
Before this issue is closed:
When extracting the
h1
of a source file to create the HTML<title>
for the browser window, I don’t get the full title if I use other tags within the◊h1
.This title, for example, outputs as only “Creating character:” in my browser window:
◊h1{Creating character: ◊em{The Catcher in the Rye}}
This also happens if I use line breaks within a title:
◊h1{«Nei» til tradisjonell reklame.
[line break in Pollen]«Nei» til uavhengig journalistikk?}
(This outputs as “«Nei» til tradisjonell reklame.”)
My template uses the code from the tutorial—
◊(select 'h1 doc)
. Is there a way to solve this using this approach? Or must I use◊(define-meta title "title-name")
and instead extract that in the template, like you do in TFL?Edit, for clarity: Of course, I don’t ask that italics or line breaks be in the browser window’s title. I only want the whole title to be there, without any formatting.
Navigating with an alternative pagetree: I should’ve mentioned that as an alternative to
parameterize
, you can simply pass the pagetree as a second argument toprevious
ornext
, for instance(previous here "nyorsk.ptree")
will work the same way.Generating title text: the problem is that you are using
select
(which only retrieves the first query result) instead ofselect*
(which you need in this case, because yourh1
contains multiple elements). Then you will have to convert these elements into a flat string by whatever means you find suitable (probably by usingtxexpr
functions)I see. Many thanks!