Use xml:lang in CSS Selector

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
dreifsnider
Posts: 170
Joined: Thu Aug 30, 2018 10:06 pm

Use xml:lang in CSS Selector

Post by dreifsnider »

Hi Oxygen Support,

My team would like to introduce some text before the contents of a topic that has a custom attribute (translated) set on the root <topic> element. We are hoping that the text can be localized depending on the value of the xml:lang attribute on the root <topic> element as well.

For example, here is a sample <topic> element that we would like to introduce the before text:

Code: Select all

<topic xml:lang="en-US" id="example_1" translated="yes">
Here are examples of the two solutions we would like to have:

xml:lang='en-US'
image.png
xml:lang='ja-JP'
image.png
Here is the CSS that I'm hoping to use:

Code: Select all

*[class~='topic/topic'][translated='yes'] {
    background-color: LightGray !important;
    -oxy-editable: false;
}

*[xml:lang~='en-US'][class~='topic/topic'][translated='yes']:before {
    content: 'The following content has been translated and is not editable';
	color: red !important;
	font-size: 26px;
	text-decoration: none;
}

*[xml:lang~='ja-JP'][class~='topic/topic'][translated='yes']:before {
    content: '以下のコンテンツは翻訳されており、編集できません';
	color: red !important;
	font-size: 26px;
	text-decoration: none;
}
Unfortunately, the presence of xml:lang in the CSS selector doesn't seem to work as expected and the before text never displays. Removing the xml:lang selector causes the before text to display as expected, but we're hoping that we can have localized before text depending on the value of xml:lang.

Do you have any suggestions for how we can have localized text in the CSS before pseudo element in Web Author?

Thank you!
You do not have the required permissions to view the files attached to this post.
cosminef
Site Admin
Posts: 232
Joined: Wed Aug 30, 2023 2:33 pm

Re: Use xml:lang in CSS Selector

Post by cosminef »

Hello,

Thank you for reaching out.
Based on our public documentation, selectors of the type [*|lang] that match the lang attribute in any namespace are not supported [1].
You can remove the xml: prefix and use lang, for example [lang='en'].

Best,
Cosmin

[1] https://www.oxygenxml.com/doc/versions/ ... tions.html
Cosmin Eftenie
www.oxygenxml.com
dreifsnider
Posts: 170
Joined: Thu Aug 30, 2018 10:06 pm

Re: Use xml:lang in CSS Selector

Post by dreifsnider »

Hi Cosmin,

Thanks for your reply and apologies for missing that entry in the public documentation.

Unfortunately, using lang does not seem to work for us, because even though a topic has "xml:lang='ja-JP'" the HTML lang still says "en", for example:
image.png
Thanks,
Daniel
You do not have the required permissions to view the files attached to this post.
cosminef
Site Admin
Posts: 232
Joined: Wed Aug 30, 2023 2:33 pm

Re: Use xml:lang in CSS Selector

Post by cosminef »

Hello,

I apologize for the confusion. What I meant was that you should use the "lang" attribute in both the XML document and the CSS file, so that the correct rules are applied.

Best,
Cosmin
Cosmin Eftenie
www.oxygenxml.com
Post Reply