These are chat archives for jescalan/roots

5th
Dec 2014
Augustin
@Augustin82
Dec 05 2014 16:33
hi @jenius!
Jeff Escalante
@jescalan
Dec 05 2014 17:39
hey there! sorry a little late
whats going on?
Augustin
@Augustin82
Dec 05 2014 18:14
heh, we keep missing each other it seems
Jeff Escalante
@jescalan
Dec 05 2014 18:14
here now :)
Augustin
@Augustin82
Dec 05 2014 18:14
yay
I asked you on Twitter about i18n
you told me there was work to be done =)
Jeff Escalante
@jescalan
Dec 05 2014 18:15
yeah, so it depends on how you want to do it really
there is a longer term plan to be able to generate multiple outputs from a single file
Augustin
@Augustin82
Dec 05 2014 18:16
my personal needs are very, very simple (which makes it all the more frustrating that I couldn't devise a simple solution)
Jeff Escalante
@jescalan
Dec 05 2014 18:16
which seems easy but actually is quite difficult if you take into consideration the wide range of plugins
Augustin
@Augustin82
Dec 05 2014 18:16
it's just a basic static site, a couple of pages, some news (the "posts")
Jeff Escalante
@jescalan
Dec 05 2014 18:16
the easiest patch at the moment is to use js on the front end to swap out templates
Augustin
@Augustin82
Dec 05 2014 18:17
i would have liked to do something as simple as dynamically generating two different sets of pages while keeping most of the code shared
Jeff Escalante
@jescalan
Dec 05 2014 18:17
yeah, that part is actually very hard, since roots is a static site generator
Augustin
@Augustin82
Dec 05 2014 18:17
I've had some success
Jeff Escalante
@jescalan
Dec 05 2014 18:18
so there's no dynamic part to it
Augustin
@Augustin82
Dec 05 2014 18:18
but I've ended up fighting with "jade"
i'll try and explain what i've done
i've created a map of objects, so typically {"en": {...}, "fr": {...}}
the plan was to create two index pages, index_en and index_fr
initialize the language within each page (so, page_lang = "en")
Jeff Escalante
@jescalan
Dec 05 2014 18:20
right
Augustin
@Augustin82
Dec 05 2014 18:20
and depending on that variable, roots would generate content using the correct "i18n" described in the map
it actually worked at one point, meaning that I could generate the correct "read in English"/"read in French" switch
problem was, i used a lot of includes to build my index page, and it seemed to only work for the first include
anything after that would crash, with jade telling me variables were undefined (while they were perfectly defined just one include before)
Jeff Escalante
@jescalan
Dec 05 2014 18:22
i cant really see a way that it would work smoothly without duplication when generating static pages for each
you'd need a single page to be rendered twice, each time with a different set of variables
Augustin
@Augustin82
Dec 05 2014 18:22
i must be doing something wrong, which is why i asked you on Twitter about tutorials
I don't understand why
Jeff Escalante
@jescalan
Dec 05 2014 18:23
really, it's because i18n would need a plugin or extension to roots core to work smoothly
right now roots maps input > transformations > output
it would need to essentially fork the input at a certain point
into two outputs
know what i mean?
like with a dynamic page, the server just renders it with different locals based on the request
Augustin
@Augustin82
Dec 05 2014 18:24
I think I do, but I think my approach would circumvent that, and it doesn't
let me type you a couple of lines
Jeff Escalante
@jescalan
Dec 05 2014 18:24
but with static, we would need to take one jade page and generate multiple pages out of that
Augustin
@Augustin82
Dec 05 2014 18:24
to illustrate better than I can do
Jeff Escalante
@jescalan
Dec 05 2014 18:24
ok
Augustin
@Augustin82
Dec 05 2014 18:25
i created "index_fr.jade" and "index_en.jade"
also, "_language_switch.jade"
in index_fr, I have, among other things
  • var current_language = "fr"
    include _language_switch
    include _header
    include _main
    include _footer
in index_en, the exact same, except setting the var to "en"
finally, in _language_switch, I have
case current_language
when "fr": output the link in English
when "en": output the link in French
default: whatever
this works fine
however
if i try to do the same trick in _footer
suddenly, it doesn't
jade complains current_language is not defined
maybe this is a completely stupid way of constructing the thing, i'm just starting with this (but you had guessed that already ^^)
I'm used to working with servers, the static thing is sometimes hard to wrap my head around =)
Jeff Escalante
@jescalan
Dec 05 2014 18:31
so the variable is resolving in one include but not another?
that's directly below it?
Augustin
@Augustin82
Dec 05 2014 18:37
(i'm done @jenius)
Jeff Escalante
@jescalan
Dec 05 2014 21:00
huh?
Augustin
@Augustin82
Dec 05 2014 22:56
wow, I'm only now seeing your answer o.O sorry about all that =/