Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarincev committed Jun 6, 2017
2 parents 7e9c3cf + 2c4a4e6 commit 728f4e0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -55,6 +55,7 @@ public JObject GetLocalization(string lang = "en")
/// <returns></returns>
[HttpGet]
[Route("locales")]
[AllowAnonymous]
[ResponseType(typeof(string[]))]
public IHttpActionResult GetLocales()
{
Expand All @@ -72,6 +73,7 @@ public IHttpActionResult GetLocales()
/// <returns></returns>
[HttpGet]
[Route("regionalformats")]
[AllowAnonymous]
[ResponseType(typeof(string[]))]
public IHttpActionResult GetRegionalFormats()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions VirtoCommerce.Platform.Web/Scripts/i18n/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
if (!timeZone) {
timeZone = moment.tz.guess();
}
timeZone = timeZones.normalize(timeZone);
momentService.changeTimezone(timeZone);
}

Expand All @@ -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
Expand Down
20 changes: 2 additions & 18 deletions VirtoCommerce.Platform.Web/Scripts/i18n/resources/timeZones.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion VirtoCommerce.Platform.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 728f4e0

Please sign in to comment.