Skip to content

Commit 098bf09

Browse files
committed
Fixed localization of data provider names during installation
1 parent 5a1cb3c commit 098bf09

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

src/Presentation/Nop.Web/Areas/Admin/Views/Shared/_AdminLayout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@using Nop.Services.Defaults
1919
@using Nop.Services.Helpers
2020
@using Nop.Services.Security
21-
@using Nop.Web.Framework.UI;
21+
@using Nop.Web.Framework.UI
2222

2323
@{
2424
var returnUrl = webHelper.GetRawUrl(Context.Request);

src/Presentation/Nop.Web/Infrastructure/Installation/IInstallationLocalizationService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public partial interface IInstallationLocalizationService
3636
/// <summary>
3737
/// Get a list of available data provider types
3838
/// </summary>
39-
/// <returns>Available installation data provider types</returns>
40-
IList<SelectListItem> GetAvailableProviderTypes();
39+
/// <param name="valuesToExclude">Values to exclude</param>
40+
/// <param name="useLocalization">Localize</param>
41+
/// <returns>SelectList</returns>
42+
SelectList GetAvailableProviderTypes(int[] valuesToExclude = null, bool useLocalization = true);
4143
}
4244
}

src/Presentation/Nop.Web/Infrastructure/Installation/InstallationLocalizationService.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public InstallationLocalizationService(IHttpContextAccessor httpContextAccessor,
4040
}
4141

4242
#endregion
43-
43+
4444
#region Methods
4545

4646
/// <summary>
@@ -214,25 +214,22 @@ public virtual IList<InstallationLanguage> GetAvailableLanguages()
214214
/// <summary>
215215
/// Get a list of available data provider types
216216
/// </summary>
217-
/// <returns>Available installation data provider types</returns>
218-
public IList<SelectListItem> GetAvailableProviderTypes()
217+
/// <param name="valuesToExclude">Values to exclude</param>
218+
/// <param name="useLocalization">Localize</param>
219+
/// <returns>SelectList</returns>
220+
public SelectList GetAvailableProviderTypes(int[] valuesToExclude = null, bool useLocalization = true)
219221
{
220-
//TODO 239 must be implemented
221-
return new List<SelectListItem>
222-
{
223-
new SelectListItem()
222+
var values =
223+
from DataProviderType enumValue in Enum.GetValues(typeof(DataProviderType))
224+
where enumValue != DataProviderType.Unknown && (valuesToExclude == null || !valuesToExclude.Contains(Convert.ToInt32(enumValue)))
225+
select new
224226
{
225-
Value = DataProviderType.SqlServer.ToString(),
226-
Text = GetResource(DataProviderType.SqlServer.ToString()),
227-
Selected = true
228-
},
229-
new SelectListItem()
230-
{
231-
Value = DataProviderType.MySql.ToString(),
232-
Text = GetResource(DataProviderType.MySql.ToString()),
233-
Selected = true
234-
}
235-
};
227+
ID = Convert.ToInt32(enumValue),
228+
Name = useLocalization ? GetResource(enumValue.ToString()) :
229+
CommonHelper.ConvertEnum(enumValue.ToString())
230+
};
231+
232+
return new SelectList(values.OrderBy(v => v.Name), "ID", "Name", null);
236233
}
237234

238235
#endregion

0 commit comments

Comments
 (0)