language filtering for XML-referenced files
This commit is contained in:
@@ -80,7 +80,10 @@ retry:
|
|||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( asPaths.size() > 1 )
|
|
||||||
|
THEME->FilterFileLanguages( asPaths );
|
||||||
|
|
||||||
|
if( asPaths.size() > 1 )
|
||||||
{
|
{
|
||||||
RString sError = ssprintf( "A file in '%s' references a file '%s' which has multiple matches.", sName.c_str(), sPath.c_str() );
|
RString sError = ssprintf( "A file in '%s' references a file '%s' which has multiple matches.", sName.c_str(), sPath.c_str() );
|
||||||
switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) )
|
switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) )
|
||||||
|
|||||||
@@ -416,6 +416,36 @@ struct CompareLanguageTag
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there's more than one result, check for language tags. For example,
|
||||||
|
*
|
||||||
|
* ScreenCompany graphic (lang English).png
|
||||||
|
* ScreenCompany graphic (lang French).png
|
||||||
|
*
|
||||||
|
* We still want to warn for ambiguous results. Use std::unique to filter
|
||||||
|
* files with the current language tag to the top, so choosing "ignore" from
|
||||||
|
* the multiple-match dialog will cause it to default to the first entry, so
|
||||||
|
* it'll still use a preferred language match if there were any.
|
||||||
|
*/
|
||||||
|
void ThemeManager::FilterFileLanguages( vector<RString> &asPaths )
|
||||||
|
{
|
||||||
|
if( asPaths.size() <= 1 )
|
||||||
|
return;
|
||||||
|
vector<RString>::iterator it =
|
||||||
|
partition( asPaths.begin(), asPaths.end(), CompareLanguageTag(m_sCurLanguage) );
|
||||||
|
|
||||||
|
int iDist = distance( asPaths.begin(), it );
|
||||||
|
if( iDist == 0 )
|
||||||
|
{
|
||||||
|
/* We didn't find any for the current language. Try BASE_LANGUAGE. */
|
||||||
|
it = partition( asPaths.begin(), asPaths.end(), CompareLanguageTag(SpecialFiles::BASE_LANGUAGE) );
|
||||||
|
iDist = distance( asPaths.begin(), it );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( iDist == 1 )
|
||||||
|
asPaths.erase( it, asPaths.end() );
|
||||||
|
}
|
||||||
|
|
||||||
RString ThemeManager::GetPathToRaw( const RString &sThemeName_, ElementCategory category, const RString &sClassName_, const RString &sElement_ )
|
RString ThemeManager::GetPathToRaw( const RString &sThemeName_, ElementCategory category, const RString &sClassName_, const RString &sElement_ )
|
||||||
{
|
{
|
||||||
/* Ugly: the parameters to this function may be a reference into g_vThemes, or something
|
/* Ugly: the parameters to this function may be a reference into g_vThemes, or something
|
||||||
@@ -490,35 +520,7 @@ try_element_again:
|
|||||||
if( asElementPaths.size() == 0 )
|
if( asElementPaths.size() == 0 )
|
||||||
return NULL; // This isn't fatal.
|
return NULL; // This isn't fatal.
|
||||||
|
|
||||||
/*
|
FilterFileLanguages( asElementPaths );
|
||||||
* If there's more than one result, check for language tags. For example,
|
|
||||||
*
|
|
||||||
* ScreenCompany graphic (lang English).png
|
|
||||||
* ScreenCompany graphic (lang French).png
|
|
||||||
*
|
|
||||||
* We still want to warn for ambiguous results. Use std::unique to filter
|
|
||||||
* files with the current language tag to the top.
|
|
||||||
*/
|
|
||||||
if( asElementPaths.size() > 1 )
|
|
||||||
{
|
|
||||||
vector<RString>::iterator it =
|
|
||||||
partition( asElementPaths.begin(), asElementPaths.end(), CompareLanguageTag(m_sCurLanguage) );
|
|
||||||
|
|
||||||
int iDist = distance( asElementPaths.begin(), it );
|
|
||||||
if( iDist == 0 )
|
|
||||||
{
|
|
||||||
/* We didn't find any for the current language. Try BASE_LANGUAGE. */
|
|
||||||
it = partition( asElementPaths.begin(), asElementPaths.end(), CompareLanguageTag(SpecialFiles::BASE_LANGUAGE) );
|
|
||||||
iDist = distance( asElementPaths.begin(), it );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there's more than one match (or no language matches), warn about it below.
|
|
||||||
* If "ignore" is picked, then it'll default to the first entry, so it'll still
|
|
||||||
* use a preferred language match if there were any (since partition() put them
|
|
||||||
* at the top). */
|
|
||||||
if( iDist == 1 )
|
|
||||||
asElementPaths.erase( it, asElementPaths.end() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( asElementPaths.size() > 1 )
|
if( asElementPaths.size() > 1 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ public:
|
|||||||
// Languages
|
// Languages
|
||||||
RString GetString( const RString &sClassName, const RString &sValueName );
|
RString GetString( const RString &sClassName, const RString &sValueName );
|
||||||
void GetString( const RString &sClassName, const RString &sValueName, RString &valueOut ) { valueOut = GetString( sClassName, sValueName ); }
|
void GetString( const RString &sClassName, const RString &sValueName, RString &valueOut ) { valueOut = GetString( sClassName, sValueName ); }
|
||||||
|
void FilterFileLanguages( vector<RString> &asElementPaths );
|
||||||
|
|
||||||
void GetMetricsThatBeginWith( const RString &sClassName, const RString &sValueName, set<RString> &vsValueNamesOut );
|
void GetMetricsThatBeginWith( const RString &sClassName, const RString &sValueName, set<RString> &vsValueNamesOut );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user