diff --git a/VirtoCommerce.Platform.Web/Controllers/Api/LocalizationController.cs b/VirtoCommerce.Platform.Web/Controllers/Api/LocalizationController.cs index dc2e3e71c8e..d9f0109efa8 100644 --- a/VirtoCommerce.Platform.Web/Controllers/Api/LocalizationController.cs +++ b/VirtoCommerce.Platform.Web/Controllers/Api/LocalizationController.cs @@ -16,7 +16,7 @@ public class LocalizationController : ApiController private const string LocalizationFilesFormat = ".json"; private const string LocalizationFilesFolder = "Localizations"; private const string InternationalizationFilesFormat = ".js"; - private const string InternationalizationFilesFolder = "Scripts\\i18n"; + private const string InternationalizationFilesFolder = "Scripts\\i18n\\angular"; private readonly IModuleCatalog _moduleCatalog; @@ -55,6 +55,7 @@ public JObject GetLocalization(string lang = "en") /// [HttpGet] [Route("locales")] + [AllowAnonymous] [ResponseType(typeof(string[]))] public IHttpActionResult GetLocales() { @@ -72,6 +73,7 @@ public IHttpActionResult GetLocales() /// [HttpGet] [Route("regionalformats")] + [AllowAnonymous] [ResponseType(typeof(string[]))] public IHttpActionResult GetRegionalFormats() { diff --git a/VirtoCommerce.Platform.Web/Scripts/app/userProfile/userProfile.js b/VirtoCommerce.Platform.Web/Scripts/app/userProfile/userProfile.js index f663e3aa3f3..6c8d63b9085 100644 --- a/VirtoCommerce.Platform.Web/Scripts/app/userProfile/userProfile.js +++ b/VirtoCommerce.Platform.Web/Scripts/app/userProfile/userProfile.js @@ -15,7 +15,7 @@ }] }); }]) -.factory('platformWebApp.userProfile', ['platformWebApp.userProfileApi', 'platformWebApp.settings.helper', 'platformWebApp.common.languages', 'platformWebApp.common.locales', 'platformWebApp.common.timeZones', function (userProfileApi, settingsHelper, languages, locales, timeZones) { +.factory('platformWebApp.userProfile', ['platformWebApp.userProfileApi', 'platformWebApp.settings.helper', 'platformWebApp.common.languages', 'platformWebApp.common.locales', function (userProfileApi, settingsHelper, languages, locales) { var onChangeCallbacks = []; var result = { @@ -34,7 +34,7 @@ settingsHelper.fixValues(profile.settings); profile.language = languages.normalize(settingsHelper.getSetting(profile.settings, "VirtoCommerce.Platform.UI.Language").value); profile.regionalFormat = locales.normalize(settingsHelper.getSetting(profile.settings, "VirtoCommerce.Platform.UI.RegionalFormat").value); - profile.timeZone = timeZones.normalize(settingsHelper.getSetting(profile.settings, "VirtoCommerce.Platform.UI.TimeZone").value); + profile.timeZone = settingsHelper.getSetting(profile.settings, "VirtoCommerce.Platform.UI.TimeZone").value; profile.timeAgoSettings = { }; profile.timeAgoSettings.useTimeAgo = settingsHelper.getSetting(profile.settings, "VirtoCommerce.Platform.UI.UseTimeAgo").value; profile.timeAgoSettings.threshold = settingsHelper.getSetting(profile.settings, "VirtoCommerce.Platform.UI.FullDateThreshold").value; @@ -54,7 +54,7 @@ mainMenuStateSetting.value = angular.toJson(this.mainMenuState); settingsHelper.getSetting(this.settings, "VirtoCommerce.Platform.UI.Language").value = languages.normalize(result.language); settingsHelper.getSetting(this.settings, "VirtoCommerce.Platform.UI.RegionalFormat").value = locales.normalize(result.regionalFormat); - settingsHelper.getSetting(this.settings, "VirtoCommerce.Platform.UI.TimeZone").value = timeZones.normalize(result.timeZone); + settingsHelper.getSetting(this.settings, "VirtoCommerce.Platform.UI.TimeZone").value = result.timeZone; settingsHelper.getSetting(this.settings, "VirtoCommerce.Platform.UI.UseTimeAgo").value = result.timeAgoSettings.useTimeAgo; settingsHelper.getSetting(this.settings, "VirtoCommerce.Platform.UI.FullDateThreshold").value = result.timeAgoSettings.threshold; settingsHelper.getSetting(this.settings, "VirtoCommerce.Platform.UI.FullDateThresholdUnit").value = result.timeAgoSettings.thresholdUnit; diff --git a/VirtoCommerce.Platform.Web/Scripts/i18n/i18n.js b/VirtoCommerce.Platform.Web/Scripts/i18n/i18n.js index a35d62fb445..973ccb7208a 100644 --- a/VirtoCommerce.Platform.Web/Scripts/i18n/i18n.js +++ b/VirtoCommerce.Platform.Web/Scripts/i18n/i18n.js @@ -42,7 +42,6 @@ if (!timeZone) { timeZone = moment.tz.guess(); } - timeZone = timeZones.normalize(timeZone); momentService.changeTimezone(timeZone); } @@ -65,7 +64,7 @@ return { getLanguage: function() { return languages.normalize($translate.use()) }, getRegionalFormat: function () { return locales.normalize(dynamicLocale.get()) }, - getTimeZone: function () { return timeZones.normalize(momentConfig.timezone) }, + getTimeZone: function () { return momentConfig.timezone }, getTimeAgoSettings: function () { var result = {}; // Always use time ago: threshold unit = null, threshold value = null | null diff --git a/VirtoCommerce.Platform.Web/Scripts/i18n/resources/timeZones.js b/VirtoCommerce.Platform.Web/Scripts/i18n/resources/timeZones.js index 4d7cccb980f..3b9a8145ddc 100644 --- a/VirtoCommerce.Platform.Web/Scripts/i18n/resources/timeZones.js +++ b/VirtoCommerce.Platform.Web/Scripts/i18n/resources/timeZones.js @@ -4,26 +4,10 @@ angular.module('platformWebApp') .factory('platformWebApp.common.timeZones', ['moment', function(moment) { return { get: function(id) { - return _.findWhere(this.query(), { id: this.normalize(id) }); + return _.find(this.query(), function(x) { return x.id.toLowerCase() === id.toLowerCase(); }); }, contains: function (id) { - return _.map(this.query(), function (entry) { return entry.id }).includes(this.normalize(id)); - }, - normalize: function(id) { - var result = undefined; - if (!!id) { - var toTitleCase = function(str) { - return str.capitalize(); - } - var parts = id.split(/[\/_]/); - var continent = toTitleCase(parts.shift()); - parts.forEach(function(x) { - return toTitleCase(x); - }); - var city = parts.join('_'); - result = continent + "/" + city; - } - return result; + return _.some(this.query(), function (x) { return x.id.toLowerCase() === id.toLowerCase(); }); }, query: function () { // Get time zone from moment list of time zones, append UTC offset to name (UTC ±XX:XX Continent/City) and sort by UTC offset diff --git a/VirtoCommerce.Platform.Web/Startup.cs b/VirtoCommerce.Platform.Web/Startup.cs index 90eb9e5f8d1..2414c1f6cde 100644 --- a/VirtoCommerce.Platform.Web/Startup.cs +++ b/VirtoCommerce.Platform.Web/Startup.cs @@ -482,7 +482,7 @@ private static void InitializePlatform(IAppBuilder app, IUnityContainer containe Name = "VirtoCommerce.Platform.UI.TimeZone", ValueType = ModuleSetting.TypeString, Title = "Time zone", - Description = "Default time zone (IANA time zone name [tz database], with slash or underscore as delemiter, case-insensitive). Examples: America/New_York, Europe/Moscow" + Description = "Default time zone (IANA time zone name [tz database], exactly as in database, case-sensitive). Examples: America/New_York, Europe/Moscow" }, new ModuleSetting {