本文整理匯總了Java中framework.services.configuration.Language類的典型用法代碼示例。如果您正苦於以下問題:Java Language類的具體用法?Java Language怎麽用?Java Language使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Language類屬於framework.services.configuration包,在下文中一共展示了Language類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendNotification
import framework.services.configuration.Language; //導入依賴的package包/類
/**
* Send a notification to a user (principal).
*
* @param notificationManagerService
* the notification manager service
* @param i18nMessagesService
* the i18n messages service
* @param recipient
* the uid of the user (principal)
* @param category
* the notification category
* @param url
* the attached url for the notification
* @param titleKey
* the i18n key of the notification title
* @param messageKey
* the i18n key of the message to send
* @param args
* the arguments for the message
*/
public static void sendNotification(INotificationManagerPlugin notificationManagerService, II18nMessagesPlugin i18nMessagesService, String recipient,
NotificationCategory category, String url, String titleKey, String messageKey, Object... args) {
// get the principal
Principal principal = Principal.getPrincipalFromUid(recipient);
if (principal != null) {
// get the language
Language language = new Language(principal.preferredLanguage);
// construct the title and the message
String message = null;
String title = null;
if (i18nMessagesService.isLanguageValid(language.getCode())) {
message = Msg.get(language.getLang(), messageKey, args);
title = Msg.get(language.getLang(), titleKey);
} else {
message = Msg.get(messageKey, args);
title = Msg.get(titleKey);
}
notificationManagerService.sendNotification(recipient, category, title, message, url);
}
}
示例2: createAction
import framework.services.configuration.Language; //導入依賴的package包/類
@Override
public Action<Void> createAction(Request request, Method actionMethod) {
return new Action.Simple() {
@Override
public Promise<Result> call(Context ctx) throws Throwable {
// Inject the required services into the context
injectCommonServicesIncontext(ctx);
final Language language = new Language(request.getQueryString("lang"));
if (messagesPlugin.isLanguageValid(language.getCode())) {
Logger.debug("change language to: " + language.getCode());
ctx.changeLang(language.getCode());
// Update the CAS language cookie which is relying on Spring
// framework (not really solid yet works)
Utilities.setSsoLanguage(ctx, language.getCode());
}
return delegate.call(ctx);
}
};
}
示例3: processEditTranslation
import framework.services.configuration.Language; //導入依賴的package包/類
@Restrict({ @Group(IMafConstants.ADMIN_TRANSLATION_KEY_EDIT_PERMISSION) })
public Result processEditTranslation() {
// bind the form
Form<TranslationFormData> boundForm = translationFormTemplate.bindFromRequest();
if (boundForm.hasErrors()) {
return ok(views.html.admin.config.translations.edit.render(boundForm));
}
TranslationFormData translationFormData = boundForm.get();
if (!this.getI18nMessagesPlugin().isAuthorizedKey(translationFormData.key)) {
return forbidden(views.html.error.access_forbidden.render(""));
}
for (int i = 0; i < getI18nMessagesPlugin().getValidLanguageList().size(); i++) {
Language language = getI18nMessagesPlugin().getValidLanguageList().get(i);
String value = translationFormData.value.getValues().get(i);
if (value != null && !value.equals("")) {
getI18nMessagesPlugin().add(translationFormData.key, value, language.getCode());
} else {
getI18nMessagesPlugin().delete(translationFormData.key, language.getCode());
}
}
Utilities.sendSuccessFlashMessage(Msg.get("admin.configuration.translations.edit.successful"));
this.getTableProvider().flushFilterConfig();
return redirect(controllers.admin.routes.ConfigurationController.searchResultsTranslations(translationFormData.keywords));
}
示例4: getLanguagesAsVHC
import framework.services.configuration.Language; //導入依賴的package包/類
public DefaultSelectableValueHolderCollection<String> getLanguagesAsVHC(II18nMessagesPlugin i18nMessagesPlugin) {
DefaultSelectableValueHolderCollection<String> vhc = new DefaultSelectableValueHolderCollection<>();
for (String code : this.languages.split(",")) {
Language language = i18nMessagesPlugin.getLanguageByCode(code);
if (language != null) {
vhc.add(new DefaultSelectableValueHolder<>(code, language.getName()));
}
}
return vhc;
}
示例5: loginCode
import framework.services.configuration.Language; //導入依賴的package包/類
/**
* The code executed depending on the login implementation.
*
* @param redirectUrl
* the URL to which the user must be redirected after
* authentication
* @return
*/
private Result loginCode(String redirectUrl) {
try {
String uid = getUserSessionManagerPlugin().getUserSessionId(ctx());
if (log.isDebugEnabled()) {
log.debug("Here is the user session uid found " + uid);
}
IUserAccount userAccount = getAccountManagerPlugin().getUserAccountFromUid(uid);
// User is not found
if (userAccount == null) {
if (log.isDebugEnabled()) {
log.debug("The account associated with " + uid + " was not found by the account manager, instance is not accessible");
}
getUserSessionManagerPlugin().clearUserSession(ctx());
return redirect(getLocalRoutes().getNoFederatedAccount());
}
// event: success login
if (userAccount.isDisplayed()) {
getInstanceAccessSupervisor().logSuccessfulLoginEvent(getUserSessionManagerPlugin().getUserSessionId(ctx()));
}
// get the preferred language as object
Language language = new Language(userAccount.getPreferredLanguage());
// verify the language is valid
if (getI18nMessagesPlugin().isLanguageValid(language.getCode())) {
Logger.debug("change language to: " + language.getCode());
ctx().changeLang(language.getCode());
Utilities.setSsoLanguage(ctx(), language.getCode());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return redirect(redirectUrl);
}
示例6: persist
import framework.services.configuration.Language; //導入依賴的package包/類
/**
* Persist the values in the DB (this method is called after a save/update
* of an entry => one call for each field with MultiLanguagesString type).
*
* @param
*/
public void persist(II18nMessagesPlugin i18nMessagesPlugin) {
for (int i = 0; i < i18nMessagesPlugin.getValidLanguageList().size(); i++) {
Language language = i18nMessagesPlugin.getValidLanguageList().get(i);
String value = this.values.get(i);
if (value != null && !value.equals("")) {
i18nMessagesPlugin.add(this.key, value, language.getCode());
} else {
i18nMessagesPlugin.delete(this.key, language.getCode());
}
}
}