Use "en-US" as the default for XHP's xml-lang attribute.

Change-Id: I765e1cc25ac79d2cebf54f7a247a200647c984da
Reviewed-on: https://gerrit.libreoffice.org/32296
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Tested-by: Olivier Hallot <olivier.hallot@libreoffice.org>
This commit is contained in:
Jan Holesovsky
2016-12-21 17:29:30 +01:00
committed by Olivier Hallot
parent 1aaa0fa821
commit a0f51dc3a4
2 changed files with 15 additions and 7 deletions

View File

@@ -54,7 +54,7 @@ namespace
OUString lcl_AltDescr() OUString lcl_AltDescr()
{ {
OUString aTempl = OUString("<alt xml-lang=\"en-US\" id=\"%1\">" OUString aTempl = OUString("<alt id=\"%1\">"
" " //FIXME real dialog title or something " " //FIXME real dialog title or something
"</alt>"); "</alt>");
aTempl = aTempl.replaceFirst( "%1", lcl_genRandom("alt_id") ); aTempl = aTempl.replaceFirst( "%1", lcl_genRandom("alt_id") );
@@ -79,7 +79,7 @@ namespace
OUString lcl_ParagraphWithImage( const OUString& rScreenshotId, const Size& rSize ) OUString lcl_ParagraphWithImage( const OUString& rScreenshotId, const Size& rSize )
{ {
OUString aTempl = OUString( "<paragraph id=\"%1\" role=\"paragraph\" xml-lang=\"en-US\">%2" OUString aTempl = OUString( "<paragraph id=\"%1\" role=\"paragraph\">%2"
"</paragraph>" SAL_NEWLINE_STRING ); "</paragraph>" SAL_NEWLINE_STRING );
aTempl = aTempl.replaceFirst( "%1", lcl_genRandom("par_id") ); aTempl = aTempl.replaceFirst( "%1", lcl_genRandom("par_id") );
aTempl = aTempl.replaceFirst( "%2", lcl_Image(rScreenshotId, rSize) ); aTempl = aTempl.replaceFirst( "%2", lcl_Image(rScreenshotId, rSize) );
@@ -90,7 +90,7 @@ namespace
OUString lcl_Bookmark( const OUString& rWidgetId ) OUString lcl_Bookmark( const OUString& rWidgetId )
{ {
OUString aTempl = "<!-- Bookmark for widget %1 -->" SAL_NEWLINE_STRING OUString aTempl = "<!-- Bookmark for widget %1 -->" SAL_NEWLINE_STRING
"<bookmark xml-lang=\"en-US\" branch=\"hid/%2\" id=\"%3\" localize=\"false\"/>" SAL_NEWLINE_STRING; "<bookmark branch=\"hid/%2\" id=\"%3\" localize=\"false\"/>" SAL_NEWLINE_STRING;
aTempl = aTempl.replaceFirst( "%1", rWidgetId ); aTempl = aTempl.replaceFirst( "%1", rWidgetId );
aTempl = aTempl.replaceFirst( "%2", rWidgetId ); aTempl = aTempl.replaceFirst( "%2", rWidgetId );
aTempl = aTempl.replaceFirst( "%3", lcl_genRandom("bm_id") ); aTempl = aTempl.replaceFirst( "%3", lcl_genRandom("bm_id") );

View File

@@ -330,7 +330,7 @@ void XMLFile::Extract()
void XMLFile::InsertL10NElement( XMLElement* pElement ) void XMLFile::InsertL10NElement( XMLElement* pElement )
{ {
OString sId, sLanguage(""); OString sId, sLanguage("en-US");
LangHashMap* pElem; LangHashMap* pElem;
if( pElement->GetAttributeList() != nullptr ) if( pElement->GetAttributeList() != nullptr )
@@ -445,7 +445,8 @@ void XMLFile::SearchL10NElements( XMLChildNode *pCur )
bool bInsert = true; bool bInsert = true;
XMLElement *pElement = static_cast<XMLElement*>(pCur); XMLElement *pElement = static_cast<XMLElement*>(pCur);
const OString sName(pElement->GetName().toAsciiLowerCase()); const OString sName(pElement->GetName().toAsciiLowerCase());
OString sLanguage, sTmpStrVal; OString sLanguage("en-US");
OString sTmpStrVal;
if ( pElement->GetAttributeList()) if ( pElement->GetAttributeList())
{ {
for ( size_t j = 0 , cnt = pElement->GetAttributeList()->size(); j < cnt && bInsert; ++j ) for ( size_t j = 0 , cnt = pElement->GetAttributeList()->size(); j < cnt && bInsert; ++j )
@@ -603,11 +604,18 @@ void XMLElement::ChangeLanguageTag( const OString &rValue )
SetLanguageId(rValue); SetLanguageId(rValue);
if ( m_pAttributes ) if ( m_pAttributes )
{ {
bool bWasSet = false;
for (size_t i = 0; i < m_pAttributes->size(); ++i) for (size_t i = 0; i < m_pAttributes->size(); ++i)
{ {
if ( (*m_pAttributes)[ i ]->GetName() == "xml-lang" ) if ((*m_pAttributes)[ i ]->GetName() == XML_LANG)
{
(*m_pAttributes)[ i ]->setValue(rValue); (*m_pAttributes)[ i ]->setValue(rValue);
bWasSet = true;
}
} }
if (!bWasSet)
AddAttribute(XML_LANG, rValue);
} }
XMLChildNodeList* pCList = GetChildList(); XMLChildNodeList* pCList = GetChildList();
@@ -681,7 +689,7 @@ void XMLElement::Print(XMLNode *pCur, OStringBuffer& rBuffer, bool bRootelement
for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ ) for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ )
{ {
const OString aAttrName( (*pElement->GetAttributeList())[ j ]->GetName() ); const OString aAttrName( (*pElement->GetAttributeList())[ j ]->GetName() );
if( !aAttrName.equalsIgnoreAsciiCase( "xml-lang" ) ) if (!aAttrName.equalsIgnoreAsciiCase(XML_LANG))
{ {
rBuffer.append( rBuffer.append(
" " + aAttrName + "=\"" + " " + aAttrName + "=\"" +