News:

Join the Facebook Fan Page.

Main Menu

lang="xx"

Started by Vector’s Shadow, April 24, 2013, 04:51:39 PM

Previous topic - Next topic

Vector’s Shadow

After looking around the forum and the mods list, I still can't find anything about this, so maybe someone can tell me off the top of his/her head, is there a way to add the lang attribute to the forum's input fields without hacking it myself? I am asking after having done this already. My forum now has <html lang="en"> and the "en" changes to whatever the language pack thinks the code should be. Among other things, this results in Firefox's spell checker automatically switching its spelling dictionary, provided the right one is installed for the language.

Arantor

The only way to do it is to hack your index.template.php file to include it.

Vector’s Shadow

Right, but have I reinvented the wheel by doing so? I find it hard to believe that this hasn't been done.

Arantor

-sigh- That's why I said *the only way to do it*... because the default theme doesn't.

Mick.

It would be this part...
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>

I once changed it to <html lang="en"> but today i use the default line.

Vector’s Shadow

So what you both are saying is that nobody's done this officially yet. Is this a good idea to submit for 2.x+ development?

Edit: Oh, and by the way, there are other files with <html> tag, shouldn't they be changed, too?

Kindred

if you think it si important, and it's not in the codebase, then, YES... by all means. :)

no guarantee of every pull/push being accepted, but it never hurts to drop it on. :)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Vector’s Shadow

To be honest, I don't know the level of importance of this. It's more of a feature, really. Perhaps just put it in as a suggestion on the sugestions board here?

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Vector’s Shadow

Sorry, not sure what you are referring to by it.

Kindred

submit the pull request/change to the github for SMF 2.1 :)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

That's exactly what we're saying. It also hasn't been done in 2.1 yet (just checked)

Is it worth doing? Probably. Is it worth submitting to the trunk? That's debatable and primarily down to whether it'll get accepted by the devs and all the subsequent maintenance that goes with it (which is also quite surprising), because it doesn't actually correlate to the language packs that already exist.

The lang attribute uses ISO-639-1 country codes, but the language packs don't conform to that. For example, there is no valid country code that can be used for the UK, they would have to use 'en' regardless of locale settings.

I would note there was already discussion and wrangling of this for Wedge (and yes, we did already implement it there, just over 2 years ago though the commit note says that we were going to use proper language codes rather than repurposing $txt['lang_dictionary'] - so you'd have to update every language as well to do it properly)

Vector’s Shadow

So this quickly turned from a support request into a DIY. Not complaining or anything, just an observation. I'll see if I can figure out the least ugly way to accomplish this. Feels like too much of a hack. I might submit it if I like how it comes out, but don't hold your breath, as I probably won't have enough time to do it in the near future. Thanks to all who replied.

Mick.

If its that important, change it to:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

This alone will give you an xhtml error:
<html lang="en">

Vector’s Shadow

The actual line that I have looks like this, I just gave the abbreviated version:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
Is xml:lang="en" actually used by anything at all?

Arantor

Quote from: Vector's Shadow on April 24, 2013, 06:25:01 PM
So this quickly turned from a support request into a DIY. Not complaining or anything, just an observation. I'll see if I can figure out the least ugly way to accomplish this. Feels like too much of a hack. I might submit it if I like how it comes out, but don't hold your breath, as I probably won't have enough time to do it in the near future. Thanks to all who replied.

Considering that you said in your first reply that you'd already done it... and in the least ugly way possible at present...

As already mentioned, you can typically use $txt['lang_dictionary'] which is usually correct for this. Combine what Mick has said with testing for and outputting $txt['lang_dictionary'] and it'll do the job. You'll have to do it for every theme though (and so will any theme authors who port their 2.0 theme to 2.1)

In answer to your xml:lang question, you are supposed to include it but I'm not 100% sure off hand if it's *necessary*. (Should != must, and getting through the official spec is... time consuming) All the official examples in the spec do include it.

The reality is that there are currently three people with the developer badge and who have more important priorities than this in the grand scheme of things. If you think it's important, commit it yourself because then you'll know it's been done. Otherwise you need to convince someone who has the time, energy and skill to do so. Sucks, but that's how it is.

Vector’s Shadow

Quote from: Arantor on April 24, 2013, 06:33:20 PM
You'll have to do it for every theme though (and so will any theme authors who port their 2.0 theme to 2.1)

This is rather offputting. Maybe a mod would be a better solution then?

Arantor

A mod solution is going to have exactly the same problem. Worse, because it'll have to edit every theme's index.template.php file unless you get into buffer rewrites (which is a form of voodoo reserved for special occasions only)

Vector’s Shadow

But that's the idea, instead of theme authors having to update their themes (and what if they are no longer active?), just update by using the package installer. I'm missing something, aren't I?

Arantor

Yup, mods do not play nicely with themes.

The instruction in a mod will be 'find/replace this code in index.template.php' and if you look through the support boards you'll find a vast number of people who've had issues with just that part of it.

Advertisement: