From de14a6dad751e06b59dab34ebb4e03255b0148c4 Mon Sep 17 00:00:00 2001 From: perploug Date: Wed, 9 Oct 2013 15:07:09 +0200 Subject: [PATCH] labels for localization support --- .../html/umbcontrolgroup.directive.js | 13 ++++-- .../src/common/services/tinymce.service.js | 16 ++++++++ .../src/views/common/dialogs/linkpicker.html | 11 +++-- .../src/views/content/edit.html | 14 +++++-- .../Mapping/TabsAndPropertiesResolver.cs | 40 ++++++++++++++++--- src/umbraco.controls/Property.cs | 2 +- 6 files changed, 79 insertions(+), 17 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbcontrolgroup.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbcontrolgroup.directive.js index 89adf18abf..5432add07a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/html/umbcontrolgroup.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/html/umbcontrolgroup.directive.js @@ -4,10 +4,10 @@ * @restrict E **/ angular.module("umbraco.directives.html") - .directive('umbControlGroup', function () { + .directive('umbControlGroup', function (localizationService) { return { scope: { - label: "@", + label: "@label", description: "@", hideLabel: "@", alias: "@" @@ -15,6 +15,13 @@ angular.module("umbraco.directives.html") transclude: true, restrict: 'E', replace: true, - templateUrl: 'views/directives/html/umb-control-group.html' + templateUrl: 'views/directives/html/umb-control-group.html', + link: function (scope, element, attr){ + if(scope.label && scope.label[0] === "@"){ + scope.labelstring = localizationService.localize(scope.label.substring(1)); + }else{ + scope.labelstring = scope.label; + } + } }; }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js index cdeef6c823..038bf00113 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js @@ -27,6 +27,22 @@ function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macro 'Failed to retreive entity data for id '); }, + /** + * @ngdoc method + * @name umbraco.services.tinyMceService#defaultPrevalues + * @methodOf umbraco.services.tinyMceService + * + * @description + * Returns a default configration to fallback on in case none is provided + * + */ + defaultPrevalues: function () { + var cfg = {}; + cfg.toolbar = ["code", "bold", "italic", "umbracocss","alignleft", "aligncenter", "alignright", "bullist","numlist", "outdent", "indent", "link", "image", "umbmediapicker", "umbembeddialog", "umbmacro"]; + cfg.stylesheets = []; + cfg.dimensions = {height: 400, width: 600}; + return cfg; + }, /** * @ngdoc method diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html index 8315d7a1e2..dbc0629f93 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html @@ -1,7 +1,7 @@
diff --git a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs index a8b37bf71f..ef22fecb91 100644 --- a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs @@ -41,9 +41,9 @@ namespace Umbraco.Web.Models.Mapping /// setting up the properties such as Created date, udpated date, template selected, etc... /// public static void MapGenericProperties( - TPersisted content, + TPersisted content, ContentItemDisplayBase display, - params ContentPropertyDisplay[] customProperties) + params ContentPropertyDisplay[] customProperties) where TPersisted : IContentBase { @@ -105,6 +105,7 @@ namespace Umbraco.Web.Models.Mapping //re-assign genericProps.Properties = contentProps; + } protected override IEnumerable> ResolveCore(IContentBase content) @@ -141,7 +142,7 @@ namespace Umbraco.Web.Models.Mapping { Id = rootGroup.Id, Alias = rootGroup.Name, - Label = rootGroup.Name, + Label = TranslateTab(rootGroup.Name), Properties = aggregateProperties, IsActive = false }); @@ -155,16 +156,45 @@ namespace Umbraco.Web.Models.Mapping aggregateTabs.Add(new Tab { Id = 0, - Label = "Generic properties", + Label = ui.Text("general", "properties"), Alias = "Generic properties", Properties = Mapper.Map, IEnumerable>(orphanProperties) }); - + //set the first tab to active aggregateTabs.First().IsActive = true; return aggregateTabs; } + + private string TranslateTab(string tabName) + { + + if (!tabName.StartsWith("#")) + return tabName; + + return tabName.Substring(1); + + /* + * The below currently doesnt work on my machine, since the dictonary always creates an entry with lang id = 0, but I dont have a lang id zero + * so the query always fails, which is odd + * + var local = ApplicationContext.Current.Services.LocalizationService; + var dic = local.GetDictionaryItemByKey(tabName); + if (dic == null || !dic.Translations.Any()) + return tabName; + + var lang = local.GetLanguageByCultureCode(UmbracoContext.Current.Security.CurrentUser.Language); + if (lang == null) + return tabName; + + + var translation = dic.Translations.Where(x => x.Language == lang).FirstOrDefault(); + if (translation == null) + return tabName; + + return translation.Value;*/ + } } } diff --git a/src/umbraco.controls/Property.cs b/src/umbraco.controls/Property.cs index 1e9145c99e..1877a71997 100644 --- a/src/umbraco.controls/Property.cs +++ b/src/umbraco.controls/Property.cs @@ -37,7 +37,7 @@ namespace umbraco.uicontrols var inGroup = this.Parent.GetType() == typeof(PropertyGroup); if (string.IsNullOrEmpty(m_Text)) - CssClass += " hideLabel"; + CssClass += " hidelabel"; writer.WriteLine("
");