This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 11 - Pages: 1 - Last Post: 03-Aug-2015 14:08 Last Post By: davidekholm
AndreWolff

Posts: 1,615
Registered: 14-Dec-2007
Please add a possibility to set a language meta tag
Posted: 20-Jul-2015 22:00
 
  Click to reply to this thread Reply
I just made an album of my trip through Sweden and Norway.

As you can see I display there a Google Ad-sense advertisement at the bottom of the intro page. This block shows normally Dutch text, but now I see mostly Swedish text.

To get there Dutch text I have to enter by hand in the heading the NL language meta tag:
<!DOCTYPE html>
<html>
<!-- saved from url=(0014)about:internet -->
<head>
<meta charset='UTF-8'>
<meta http-equiv="language" content="NL">

My request is do that via a jAlbum setting.

In the jAlbum advanced general settings it is possible to set already the Character coding, e.g. UTF-8.

Please extend this with a possibility to set the language code.
jGromit

Posts: 7,615
Registered: 31-Jan-2006
Re: Please add a possibility to set a language meta tag
Posted: 20-Jul-2015 22:50   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
I wouldn't want to see jAlbum automatically inserting something that fails HTML5 validation:

Using the meta element to specify the document-wide default language is obsolete. Consider specifying the language on the root element instead.


In short, it should be in the <html> tag, not in a <meta> tag.

And jAlbum doesn't currently insert the "charset" meta tag, either. The skin simply picks up the charset from the jAlbum options. There's no reason why a skin can't also grab the language setting, and do whatever it likes with it. Getting the language is a bit tricky, however. Plant this in your init.bsh:
import se.datadosen.jalbum.Config;
String language = Config.getConfig().getLanguage();
if (language.equals("default")) {
	language = System.getProperty("user.language");
}
Then in your index.htt, for example, you can just refer to ${language}.
AndreWolff

Posts: 1,615
Registered: 14-Dec-2007
Re: Please add a possibility to set a language meta tag
Posted: 21-Jul-2015 00:10   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
In short, it should be in the <html> tag, not in a <meta> tag.
That is also OK for me, if the result is the same.

And jAlbum doesn't currently insert the "charset" meta tag, either. The skin simply picks up the charset from the jAlbum options.
I propsed also that jAlbum should picks the lasnguage code from the jAlbum options, not automatically and if no language code is given, nothing should be inserted.
There's no reason why a skin can't also grab the language setting, and do whatever it likes with it. Getting the language is a bit tricky, however. Plant this in your init.bsh:
The language has nothing to do with the skin, the problem is the same for all skins, so it should be done in the JAlbum part as is done with the Character coding.
jGromit

Posts: 7,615
Registered: 31-Jan-2006
Re: Please add a possibility to set a language meta tag
Posted: 21-Jul-2015 00:20   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
I propsed also that jAlbum should picks the lasnguage code from the jAlbum options...

That's exactly what the code I posted above does. It picks up the language you have chosen for jAlbum. Are you proposing some second language choice, somewhere else?
AndreWolff

Posts: 1,615
Registered: 14-Dec-2007
Re: Please add a possibility to set a language meta tag
Posted: 21-Jul-2015 00:31   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
That's exactly what the code I posted above does. It picks up the language you have chosen for jAlbum. Are you proposing some second language choice, somewhere else?
No, I see you are using the language defined in the jAlbum preferences, while I was thinking on the jAlbum project settings.

You are correct, you could use that too, and because not all skins use the html5 code, you have to do it in the skin.

Thanks for your help!
jGromit

Posts: 7,615
Registered: 31-Jan-2006
Re: Please add a possibility to set a language meta tag
Posted: 21-Jul-2015 00:33   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
The language has nothing to do with the skin, the problem is the same for all skins, so it should be done in the JAlbum part as is done with the Character coding.

That's exactly the way it is now. The jAlbum core doesn't insert the charset into the HTML code of the album pages - the skins do that on their own. And that's a good thing, because a skin written in HTML5 needs to use that charset differently from a skin written in XHTML or HTML4.

Similarly, the jAlbum core doesn't insert the language into the HTML code of the album pages. It makes a variable available to you, the skin developer. You can insert it into your pages in whatever way you need.

And there's no such thing as "no language" - there is always a selected language in jAlbum.
AndreWolff

Posts: 1,615
Registered: 14-Dec-2007
Re: Please add a possibility to set a language meta tag
Posted: 21-Jul-2015 08:56   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
Similarly, the jAlbum core doesn't insert the language into the HTML code of the album pages. It makes a variable available to you, the skin developer. You can insert it into your pages in whatever way you need.
Yes, but it is a weak point that I should insert code in init.bsh to get the language code.
This should in that case be done in all skins, so it is much better to move that part of code to the jAlbum code.

So I change my request into:

Please add a global variable for the language code in such a way that I have no code to insert in init.bsh.
RobM

Posts: 3,175
Registered: 4-Aug-2006
Re: Please add a possibility to set a language meta tag
Posted: 21-Jul-2015 13:10   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
I am curious as to why the language displayed suddenly changed from Dutch to Swedish, what changed and what caused it?
AndreWolff

Posts: 1,615
Registered: 14-Dec-2007
Re: Please add a possibility to set a language meta tag
Posted: 21-Jul-2015 21:07   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
I am curious as to why the language displayed suddenly changed from Dutch to Swedish, what changed and what caused it?
Only the text in the Google ad-sense advertisement did change from Dutch to Swedisch. I don't know how Google defines the language, but I assume it will look at the language meta tag.
jGromit

Posts: 7,615
Registered: 31-Jan-2006
Re: Please add a possibility to set a language meta tag
Posted: 21-Jul-2015 21:35   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
It isn't nearly that simple.

From https://support.google.com/adsense/answer/2753586?hl=en

In addition, we may look at the language of the pages a user is viewing or has recently viewed to determine which ads to show. This means that we may detect the language from either pages that the person had viewed in the past, or the page that they are currently viewing. In this case, AdSense may target ads in the user's detected language rather than in the language of your content.

And some of the targeting is based on IP address: https://support.google.com/adsense/answer/9720?hl=en&ref_topic=1628432

In short, setting a single language tag in your content may make little or no difference.
RobM

Posts: 3,175
Registered: 4-Aug-2006
Re: Please add a possibility to set a language meta tag
Posted: 21-Jul-2015 22:07   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
I thought it might be to do with Google doing its usual thing, not really anything to do with jAlbum.
As for using Adsense why bother? Is it really such a money spinner? If it is I definitely wouldn't use it unless it was worth the trouble of filling in tax returns each year! ;)
davidekholm

Posts: 3,430
Registered: 18-Oct-2002
Re: Please add a possibility to set a language meta tag
Posted: 03-Aug-2015 14:08   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
The shortest way to insert the language code in an equivalent way to jGromits solutions is to paste the following code snipped int your index.htt:
<%= Config.getConfig().getInterpretedLanguage() %>
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums