Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DbRes - Cultureinfo is not set if AspNetResourceProvider is set #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/Westwind.Globalization/DbResourceManager/DbResInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,16 @@ public string T(string resId, string resourceSet = null, string lang = null)
if (resourceSet == null)
resourceSet = string.Empty;

CultureInfo ci;
if (string.IsNullOrEmpty(lang))
ci = CultureInfo.CurrentUICulture;
else
ci = new CultureInfo(lang);

#if NETFULL
if (DbResourceConfiguration.Current.ResourceAccessMode == ResourceAccessMode.AspNetResourceProvider && HttpContext.Current != null)
{
var translated = HttpContext.GetGlobalResourceObject(resourceSet, resId) as string;
var translated = HttpContext.GetGlobalResourceObject(resourceSet, resId,ci) as string;
if (string.IsNullOrEmpty(translated))
return resId;

Expand All @@ -121,11 +127,6 @@ public string T(string resId, string resourceSet = null, string lang = null)
if (manager == null)
return resId;

CultureInfo ci;
if (string.IsNullOrEmpty(lang))
ci = CultureInfo.CurrentUICulture;
else
ci = new CultureInfo(lang);

string result = manager.GetObject(resId, ci) as string;

Expand Down Expand Up @@ -159,10 +160,16 @@ public string TDefault(string resId, string defaultText, string resourceSet, str
if (resourceSet == null)
resourceSet = string.Empty;

CultureInfo ci;
if (string.IsNullOrEmpty(lang))
ci = CultureInfo.CurrentUICulture;
else
ci = new CultureInfo(lang);

#if NETFULL
if (DbResourceConfiguration.Current.ResourceAccessMode == ResourceAccessMode.AspNetResourceProvider && HttpContext.Current != null)
{
var translated = HttpContext.GetGlobalResourceObject(resourceSet, resId) as string;
var translated = HttpContext.GetGlobalResourceObject(resourceSet, resId, ci) as string;
if (string.IsNullOrEmpty(translated))
return defaultText;

Expand All @@ -174,11 +181,6 @@ public string TDefault(string resId, string defaultText, string resourceSet, str
if (manager == null)
return defaultText;

CultureInfo ci;
if (string.IsNullOrEmpty(lang))
ci = CultureInfo.CurrentUICulture;
else
ci = new CultureInfo(lang);

string result = manager.GetObject(resId, ci) as string;

Expand Down