This is an automated email from the ASF dual-hosted git repository. dklco pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit 2efc3aab8d162b66621ade89804c1aabfbe96a13 Author: Dan Klco <[email protected]> AuthorDate: Thu May 24 22:05:47 2018 -0400 Fixing the i18n editor which wasn't working and adding an improved editing method for adding languages --- .../sling/cms/core/models/LocaleResource.java | 42 ++++++++++++++++++++++ .../cms/columns/localetitle/localetitle.jsp | 23 ++++++++++++ .../components/cms/i18ntable/i18ntable.jsp | 3 +- .../libs/sling-cms/content/i18n/dictionary.json | 25 +++++-------- .../sling-cms/content/i18n/language/create.json | 9 +++-- 5 files changed, 82 insertions(+), 20 deletions(-) diff --git a/cms/core/src/main/java/org/apache/sling/cms/core/models/LocaleResource.java b/cms/core/src/main/java/org/apache/sling/cms/core/models/LocaleResource.java new file mode 100644 index 0000000..2a91c98 --- /dev/null +++ b/cms/core/src/main/java/org/apache/sling/cms/core/models/LocaleResource.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sling.cms.core.models; + +import java.util.Locale; + +import org.apache.jackrabbit.JcrConstants; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; + +/** + * Model for retrieving the locale information from a resource with the + * jcr:language property. + */ +@Model(adaptables = Resource.class) +public class LocaleResource { + + private Locale locale; + + public LocaleResource(Resource resource) { + this.locale = Locale + .forLanguageTag(resource.getValueMap().get(JcrConstants.JCR_LANGUAGE, String.class).replace("_", "-")); + } + + public Locale getLocale() { + return locale; + } +} diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/columns/localetitle/localetitle.jsp b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/columns/localetitle/localetitle.jsp new file mode 100644 index 0000000..513b2c8 --- /dev/null +++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/columns/localetitle/localetitle.jsp @@ -0,0 +1,23 @@ +<%-- /* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ --%> +<%@include file="/libs/sling-cms/global.jsp"%> +<sling:adaptTo adaptable="${resource}" adaptTo="org.apache.sling.cms.core.models.LocaleResource" var="localeResource" /> +<td class="Cell-Static" title="${sling:encode(localeResource.locale.displayLanguage,'HTML_ATTR')} ${sling:encode(localeResource.locale.displayCountry,'HTML_ATTR')}" data-value="${localeResource.locale}"> + ${localeResource.locale.displayLanguage} ${localeResource.locale.displayCountry} +</td> \ No newline at end of file diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/i18ntable/i18ntable.jsp b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/i18ntable/i18ntable.jsp index 3794fd6..ebad540 100644 --- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/i18ntable/i18ntable.jsp +++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/i18ntable/i18ntable.jsp @@ -35,7 +35,8 @@ <c:forEach var="language" items="${sling:listChildren(slingRequest.requestPathInfo.suffixResource)}"> <c:if test="${not empty language.valueMap['jcr:language']}"> <th class="Column-${language.valueMap['jcr:language']}"> - <sling:encode value="${language.valueMap['jcr:content/jcr:title']}" mode="HTML" /> + <sling:adaptTo adaptable="${language}" adaptTo="org.apache.sling.cms.core.models.LocaleResource" var="localeResource" /> + <sling:encode value="${localeResource.locale.displayLanguage}" mode="HTML" /> <sling:encode value="${localeResource.locale.displayCountry}" mode="HTML" /> <br/> <small>(<sling:encode value="${language.valueMap['jcr:language']}" mode="HTML" />)</small> </th> diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/i18n/dictionary.json b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/i18n/dictionary.json index 7198e29..ab68447 100644 --- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/i18n/dictionary.json +++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/i18n/dictionary.json @@ -30,11 +30,11 @@ "jcr:primaryType": "nt:unstructured", "title": { "jcr:primaryType": "nt:unstructured", - "title": "Title" + "title": "Language" }, "language": { "jcr:primaryType": "nt:unstructured", - "title": "Language" + "title": "i18n Code" }, "actions": { "jcr:primaryType": "nt:unstructured", @@ -47,27 +47,18 @@ "jcr:primaryType": "nt:unstructured", "columns": { "jcr:primaryType": "nt:unstructured", - "title": { + "language": { "jcr:primaryType": "nt:unstructured", - "property": "jcr:content/jcr:title", - "type": "String" + "sling:resourceType": "sling-cms/components/cms/columns/localetitle" }, - "Language": { + "i18n": { "jcr:primaryType": "nt:unstructured", - "property": "jcr:language", - "type": "String" + "sling:resourceType": "sling-cms/components/cms/columns/text", + "property": "jcr:language" }, "actions": { "jcr:primaryType": "nt:unstructured", - "type": "Actions", - "edit": { - "jcr:primaryType": "nt:unstructured", - "modal": true, - "new": false, - "title": "Edit Language", - "text": "✏", - "prefix": "/cms/i18n/language/edit.html" - }, + "sling:resourceType": "sling-cms/components/cms/columns/actions", "delete": { "jcr:primaryType": "nt:unstructured", "modal": true, diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/i18n/language/create.json b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/i18n/language/create.json index dd552d2..62f1555 100644 --- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/i18n/language/create.json +++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/i18n/language/create.json @@ -33,8 +33,13 @@ "jcr:primaryType": "nt:unstructured", "sling:resourceType": "sling-cms/components/editor/fields/text", "label": "Name", - "name": ":name", - "required": true + "name": ":name" + }, + "nameParam": { + "jcr:primaryType": "nt:unstructured", + "sling:resourceType": "sling-cms/components/editor/fields/hidden", + "name": ":nameParam", + "value": "jcr:language" }, "primaryType": { "jcr:primaryType": "nt:unstructured", -- To stop receiving notification emails like this one, please contact [email protected].
