Skip to content

Commit

Permalink
SAK-32659 Moved commons tool to portal.i18n (sakaiproject#4569)
Browse files Browse the repository at this point in the history
Renamed i18n translate function to 'tr' and updated connections manager
code.
Tidied up SakaiI18n a bit.
  • Loading branch information
adrianfish authored Aug 21, 2017
1 parent 74f53a4 commit f4b98dc
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 120 deletions.
6 changes: 6 additions & 0 deletions commons/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
<include>**/*.sql</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/i18n</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<!-- unit testing -->
<plugins>
Expand Down
File renamed without changes.
25 changes: 0 additions & 25 deletions commons/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,6 @@

<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}/i18n</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/i18n/org/sakaiproject/commons</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.json</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars-maven-plugin</artifactId>
Expand Down
6 changes: 0 additions & 6 deletions commons/tool/src/i18n/org/sakaiproject/commons/languages.json

This file was deleted.

2 changes: 1 addition & 1 deletion commons/tool/src/webapp/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<property name="commonsManager"><ref bean="org.sakaiproject.commons.api.CommonsManager"/></property>
<property name="commonsSecurityManager"><ref bean="org.sakaiproject.commons.api.CommonsSecurityManager"/></property>
<property name="sakaiProxy"><ref bean="org.sakaiproject.commons.api.SakaiProxy"/></property>
</bean>
</bean>

</beans>
1 change: 0 additions & 1 deletion commons/tool/src/webapp/WEB-INF/bootstrap.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<script src="/library/webjars/jquery/1.11.3/jquery.min.js"></script>
<script src="/library/webjars/jquery-ui/1.11.3/jquery-ui.min.js"></script>
<script src="/library/webjars/jquery-i18n-properties/1.2.2/jquery.i18n.properties.min.js"></script>
<script src="/library/webjars/momentjs/2.11.1/min/moment-with-locales.min.js"></script>
<script src="/library/js/jquery/qtip/jquery.qtip-latest.min.js"></script>
<script src="/commons-tool/lib/handlebars.runtime-v4.0.5.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions commons/tool/src/webapp/WEB-INF/templates/comment.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<span id="commons-comment-content-{{id}}" class="commons-comment-content">{{{content}}}</span>
<div id="commons-comment-options-{{id}}" class="commons-comment-options">
{{#if canEdit}}
<a href="javascript:;" id="commons-comment-edit-link-{{id}}" class="commons-comment-edit-link" data-comment-id="{{id}}" data-creator-id="{{creatorId}}">{{translate 'edit'}}</a>
<a href="javascript:;" id="commons-comment-edit-link-{{id}}" class="commons-comment-edit-link" data-comment-id="{{id}}" data-creator-id="{{creatorId}}">{{tr 'commons' 'edit'}}</a>
{{/if}}
{{!--
{{#if canComment}}
<a href="javascript:;" class="commons-comment-reply-link" data-comment-id="{{id}}">{{translate 'reply'}}</a>
<a href="javascript:;" class="commons-comment-reply-link" data-comment-id="{{id}}">{{tr 'commons' 'reply'}}</a>
{{/if}}
--}}
{{#if canDelete}}
<a href="javascript:;" id="commons-comment-delete-link-{{id}}" class="commons-comment-delete-link" data-post-id="{{postId}}" data-comment-id="{{id}}">{{translate 'del'}}</a>
<a href="javascript:;" id="commons-comment-delete-link-{{id}}" class="commons-comment-delete-link" data-post-id="{{postId}}" data-comment-id="{{id}}">{{tr 'commons' 'del'}}</a>
{{/if}}
<span class="commons-date">{{formattedCreatedDate}}</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="commons-editor-text-wrapper">
<div class="commons-editor-text commons-comment-editor-text" data-post-id="{{id}}"><textarea id="commons-comment-textarea-{{id}}" class="commons-comment-textarea" data-post-id="{{id}}"></textarea></div>
<div id="commons-comment-post-buttons-{{id}}">
<button id="commons-inplace-comment-editor-post-button-{{id}}">{{translate 'post_comment'}}</button>
<button id="commons-inplace-comment-editor-cancel-button-{{id}}">{{translate 'cancel'}}</button>
<button id="commons-inplace-comment-editor-post-button-{{id}}">{{tr 'commons' 'post_comment'}}</button>
<button id="commons-inplace-comment-editor-cancel-button-{{id}}">{{tr 'commons' 'cancel'}}</button>
</div>
</div>
38 changes: 19 additions & 19 deletions commons/tool/src/webapp/WEB-INF/templates/permissions.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<h2>{{translate 'permissions'}}</h2>
<h2>{{tr 'commons' 'permissions'}}</h2>
<table class="commons-permissions-table">
<thead>
<tr>
<th></th>
<th width="5px"></th>
<th align="center" colspan="6">{{translate 'post'}}</th>
<th align="center" colspan="6">{{tr 'commons' 'post'}}</th>
</tr>
<tr class="listHier">
<th align="left">{{translate 'role'}}:</th>
<th align="left">{{tr 'commons' 'role'}}:</th>
<th style="background: white;border: none;"></th>
<th style="text-align:center;">{{translate 'create'}}</th>
<th style="text-align:center;">{{translate 'read_any'}}</th>
<th style="text-align:center;">{{translate 'update_any'}}</th>
<th style="text-align:center;">{{translate 'update_own'}}</th>
<th style="text-align:center;">{{translate 'delete_any'}}</th>
<th style="text-align:center;">{{translate 'delete_own'}}</th>
<th style="text-align:center;">{{tr 'commons' 'create'}}</th>
<th style="text-align:center;">{{tr 'commons' 'read_any'}}</th>
<th style="text-align:center;">{{tr 'commons' 'update_any'}}</th>
<th style="text-align:center;">{{tr 'commons' 'update_own'}}</th>
<th style="text-align:center;">{{tr 'commons' 'delete_any'}}</th>
<th style="text-align:center;">{{tr 'commons' 'delete_own'}}</th>
</tr>
</thead>
<tbody>
Expand All @@ -37,17 +37,17 @@
<tr>
<th></th>
<th width="5px"></th>
<th colspan="6">{{translate 'comment'}}</th>
<th colspan="6">{{tr 'commons' 'comment'}}</th>
</tr>
<tr class="listHier">
<th align="left">{{translate 'role'}}:</th>
<th align="left">{{tr 'commons' 'role'}}:</th>
<th style="background: white;border: none;"></th>
<th style="text-align:center;">{{translate 'create'}}</th>
<th style="text-align:center;">{{translate 'read_any'}}</th>
<th style="text-align:center;">{{translate 'update_any'}}</th>
<th style="text-align:center;">{{translate 'update_own'}}</th>
<th style="text-align:center;">{{translate 'delete_any'}}</th>
<th style="text-align:center;">{{translate 'delete_own'}}</th>
<th style="text-align:center;">{{tr 'commons' 'create'}}</th>
<th style="text-align:center;">{{tr 'commons' 'read_any'}}</th>
<th style="text-align:center;">{{tr 'commons' 'update_any'}}</th>
<th style="text-align:center;">{{tr 'commons' 'update_own'}}</th>
<th style="text-align:center;">{{tr 'commons' 'delete_any'}}</th>
<th style="text-align:center;">{{tr 'commons' 'delete_own'}}</th>
</tr>
</thead>
{{#each perms}}
Expand All @@ -64,5 +64,5 @@
{{/each}}
</tbody>
</table>
<input id="commons_permissions_save_button" type="button" value="{{translate 'save'}}"/>
<input type="button" value="{{translate 'cancel'}}" onclick="return commons.switchState('home');"/>
<input id="commons_permissions_save_button" type="button" value="{{tr 'commons' 'save'}}"/>
<input type="button" value="{{tr 'commons' 'cancel'}}" onclick="return commons.switchState('home');"/>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div id="commons-permissions-not-set-message" class="textblock">
<p>{{translate 'permissions_not_set'}}</p>
<p>{{tr 'commons' 'permissions_not_set'}}</p>
</div>
16 changes: 8 additions & 8 deletions commons/tool/src/webapp/WEB-INF/templates/post.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
<div class="commons-post-content"><a id="commons-author-name-{{id}}" class="commons-post-author-name" href="javascript:;">{{creatorDisplayName}}</a><span id="commons-post-content-{{id}}">{{{content}}}<span></div>
<div id="commons-post-options-{{id}}" class="commons-post-options">
{{#if canComment}}
<a href="javascript:;" id="commons-create-comment-link-{{id}}" class="commons-create-comment-link" data-post-id="{{id}}">{{translate 'comment'}}</a>
<a href="javascript:;" id="commons-create-comment-link-{{id}}" class="commons-create-comment-link" data-post-id="{{id}}">{{tr 'commons' 'comment'}}</a>
{{/if}}
{{#if canEdit}}
<a href="javascript:;" id="commons-post-edit-link-{{id}}" class="commons-post-edit-link" data-post-id="{{id}}">{{translate 'edit'}}</a>
<a href="javascript:;" id="commons-post-edit-link-{{id}}" class="commons-post-edit-link" data-post-id="{{id}}">{{tr 'commons' 'edit'}}</a>
{{/if}}
{{#if canDelete}}
<a href="javascript:;" id="commons-post-delete-link-{{id}}" class="commons-post-delete-link" data-post-id="{{id}}">{{translate 'del'}}</a>
<a href="javascript:;" id="commons-post-delete-link-{{id}}" class="commons-post-delete-link" data-post-id="{{id}}">{{tr 'commons' 'del'}}</a>
{{/if}}
{{#if isModified}}
<span class="commons-date">{{translate 'modified_at'}} {{formattedModifiedDate}}</span>
<span class="commons-date">{{tr 'commons' 'modified_at'}} {{formattedModifiedDate}}</span>
{{else}}
<span class="commons-date">{{formattedReleaseDate}}</span>
{{/if}}
</div>
<div id="commons-post-edit-buttons-{{id}}" class="commons-post-edit-buttons">
<button id="commons-inplace-post-editor-post-button-{{id}}">{{translate 'post'}}</button>
<button onclick="commons.utils.cancelPostEdit('{{id}}');">{{translate 'cancel'}}</button>
<button id="commons-inplace-post-editor-post-button-{{id}}">{{tr 'commons' 'post'}}</button>
<button onclick="commons.utils.cancelPostEdit('{{id}}');">{{tr 'commons' 'cancel'}}</button>
</div>
</div>
</div> <!-- commons-post-text-container -->
Expand All @@ -33,8 +33,8 @@

<div id="commons-comments-{{id}}" class="commons-comments">
<div id="commons-comments-container-{{id}}">
<div class="commons-comment-expander"><a href="javascript:;" id="commons-show-comments-link-{{id}}">{{translate 'show_comments'}}</a></div>
<div class="commons-comment-expander"><a href="javascript:;" id="commons-hide-comments-link-{{id}}" style="display: none;">{{translate 'hide_comments'}}</a></div>
<div class="commons-comment-expander"><a href="javascript:;" id="commons-show-comments-link-{{id}}">{{tr 'commons' 'show_comments'}}</a></div>
<div class="commons-comment-expander"><a href="javascript:;" id="commons-hide-comments-link-{{id}}" style="display: none;">{{tr 'commons' 'hide_comments'}}</a></div>
{{#each comments}}
{{> wrapped_comment}}
{{/each}}
Expand Down
26 changes: 13 additions & 13 deletions commons/tool/src/webapp/WEB-INF/templates/posts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<div class="commons-photo-text-wrapper">
<div class="commons-photo" style="background-image:url(/direct/profile/{{currentUserId}}/image/thumb)"></div>
<div class="commons-editor-text-wrapper">
<div class="commons-editor-text"><div id="commons-post-creator-editor" contenteditable="true">{{translate 'post_editor_initial_text'}}</div></div>
<div class="commons-editor-text"><div id="commons-post-creator-editor" contenteditable="true">{{tr 'commons' 'post_editor_initial_text'}}</div></div>
</div>
</div>
<div id="commons-editor-toolbar">
<button id="commons-editor-post-button" disabled="true">{{translate 'post'}}</button>
<button id="commons-editor-cancel-button" disabled="true">{{translate 'cancel'}}</button>
<button id="commons-editor-link-button" class="commons-editor-special-button" title="{{translate 'link_button_tooltip'}}"><span class="fa fa-link"></span></button>
<button id="commons-editor-image-button" class="commons-editor-special-button" title="{{translate 'image_button_tooltip'}}"><span class="fa fa-picture-o"></span></button>
<button id="commons-editor-post-button" disabled="true">{{tr 'commons' 'post'}}</button>
<button id="commons-editor-cancel-button" disabled="true">{{tr 'commons' 'cancel'}}</button>
<button id="commons-editor-link-button" class="commons-editor-special-button" title="{{tr 'commons' 'link_button_tooltip'}}"><span class="fa fa-link"></span></button>
<button id="commons-editor-image-button" class="commons-editor-special-button" title="{{tr 'commons' 'image_button_tooltip'}}"><span class="fa fa-picture-o"></span></button>
</div>
</div>

Expand All @@ -25,27 +25,27 @@
<div class="commons-dialog-container">
<div id="commons-link-dialog-table">
<div class="commons-link-dialog-row">
<div>{{translate 'display_text'}}</div><input type="text" id="commons-link-dialog-text" />
<div>{{tr 'commons' 'display_text'}}</div><input type="text" id="commons-link-dialog-text" />
</div>
<div class="commons-link-dialog-row">
<div>{{translate 'link_to'}}</div><input type="text" id="commons-link-dialog-url" />
<div>{{tr 'commons' 'link_to'}}</div><input type="text" id="commons-link-dialog-url" />
</div>
<div class="commons-link-dialog-row">
<div>{{translate 'load_thumbnail'}}</div><input type="checkbox" id="commons-link-dialog-load-thumbnail"/ >
<div>{{tr 'commons' 'load_thumbnail'}}</div><input type="checkbox" id="commons-link-dialog-load-thumbnail"/ >
</div>
</div>
<button id="commons-link-dialog-insert-button" disabled="true">{{translate 'insert'}}</button>
<button id="commons-link-dialog-cancel-button">{{translate 'cancel'}}</button>
<button id="commons-link-dialog-insert-button" disabled="true">{{tr 'commons' 'insert'}}</button>
<button id="commons-link-dialog-cancel-button">{{tr 'commons' 'cancel'}}</button>
</div>
</div>
<div id="commons-image-dialog">
<div class="commons-dialog-container">
<div id="commons-link-dialog-table">
<div class="commons-link-dialog-row">
<div>{{translate 'choose_file'}}</div><input type="file" id="commons-image-dialog-file" accept=".png,.jpg,.jpeg,.gif,image/png,image/jpeg,image/jpg,image/gif" />
<div>{{tr 'commons' 'choose_file'}}</div><input type="file" id="commons-image-dialog-file" accept=".png,.jpg,.jpeg,.gif,image/png,image/jpeg,image/jpg,image/gif" />
</div>
</div>
<button id="commons-image-dialog-insert-button" disabled="true">{{translate 'insert'}}</button>
<button id="commons-image-dialog-cancel-button">{{translate 'cancel'}}</button>
<button id="commons-image-dialog-insert-button" disabled="true">{{tr 'commons' 'insert'}}</button>
<button id="commons-image-dialog-cancel-button">{{tr 'commons' 'cancel'}}</button>
</div>
</div>
2 changes: 1 addition & 1 deletion commons/tool/src/webapp/WEB-INF/templates/single_post.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div id="commons-single-post-title">{{translate 'commons_link_preamble'}}<a id="commons-view-commons-link" href="javascript:;">{{translate 'here'}}</a>{{translate 'commons_link_postamble'}}</div>
<div id="commons-single-post-title">{{tr 'commons' 'commons_link_preamble'}}<a id="commons-view-commons-link" href="javascript:;">{{tr 'commons' 'here'}}</a>{{tr 'commons' 'commons_link_postamble'}}</div>
<div id="commons-post-{{id}}" class="commons-post" data-creator-id="{{creatorId}}">
</div>
2 changes: 1 addition & 1 deletion commons/tool/src/webapp/WEB-INF/templates/toolbar.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<li id="commons-permissions-link" role="menuitem"><span><a href="javascript:;">{{translate 'permissions'}}</a></span></li>
<li id="commons-permissions-link" role="menuitem"><span><a href="javascript:;">{{tr 'commons' 'permissions'}}</a></span></li>
27 changes: 12 additions & 15 deletions commons/tool/src/webapp/js/commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ commons.AJAX_TIMEOUT = 5000;
Handlebars.registerPartial('comment', Handlebars.partials['comment']);
Handlebars.registerPartial('wrapped_comment', Handlebars.partials['wrapped_comment']);
Handlebars.registerPartial('inplace_comment_editor', Handlebars.partials['inplace_comment_editor']);
Handlebars.registerHelper('translate', function (key) {
return commons.i18n[key];
});

commons.states = {
POSTS: 'posts',
Expand Down Expand Up @@ -104,7 +101,7 @@ commons.switchState = function (state, arg) {

editor.click(function (e) {

if (this.innerHTML == commons.i18n.post_editor_initial_text) {
if (this.innerHTML == commons.i18n['post_editor_initial_text']) {
this.innerHTML = '';
$('#commons-editor-post-button').prop('disabled', false);
editorPostButton.prop('disabled', false);
Expand All @@ -128,7 +125,7 @@ commons.switchState = function (state, arg) {

commons.utils.savePost('', editor.html(), function (post) {

editor.html(commons.i18n.post_editor_initial_text);
editor.html(commons.i18n['post_editor_initial_text']);
editorPostButton.prop('disabled', true);
editorCancelButton.prop('disabled', true);
fileField.val('');
Expand All @@ -144,7 +141,7 @@ commons.switchState = function (state, arg) {

editorCancelButton.click(function (e) {

editor.html(commons.i18n.post_editor_initial_text);
editor.html(commons.i18n['post_editor_initial_text']);
editorPostButton.prop('disabled', true);
editorCancelButton.prop('disabled', true);
});
Expand Down Expand Up @@ -300,7 +297,7 @@ commons.switchState = function (state, arg) {

var languagesLoaded = function () {

commons.i18n = $.i18n.map;
commons.i18n = portal.i18n.translations['commons'];

if (commons.embedder === 'SITE') {
commons.utils.renderTemplate('toolbar', {} ,'commons-toolbar');
Expand Down Expand Up @@ -338,14 +335,14 @@ commons.switchState = function (state, arg) {
commons.utils.getCurrentUserPermissions(permissionsCallback);
};

$.i18n.properties({
name:'ui',
path:'/commons-tool/i18n/',
mode: 'both',
checkAvailableLanguages: true,
async: true,
language: sakai.locale.userLocale,
callback: function () { languagesLoaded(); }
$(document).ready(function () {

portal.i18n.loadProperties({
resourceClass: 'org.sakaiproject.commons.api.CommonsManager',
resourceBundle: 'org.sakaiproject.commons.impl.ui',
namespace: 'commons',
callback: function () { languagesLoaded(); }
});
});

if (CKEDITOR) {
Expand Down
Loading

0 comments on commit f4b98dc

Please sign in to comment.