Page 1 of 1

Use xml:lang in CSS Selector

Posted: Tue Apr 08, 2025 2:59 am
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!

Re: Use xml:lang in CSS Selector

Posted: Tue Apr 08, 2025 12:56 pm
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

Re: Use xml:lang in CSS Selector

Posted: Tue Apr 08, 2025 10:17 pm
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

Re: Use xml:lang in CSS Selector

Posted: Wed Apr 09, 2025 9:50 am
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