[webgen-users] Language names instead of codes + special characters (ISO-8859-1)

24 views
Skip to first unread message

Marcelo Schots

unread,
Oct 24, 2013, 4:32:24 PM10/24/13
to webgen...@rubyforge.org
Hi,

I had some issues while migrating my webgen website (0.5.x) to the format compatible with the latest version. I've tried to follow the instructions on the website, but two issues remain:

1) I couldn't find a way to present language names instead of their codes (i.e., "English" instead of "en").
Previously I used the langbar tag:

{langbar: {lang_names: {pt: Português, en: English}}}

It seems that the lang_names option was removed. Is there an explanation for that, or even a workaround? I am currently using the following, which only shows the language code:

{langbar: {show_own_lang: false}}

(yes, I chose not to present the own language, apart from the previous version, but this is not related to the issue)

2) As you may have noticed in the previous issue, I would like to present a Portuguese version of my website. I never found a way to use special characters in the template, so I always used the HTML encoding (see Português = Português), but now I am having problems also with the .page files (which always worked well for me). I already specify in the template the following:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang:}">

This worked well in webgen's previous versions. Now the generated webpage does not present the results as I expected.

I've tried to use the options presented in the configuration page related to escaping special HTML characters, but I didn't manage to solve this problem. Is there any information in the webgen page that can help me? I didn't find any, unfortunately.

Thanks in advance (and thanks to the webgen developers for such a nice project),
--
Marcelo

Thomas Leitner

unread,
Oct 26, 2013, 4:08:04 AM10/26/13
to webgen...@rubyforge.org
Hi Marcelo,

On 2013-10-24 18:32 -0200 Marcelo Schots wrote:
> 1) I couldn't find a way to present language names instead of their
> codes (i.e., "English" instead of "en").
> Previously I used the langbar tag:
>
> {langbar: {lang_names: {pt: Portugu&ecirc;s, en: English}}}
>
> It seems that the lang_names option was removed. Is there an
> explanation for that, or even a workaround?

The current workaround would be to create a custom tag template.

I have refactored tag.langbar one and a half years ago and I don't
remember why I removed the lang_names option. Probably because creating
a custom template for a tag is now possible.

However, I have re-implemented some functionality that allows basic
modification for some tags and therefore I should re-implement support
for the lang_names option, too. This will be in the next release.

> 2) As you may have noticed in the previous issue, I would like to
> present a Portuguese version of my website. I never found a way to
> use special characters in the template, so I always used the HTML
> encoding (see Português = Portugu&ecirc;s), but now I am having
> problems also with the .page files (which always worked well for me).
> I already specify in the template the following:
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "
> http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang:}">
>
> This worked well in webgen's previous versions. Now the generated
> webpage does not present the results as I expected.
>
> I've tried to use the options presented in the configuration page
> related to escaping special HTML characters, but I didn't manage to
> solve this problem. Is there any information in the webgen page that
> can help me? I didn't find any, unfortunately.

I can't really reproduce the problem.

One possible source for the problem may be the file encoding. You
specified 'iso-8859-1'. Try changing that to 'UTF-8' if the output of
the following command is also UTF-8:

ruby -e "puts Encoding.default_external"

If this doesn't work could you provide a small sample website that
exhibits this behavior?

Best regards,
Thomas
_______________________________________________
webgen-users mailing list
webgen...@rubyforge.org
http://rubyforge.org/mailman/listinfo/webgen-users

Marcelo Schots

unread,
Oct 26, 2013, 4:14:54 PM10/26/13
to webgen...@rubyforge.org
Hi Thomas, thanks for your answer.

> > 1) I couldn't find a way to present language names instead of their
> > codes (i.e., "English" instead of "en").
> > Previously I used the langbar tag:
> >
> > {langbar: {lang_names: {pt: Portugu&ecirc;s, en: English}}}
> >
> > It seems that the lang_names option was removed. Is there an
> > explanation for that, or even a workaround?
>
> The current workaround would be to create a custom tag template.
>
> I have refactored tag.langbar one and a half years ago and I don't
> remember why I removed the lang_names option. Probably because creating
> a custom template for a tag is now possible.
>
> However, I have re-implemented some functionality that allows basic
> modification for some tags and therefore I should re-implement support
> for the lang_names option, too. This will be in the next release.

I appreciate that, because indeed it is a useful feature for website visitors.
I've tried to change the template, but no success so far.

> > 2) As you may have noticed in the previous issue, I would like to
> > present a Portuguese version of my website. I never found a way to
> > use special characters in the template, so I always used the HTML
> > encoding (see Português = Portugu&ecirc;s), but now I am having
> > problems also with the .page files (which always worked well for me).
> > I already specify in the template the following:
> >
> > <?xml version="1.0" encoding="iso-8859-1"?>
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "
> > http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang:}">
> >
> > This worked well in webgen's previous versions. Now the generated
> > webpage does not present the results as I expected.
> >
> > I've tried to use the options presented in the configuration page
> > related to escaping special HTML characters, but I didn't manage to
> > solve this problem. Is there any information in the webgen page that
> > can help me? I didn't find any, unfortunately.
>
> I can't really reproduce the problem.
>
> One possible source for the problem may be the file encoding. You
> specified 'iso-8859-1'. Try changing that to 'UTF-8' if the output of
> the following command is also UTF-8:
>
> ruby -e "puts Encoding.default_external"

