forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-29422 Switch I18n implementation to use ResourceLoader
- Loading branch information
1 parent
d81e29b
commit d71e938
Showing
9 changed files
with
112 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,6 @@ | |
import java.util.HashMap; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import org.json.simple.JSONArray; | ||
import org.json.simple.JSONObject; | ||
import org.sakaiproject.authz.cover.FunctionManager; | ||
|
@@ -51,7 +50,7 @@ | |
import org.sakaiproject.pasystem.api.Popup; | ||
import org.sakaiproject.pasystem.api.Popups; | ||
import org.sakaiproject.pasystem.impl.banners.BannerStorage; | ||
import org.sakaiproject.pasystem.impl.common.JSONI18n; | ||
import org.sakaiproject.pasystem.impl.common.SakaiI18n; | ||
import org.sakaiproject.pasystem.impl.popups.PopupForUser; | ||
import org.sakaiproject.pasystem.impl.popups.PopupStorage; | ||
import org.sakaiproject.portal.util.PortalUtils; | ||
|
@@ -73,17 +72,13 @@ class PASystemImpl implements PASystem { | |
|
||
private static final String POPUP_SCREEN_SHOWN = "pasystem.popup.screen.shown"; | ||
|
||
private Map<String, I18n> i18nStore; | ||
|
||
@Override | ||
public void init() { | ||
if (ServerConfigurationService.getBoolean("auto.ddl", false) || ServerConfigurationService.getBoolean("pasystem.auto.ddl", false)) { | ||
runDBMigration(ServerConfigurationService.getString("[email protected]")); | ||
} | ||
|
||
FunctionManager.registerFunction("pasystem.manage"); | ||
|
||
i18nStore = new ConcurrentHashMap<String, I18n>(1); | ||
} | ||
|
||
@Override | ||
|
@@ -94,8 +89,7 @@ public void destroy() { | |
public String getFooter() { | ||
StringBuilder result = new StringBuilder(); | ||
|
||
Locale userLocale = PreferencesService.getLocale(SessionManager.getCurrentSessionUserId()); | ||
I18n i18n = getI18n(this.getClass().getClassLoader(), "i18n", userLocale); | ||
I18n i18n = getI18n(this.getClass().getClassLoader(), "org.sakaiproject.pasystem.impl.i18n.pasystem"); | ||
Handlebars handlebars = loadHandleBars(i18n); | ||
|
||
Session session = SessionManager.getCurrentSession(); | ||
|
@@ -132,20 +126,8 @@ public Popups getPopups() { | |
} | ||
|
||
@Override | ||
public I18n getI18n(ClassLoader loader, String resourceBase, Locale locale) { | ||
String language = "en"; | ||
|
||
if (locale != null) { | ||
language = locale.getLanguage(); | ||
} | ||
|
||
String i18nKey = resourceBase + "::" + language + "::" + loader.hashCode(); | ||
|
||
if (!i18nStore.containsKey(i18nKey)) { | ||
i18nStore.put(i18nKey, new JSONI18n(loader, resourceBase, locale)); | ||
} | ||
|
||
return i18nStore.get(i18nKey); | ||
public I18n getI18n(ClassLoader loader, String resourceBase) { | ||
return new SakaiI18n(loader, resourceBase); | ||
} | ||
|
||
private Handlebars loadHandleBars(final I18n i18n) { | ||
|
81 changes: 0 additions & 81 deletions
81
pasystem/pasystem-impl/impl/src/java/org/sakaiproject/pasystem/impl/common/JSONI18n.java
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
pasystem/pasystem-impl/impl/src/java/org/sakaiproject/pasystem/impl/common/SakaiI18n.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/********************************************************************************** | ||
* | ||
* Copyright (c) 2015 The Sakai Foundation | ||
* | ||
* Original developers: | ||
* | ||
* New York University | ||
* Payten Giles | ||
* Mark Triggs | ||
* | ||
* Licensed under the Educational Community 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.osedu.org/licenses/ECL-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.sakaiproject.pasystem.impl.common; | ||
|
||
import java.util.MissingResourceException; | ||
import org.sakaiproject.pasystem.api.I18n; | ||
import org.sakaiproject.util.ResourceLoader; | ||
|
||
/** | ||
* An I18N implementation based on Sakai's ResourceLoader. | ||
*/ | ||
public class SakaiI18n implements I18n { | ||
|
||
private ResourceLoader resourceLoader; | ||
|
||
public SakaiI18n(ClassLoader loader, String resourceBase) { | ||
resourceLoader = new ResourceLoader(resourceBase, loader); | ||
} | ||
|
||
@Override | ||
public String t(String key) { | ||
String result = resourceLoader.getString(key); | ||
|
||
if (result == null) { | ||
throw new RuntimeException("Missing translation for key: " + key); | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
.../pasystem-impl/impl/src/resources/org/sakaiproject/pasystem/impl/i18n/pasystem.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
popup-acknowledged=Don't show this again | ||
popup-remind-later=Remind me later | ||
Show\ System\ Alerts=Show System Alerts | ||
timezone-does-not-match-msg=Your computer's time zone <span class="computerTimezone">${reportedTimezone}</span> does not match your account's time zone of <span class="prefsTimezone">${prefsTimezone}</span>. <span class="pasystem-tz-click-here"><a href="${setTimezoneUrl}" id="setTimezoneMsg">Click here to update your time zone preferences</a></span>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
pasystem/pasystem-tool/tool/src/java/org/sakaiproject/pasystem/tool/i18n/default.json
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
pasystem/pasystem-tool/tool/src/java/org/sakaiproject/pasystem/tool/i18n/pasystem.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Active=Active | ||
Are\ you\ sure\ you\ want\ to\ delete\ this\ banner?=Are you sure you want to delete this banner? | ||
Are\ you\ sure\ you\ want\ to\ delete\ this\ popup?=Are you sure you want to delete this popup? | ||
Banners=Banners | ||
Cancel=Cancel | ||
Close=Close | ||
Create\ Banner=Create Banner | ||
Create\ Popup=Create Popup | ||
Delete\ Banner=Delete Banner | ||
Delete\ Popup=Delete Popup | ||
Description=Description | ||
Dismissible=Dismissible | ||
Distribution=Distribution | ||
Edit=Edit | ||
End\ Time=End Time | ||
From=From | ||
Hosts=Hosts | ||
Message=Message | ||
Popups=Popups | ||
Preview=Preview | ||
Save\ Banner=Save Banner | ||
Save\ Popup=Save Popup | ||
Start\ Time=Start Time | ||
Template=Template | ||
Timezone\ Check=Timezone Check | ||
Type=Type | ||
Until=Until | ||
banner_created=Banner Created | ||
banner_deleted=Banner Deleted | ||
banner_type_help=Note: When a user dismisses a "Medium" alert, a small "Show System Alerts" button will remain at the top of their screen. Clicking on this button will cause all active Medium alerts to reappear for the user. | ||
banner_type_high=High | ||
banner_type_high_option=High - Cannot be dismissed by user | ||
banner_type_low=Low | ||
banner_type_low_option=Low - Can be permanently dismissed by user | ||
banner_type_medium=Medium | ||
banner_type_medium_option=Medium - Can be temporarily dismissed by user; reappears after 24 hours | ||
banner_updated=Banner Updated | ||
distribution_everyone=Show this campaign to everyone | ||
distribution_selected_users=Show this campaign to selected users | ||
invalid_time=Time was not valid | ||
pasystem-disabled=The Public Announcement System has not been enabled. Set <tt>pasystem.enabled=true</tt> in your properties file to activate it. | ||
popup_created=Popup Created | ||
popup_deleted=Popup Deleted | ||
popup_updated=Popup Updated | ||
start_time_after_end_time=Start time must fall before end time | ||
template_upload_failed=Template file failed to upload | ||
template_was_missing=Could not find a template for the selected popup screen | ||
timezone-check-active=Timezone checking is <strong>active</strong> | ||
timezone-check-disabled=Timezone checking is <strong>disabled</strong>. Set <tt>pasystem.timezone-check=true</tt> in your properties file to activate it. | ||
uuid_missing=The requested record could not be found |