@ -74,8 +74,7 @@ namespace Volo.Abp.Localization
var dictionaries = Resource . DictionaryProvider . Dictionaries ;
var dictionaries = Resource . DictionaryProvider . Dictionaries ;
//Try to get from original dictionary (with country code)
//Try to get from original dictionary (with country code)
ILocalizationDictionary originalDictionary ;
if ( dictionaries . TryGetValue ( cultureName , out var originalDictionary ) )
if ( dictionaries . TryGetValue ( cultureName , out originalDictionary ) )
{
{
var strOriginal = originalDictionary . GetOrNull ( name ) ;
var strOriginal = originalDictionary . GetOrNull ( name ) ;
if ( strOriginal ! = null )
if ( strOriginal ! = null )
@ -92,8 +91,7 @@ namespace Volo.Abp.Localization
//Try to get from same language dictionary (without country code)
//Try to get from same language dictionary (without country code)
if ( cultureName . Contains ( "-" ) ) //Example: "tr-TR" (length=5)
if ( cultureName . Contains ( "-" ) ) //Example: "tr-TR" (length=5)
{
{
ILocalizationDictionary langDictionary ;
if ( dictionaries . TryGetValue ( GetBaseCultureName ( cultureName ) , out var langDictionary ) )
if ( dictionaries . TryGetValue ( GetBaseCultureName ( cultureName ) , out langDictionary ) )
{
{
var strLang = langDictionary . GetOrNull ( name ) ;
var strLang = langDictionary . GetOrNull ( name ) ;
if ( strLang ! = null )
if ( strLang ! = null )
@ -104,19 +102,21 @@ namespace Volo.Abp.Localization
}
}
//Try to get from default language
//Try to get from default language
var defaultDictionary = dictionaries . GetOrDefault ( Resource . DefaultCultureName ) ; //TODO: What if not contains a default dictionary?
if ( ! Resource . DefaultCultureName . IsNullOrEmpty ( ) )
if ( defaultDictionary = = null )
{
var defaultDictionary = dictionaries . GetOrDefault ( Resource . DefaultCultureName ) ;
if ( defaultDictionary ! = null )
{
{
return null ;
}
var strDefault = defaultDictionary . GetOrNull ( name ) ;
var strDefault = defaultDictionary . GetOrNull ( name ) ;
if ( strDefault = = null )
if ( strDefault ! = null )
{
{
return null ;
return new LocalizedString ( name , strDefault . Value ) ;
}
}
}
}
return new LocalizedString ( name , strDefault . Value ) ;
//Not found
return null ;
}
}
protected virtual IReadOnlyList < LocalizedString > GetAllStrings ( string cultureName , bool includeParentCultures = true )
protected virtual IReadOnlyList < LocalizedString > GetAllStrings ( string cultureName , bool includeParentCultures = true )
@ -131,6 +131,8 @@ namespace Volo.Abp.Localization
if ( includeParentCultures )
if ( includeParentCultures )
{
{
//Fill all strings from default dictionary
//Fill all strings from default dictionary
if ( ! Resource . DefaultCultureName . IsNullOrEmpty ( ) )
{
var defaultDictionary = dictionaries . GetOrDefault ( Resource . DefaultCultureName ) ;
var defaultDictionary = dictionaries . GetOrDefault ( Resource . DefaultCultureName ) ;
if ( defaultDictionary ! = null )
if ( defaultDictionary ! = null )
{
{
@ -139,6 +141,7 @@ namespace Volo.Abp.Localization
allStrings [ defaultDictString . Name ] = new LocalizedString ( defaultDictString . Name , defaultDictString . Value ) ;
allStrings [ defaultDictString . Name ] = new LocalizedString ( defaultDictString . Name , defaultDictString . Value ) ;
}
}
}
}
}
//Overwrite all strings from the language based on country culture
//Overwrite all strings from the language based on country culture
if ( cultureName . Contains ( "-" ) )
if ( cultureName . Contains ( "-" ) )