The output of this command is CP850.
After that, I''ve tried to change the encoding parts of the template
to CP850, but it just changed from a wrong reresentation to another
wrong one.

> If this doesn't work could you provide a small sample website that
> exhibits this behavior?

Please find an excerpt in
https://www.dropbox.com/sh/m55g0alsackjoe6/IsOvBks9QZ
The weird thing is that there is a new error message with this excerpt:

INFO Generating website...
INFO [update] </>
INFO [update] </contact.html>
INFO [create] </contact.pt.html>
webgen encountered a problem:
Error at content_processor.blocks in <C:/Users/Marcelo/.gem/ruby/1.9.1/gems/we
bgen-1.0.0/lib/webgen/content_processor/blocks.rb:~21> while rendering </contact
.pt.html>:
incompatible character encodings: CP850 and UTF-8

Thanks again for your support.

Best,
Marcelo Schots

Thomas Leitner

unread,
Oct 26, 2013, 5:28:07 PM10/26/13
to webgen...@rubyforge.org
Hi Marcelo,

On 2013-10-26 18:14 -0200 Marcelo Schots wrote:
> I appreciate that, because indeed it is a useful feature for website
> visitors. I've tried to change the template, but no success so far.

I have already implemented it, will be available in the next version.

> > If this doesn't work could you provide a small sample website that
> > exhibits this behavior?
>
> Please find an excerpt in
> https://www.dropbox.com/sh/m55g0alsackjoe6/IsOvBks9QZ
> The weird thing is that there is a new error message with this
> excerpt:

Thanks for the website. I have probably found the culprit (or one of
them) and fixed it in the Github repo. The problem stems from Ruby 1.9+
being encoding aware and therefore nearly all programs need to take
that into account.

Please try the latest version from Github to see if this also fixes the
problem on your side.

Best regards,
Thomas

Marcelo Schots

unread,
Oct 28, 2013, 1:38:36 PM10/28/13
to webgen...@rubyforge.org
Hi Thomas,

> Thanks for the website. I have probably found the culprit (or one of
> them) and fixed it in the Github repo. The problem stems from Ruby 1.9+
> being encoding aware and therefore nearly all programs need to take
> that into account.
>
> Please try the latest version from Github to see if this also fixes the
> problem on your side.

Problem fixed. Thank you so much! It's working perfectly.

>> I appreciate that, because indeed it is a useful feature for website
>> visitors. I've tried to change the template, but no success so far.
>
> I have already implemented it, will be available in the next version.

Thanks for implementing it. I've tried to re-generate the website with
this option (using the latest github version from master branch), but
I've got the same error. Maybe I'm doing something wrong, or it has
been implemented somewhere else.
I've updated that website directory that I've shared with you. Here's
what I changed:

{langbar: {lang_names: {pt: Portugu&ecirc;s, en:
English}}{show_own_lang: false}}

And the error message I've got:

WARN Invalid configuration option 'lang_names' for tag 'langbar'
found in </default.template>

Best regards,
Marcelo Schots

Thomas Leitner

unread,
Oct 28, 2013, 3:25:00 PM10/28/13
to webgen...@rubyforge.org
Hi Marcelo,

On 2013-10-28 15:38 -0200 Marcelo Schots wrote:
> > Please try the latest version from Github to see if this also fixes
> > the problem on your side.
>
> Problem fixed. Thank you so much! It's working perfectly.

Perfect!

> Thanks for implementing it. I've tried to re-generate the website with
> this option (using the latest github version from master branch), but
> I've got the same error. Maybe I'm doing something wrong, or it has
> been implemented somewhere else.
> I've updated that website directory that I've shared with you. Here's
> what I changed:
>
> {langbar: {lang_names: {pt: Portugu&ecirc;s, en:
> English}}{show_own_lang: false}}

I have renamed 'lang_names' to 'mapping' because this shows better what
is meant since the mapped values can contain anything, not just the
language names.

Best regards,
Thomas

Marcelo Schots

unread,
Oct 28, 2013, 5:39:47 PM10/28/13
to webgen...@rubyforge.org
Hey Thomas,

> I have renamed 'lang_names' to 'mapping' because this shows better what
> is meant since the mapped values can contain anything, not just the
> language names.

Got it. I've changed to

{langbar: {mapping: {pt: Portugu&ecirc;s, en: English}}{show_own_lang: false}}

and mapping worked just fine. However, both mapping and show_own_lang
options were not working simultaneously.
Then I changed to

{langbar: {show_own_lang: false, mapping: {pt: Portugu&ecirc;s, en: English}}}

and both are working now. :-)

Once more, thank you for your attention and support. Keep up the great work!

All the best,
Marcelo Schots
Reply all
Reply to author
Forward
0 new messages