Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Textrichtung mit dir="ltr"/dir="rtl" und/oder Body-Klasse ausgeben #7171

Closed
michelbalzer opened this issue Jul 15, 2014 · 28 comments
Closed
Labels
Milestone

Comments

@michelbalzer
Copy link

Zusätzlich zu #7153 wäre ein Feld zur Definition der Textrichtung (LTR/RTL) nicht verkehrt, die dann auch als Body-Klasse verwendet wird. Könnte man in den Seiteneinstellungen in Nähe des Felds „Sprache“ setzen.

(auch mal bei change_language gewünscht: terminal42/contao-changelanguage#25)

@aschempp
Copy link
Member

Ich glaube RTL ist eher eine Frage des Seitenlayouts? Natürlich bezieht es sich auf die Sprache der Root-Seite, aber ein RTL braucht doch immer ein anderes Seitenlayout?

Ausserdem braucht es eigentlich keine Body-Klasse, weil mit html[dir=rtl] kannst du das ja bereits ansteuern.

@michelbalzer
Copy link
Author

Jein, wir haben letztens eine Seite mit arabischem Teil veröffentlicht, da sind wir mit einem Layout ausgekommen, haben halt nur alles anders ausgerichtet und uns da mit der .lang-ar-Klasse aus change_language und dem iflng-Insert-Tag beholfen.

html[dir=rtl] ginge auch, wird in Contao aber auch nicht ausgegeben. Oder geht das auch ohne explizite Nennung im CSS weil der Browser weiß, dass das eine RTL-Sprache ist, wenn da lang="ar" auftaucht? Hab ich nicht getestet.

Seiten- oder Layout-Einstellung ist aber trotzdem eine gute Frage. Einerseits bezieht es sich auf die Sprache, andererseits ist es aber auch eine darstellerische Sache. Tendiere aber inzwischen auch Richtung Seitenlayout.

@aschempp
Copy link
Member

dir=ltr wäre natürlich das, was neu hinzugefügt werden müsste. Siehe http://www.w3.org/International/questions/qa-html-dir

@michelbalzer michelbalzer changed the title Textrichtung in body-Klasse Textrichtung mit dir="ltr"/dir="rtl" und/oder Body-Klasse ausgeben Jul 15, 2014
@aschempp
Copy link
Member

Related to #3180

@aschempp
Copy link
Member

Also related to #4040 (comment)

@Toflar
Copy link
Member

Toflar commented Jul 15, 2014

Wobei man sagen muss, dass seit der 3.3 ein Anlegen einer "fe_page_ltr.html5" mit dem Inhalt

<?php
$this->extends('fe_page');
$this->language = $this->language . '" dir="ltr';
?>

bereits ausreichen würde. Okay, nicht gerade schön, aber ich wollt's trotzdem anbringen ;)

@hamidpeywasti
Copy link
Contributor

👍
Supporting RTL sush as LTR language must be one of Contao features. So why you do not add an atrribute to page body in layout or maybe in root page?

@fjacobi
Copy link

fjacobi commented Jul 19, 2014

+1
Language, Language fallback, RTL Language

@aschempp
Copy link
Member

I agree with @fjacobi now, this belongs to the language (so to the root page). My only question now: do we really have to ask this to the user? The information if a language is RTL is available, so we could automatically inject it?

I've done something similar. The solution is very simple:

// system/modules/core/languages/en/default.php
$GLOBALS['TL_LANG']['textDirection'] = 'ltr';

// system/modules/core/languages/ar/default.php
$GLOBALS['TL_LANG']['textDirection'] = 'rtl';

@fjacobi
Copy link

fjacobi commented Jul 19, 2014

Do we save language specific settings in language files?

@aschempp
Copy link
Member

@fjacobi
Copy link

fjacobi commented Jul 19, 2014

👍

@leofeyer
Copy link
Member

Do we really need to add this to the language files? According to this list of RTL languages, there are only four to consider. We might as well hardcode those in a getRtlLanguages() or isRlt($language) method.

@leofeyer
Copy link
Member

Here's a more complete list: http://en.wikipedia.org/wiki/Right-to-left#RTL_Wikipedia_languages

@leofeyer
Copy link
Member

Implemented in e021310.

@aschempp
Copy link
Member

Thanks! Why not adding dir="ltr" for the other languages?

@leofeyer
Copy link
Member

According to the specs, you only add the tag if the text direction deviates from the default. Do you need the tag for LTR languages?=

@aschempp
Copy link
Member

Hmm, the specs tell me both values are available. And ltr is the default. But is there a reason not to add it.

I just thought it might be useful for CSS targeting, if I want to be able to style an element for LTR which is by default (in my CSS) styled for RTL.

Now that I think of it, this could also be achieved using template adjustments. However, we should probably not send HTML blocks to the template, we should tell the template $this->Template->directionRTL = true and then let the template decide what to do?

@leofeyer
Copy link
Member

But is there a reason not to add it?

Not a strong one. We are just adding 10 more characters to the markup, which are likely to be unnecessary in 99% of the use cases.

@aschempp
Copy link
Member

I agree not to add it. But it feels like a hack in the template if I need to check for an empty string and then add direction="ltr" if I need it. I would prefer a boolean variable in the template and output HTML code only in the template...

@leofeyer
Copy link
Member

Ok, I'll be changing it accordingly.

@leofeyer leofeyer reopened this Sep 30, 2014
leofeyer added a commit that referenced this issue Oct 3, 2014
@leofeyer
Copy link
Member

leofeyer commented Oct 3, 2014

Changed in 9c272cc.

@fritzmg
Copy link
Contributor

fritzmg commented Nov 29, 2017

The current approach is problematic, since it relies on a translation for the used front end language to be present. However, out of the current languages that definitely require dir="rtl" only one exists as a translation within Contao (Farsi).

Thus, if you use a language like ar for example in your website root's language setting (which is not that uncommon), you have to manually add

if ($GLOBALS['TL_LANGUAGE'] == 'ar')
{
    $GLOBALS['TL_LANG']['MSC']['textDirection'] = 'rtl';
}

to your langconfig.php.

@Toflar
Copy link
Member

Toflar commented Nov 29, 2017

Should be a root page setting maybe?

@fritzmg
Copy link
Contributor

fritzmg commented Nov 29, 2017

Maybe, on the other hand, shouldn't languages like fa, ar, hr, ... be automatically rtl?

There are some languages though that can be rtl optionally (Chinese and Japanese).

@Toflar
Copy link
Member

Toflar commented Nov 29, 2017

I don't know. And generally, if I don't know, I let the users decide :D

@aschempp
Copy link
Member

For the rare case of this, a language setting seems reasonable to me …

@fritzmg
Copy link
Contributor

fritzmg commented Mar 20, 2018

What is the status on this? Can this be reopened?

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

No branches or pull requests

7 participants