Skip to content

Commit

Permalink
Fix #3787 "Date picker doesn't use right language when embedded"
Browse files Browse the repository at this point in the history
  • Loading branch information
ebruchez committed Oct 31, 2018
1 parent c167978 commit e61ac1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Expand Up @@ -24,10 +24,12 @@

<xsl:template match="/">
<xh:div>
<!-- Copy xforms-[dis|en]able-hint-as-tooltip and xforms-[dis|en]able-alert-as-tooltip from the body to the div -->
<!-- Copy `id` and `lang` from the root element, see https://github.com/orbeon/orbeon-forms/issues/3787. -->
<xsl:copy-of select="/*/(@id | @lang)"/>
<!-- Copy `xforms-[dis|en]able-hint-as-tooltip` and `xforms-[dis|en]able-alert-as-tooltip` from the body to the div -->
<!-- NOTE: Since Orbeon Forms 2016.2, the XForms engine places the hint classes on the `<xh:form>` element. -->
<xsl:variable name="classes-to-copy" select="p:split(/xh:html/xh:body/@class)[matches(., '^xforms-(dis|en)able-[^-]+-as-tooltip$')]"/>
<xsl:attribute name="class" select="string-join(('orbeon orbeon-portlet-div', $classes-to-copy), ' ')"/>
<xsl:variable name="classes-to-copy" select="p:split(/xh:html/xh:body/@class)[matches(., '^xforms-(dis|en)able-[^-]+-as-tooltip$')]"/>
<xsl:attribute name="class" select="string-join(('orbeon orbeon-portlet-div', $classes-to-copy), ' ')"/>
<!-- Handle head elements except scripts -->
<xsl:for-each select="/xh:html/xh:head/(xh:meta | xh:link | xh:style)">
<xsl:element name="xh:{local-name()}" namespace="{namespace-uri()}">
Expand Down
10 changes: 8 additions & 2 deletions xforms/js/src/main/scala/org/orbeon/xforms/Page.scala
Expand Up @@ -43,8 +43,14 @@ object Page {
}

// Return the language for the page, defaulting to English if none is set on html/@lang.
def getLang(): String =
($(g.document.documentElement).attr("lang") getOrElse "en").substring(0, 2)
// See also https://github.com/orbeon/orbeon-forms/issues/3787
def getLang(): String = {

def fromRootElem = $(g.document.documentElement).attr("lang")
def fromOther = $("[lang]").attr("lang")

(fromRootElem orElse fromOther getOrElse "en").substring(0, 2)
}

// Create or return a control object corresponding to the provided container. Each control is inside a given
// form, so getControl() could be a method of a form, but since we can given a container or control id determine
Expand Down

0 comments on commit e61ac1f

Please sign in to comment.