Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to deal with hyperlinks in jade templates? #83

Closed
binarykitchen opened this issue Apr 21, 2013 · 8 comments
Closed

How to deal with hyperlinks in jade templates? #83

binarykitchen opened this issue Apr 21, 2013 · 8 comments

Comments

@binarykitchen
Copy link

Hello again

I'm struggling to translate text in jade templates that contain hyperlinks. For example:

!{t('A <a href="/faq">faq page</a> to answer the usual questions')}

This does not look nice. I don't want to save HTML tags in translation files. How would you solve his?

@jamuhl
Copy link
Member

jamuhl commented Apr 21, 2013

we do it this way:

a(href!=t('ns.routes:link.info.href'))=t('ns.routes:link.info.text')

@binarykitchen
Copy link
Author

good to know to use namespaces but i meant a link inside a long sentence.

it would be wrong to split up the sentence into three fragments like

A
faq page
to answer the usual questions

translation would be horrible. advice?

@jamuhl
Copy link
Member

jamuhl commented Apr 22, 2013

if splitting is no option - where i agree you could still use postProcessors:

write the content in markdown or jade: http://i18next.com/node/pages/doc_templates.html

http://i18next.com/node/pages/doc_features.html#postprocessing

@binarykitchen
Copy link
Author

ok, i tried with markdown for postprocess but it generates invalid html code. this jade line here
p!=t('Especially [webcam integration (getUserMedia)](http://caniuse.com/stream).', {"postProcess": "markdown"})

produces duplicate p tags:
<p><p>Especially <a href="http://caniuse.com/stream">webcam integration (getUserMedia)</a>.</p></p>

why?

postprocessor is normal as suggested:

    i18n.addPostProcessor('markdown', function(val, key, opts) {
        return require('markdown').markdown.toHTML(val);
    });

@jamuhl
Copy link
Member

jamuhl commented Apr 22, 2013

markdown syntax a line is always a p tag.

just don't append to a p tag in your jade file:

div
  !=t('Especially [webcam integration (getUserMedia)](http://caniuse.com/stream).', {"postProcess": "markdown"})

@binarykitchen
Copy link
Author

ouch, that's not what i want.

i want to translate each single sentence within a long paragraph. translating a whole paragraph might be a bad idea. can we somehow tell markdown not to add a p tag?

@jamuhl
Copy link
Member

jamuhl commented Apr 22, 2013

don't know if there is some option to change this - my bet is no - as this is what markdown is for - publishing content.

@jamuhl
Copy link
Member

jamuhl commented Apr 22, 2013

not sure if the issues title is right markdown doesn't wrap in a p tag...it's more every sentence beginning with a newline will be a paragraph:

This is my first
sentence on multiple lines.

This another sentence.

will be parsed to:

<p>This is my first sentence on multiple lines.</p>
<p>This another sentence.</p>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants