<tr><th><wicket:message key="gb.confirmPassword"></wicket:message></th><td class="edit"><input type="password" wicket:id="confirmPassword" size="30" tabindex="3" /></td></tr>\r
<tr><th><wicket:message key="gb.displayName"></wicket:message></th><td class="edit"><input type="text" wicket:id="displayName" size="30" tabindex="4" /></td></tr>\r
<tr><th><wicket:message key="gb.emailAddress"></wicket:message></th><td class="edit"><input type="text" wicket:id="emailAddress" size="30" tabindex="5" /></td></tr>\r
- <tr><th><wicket:message key="gb.canAdmin"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="canAdmin" tabindex="6" /> <span class="help-inline"><wicket:message key="gb.canAdminDescription"></wicket:message></span></label></td></tr>\r
- <tr><th><wicket:message key="gb.canCreate"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="canCreate" tabindex="7" /> <span class="help-inline"><wicket:message key="gb.canCreateDescription"></wicket:message></span></label></td></tr>\r
- <tr><th><wicket:message key="gb.canFork"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="canFork" tabindex="8" /> <span class="help-inline"><wicket:message key="gb.canForkDescription"></wicket:message></span></label></td></tr>\r
- <tr><th><wicket:message key="gb.excludeFromFederation"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="excludeFromFederation" tabindex="9" /> <span class="help-inline"><wicket:message key="gb.excludeFromFederationDescription"></wicket:message></span></label></td></tr> \r
- <tr><th><wicket:message key="gb.disableUser"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="disabled" tabindex="10" /> <span class="help-inline"><wicket:message key="gb.disableUserDescription"></wicket:message></span></label></td></tr>\r
+ <tr><th><wicket:message key="gb.languagePreference"></wicket:message></th><td class="edit"><select wicket:id="language" ></select></td></tr>\r
+ <tr><th><wicket:message key="gb.canAdmin"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="canAdmin" tabindex="7" /> <span class="help-inline"><wicket:message key="gb.canAdminDescription"></wicket:message></span></label></td></tr>\r
+ <tr><th><wicket:message key="gb.canCreate"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="canCreate" tabindex="8" /> <span class="help-inline"><wicket:message key="gb.canCreateDescription"></wicket:message></span></label></td></tr>\r
+ <tr><th><wicket:message key="gb.canFork"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="canFork" tabindex="9" /> <span class="help-inline"><wicket:message key="gb.canForkDescription"></wicket:message></span></label></td></tr>\r
+ <tr><th><wicket:message key="gb.excludeFromFederation"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="excludeFromFederation" tabindex="10" /> <span class="help-inline"><wicket:message key="gb.excludeFromFederationDescription"></wicket:message></span></label></td></tr> \r
+ <tr><th><wicket:message key="gb.disableUser"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="disabled" tabindex="11" /> <span class="help-inline"><wicket:message key="gb.disableUserDescription"></wicket:message></span></label></td></tr>\r
</tbody>\r
</table>\r
</div>\r
import java.util.Collections;\r
import java.util.Iterator;\r
import java.util.List;\r
+import java.util.Locale;\r
\r
import org.apache.wicket.PageParameters;\r
import org.apache.wicket.behavior.SimpleAttributeModifier;\r
import org.apache.wicket.extensions.markup.html.form.palette.Palette;\r
import org.apache.wicket.markup.html.form.Button;\r
import org.apache.wicket.markup.html.form.CheckBox;\r
+import org.apache.wicket.markup.html.form.DropDownChoice;\r
import org.apache.wicket.markup.html.form.Form;\r
import org.apache.wicket.markup.html.form.TextField;\r
import org.apache.wicket.model.CompoundPropertyModel;\r
+import org.apache.wicket.model.IModel;\r
import org.apache.wicket.model.Model;\r
import org.apache.wicket.model.util.CollectionModel;\r
import org.apache.wicket.model.util.ListModel;\r
final Palette<String> teams = new Palette<String>("teams", new ListModel<String>(\r
new ArrayList<String>(userTeams)), new CollectionModel<String>(app().users()\r
.getAllTeamNames()), new StringChoiceRenderer(), 10, false);\r
+ Locale locale = userModel.getPreferences().getLocale();\r
+ if (locale == null) {\r
+ locale = Locale.ENGLISH;\r
+ }\r
+\r
+ List<Language> languages = UserPage.getLanguages();\r
+ Language preferredLanguage = null;\r
+ if (locale != null) {\r
+ String localeCode = locale.getLanguage();\r
+ if (!StringUtils.isEmpty(locale.getCountry())) {\r
+ localeCode += "_" + locale.getCountry();\r
+ }\r
+\r
+ for (Language lang : languages) {\r
+ if (lang.code.equals(localeCode)) {\r
+ // language_COUNTRY match\r
+ preferredLanguage = lang;\r
+ } else if (preferredLanguage != null && lang.code.startsWith(locale.getLanguage())) {\r
+ // language match\r
+ preferredLanguage = lang;\r
+ }\r
+ }\r
+ }\r
+ final IModel<Language> language = Model.of(preferredLanguage); \r
Form<UserModel> form = new Form<UserModel>("editForm", model) {\r
\r
private static final long serialVersionUID = 1L;\r
error(getString("gb.pleaseSetUsername"));\r
return;\r
}\r
+ Language lang = language.getObject();\r
+ if (lang != null) {\r
+ userModel.getPreferences().setLocale(lang.code);\r
+ }\r
// force username to lower-case\r
userModel.username = userModel.username.toLowerCase();\r
String username = userModel.username;\r
form.add(confirmPasswordField.setEnabled(editCredentials));\r
form.add(new TextField<String>("displayName").setEnabled(editDisplayName));\r
form.add(new TextField<String>("emailAddress").setEnabled(editEmailAddress));\r
+ \r
\r
+ DropDownChoice<Language> choice = new DropDownChoice<Language>("language",language,languages );\r
+ form.add( choice.setEnabled(languages.size()>0) );\r
if (userModel.canAdmin() && !userModel.canAdmin) {\r
// user inherits Admin permission\r
// display a disabled-yet-checked checkbox\r
--- /dev/null
+package com.gitblit.wicket.pages;
+
+import java.io.Serializable;
+
+public class Language implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ final String name;
+ final String code;
+
+ public Language(String name, String code) {
+ this.name = name;
+ this.code = code;
+ }
+
+ @Override
+ public String toString() {
+ return name + " (" + code + ")";
+ }
+}
\ No newline at end of file
\r
navLinks.add(menu);\r
}\r
-\r
- private void addPreferences(UserModel user) {\r
- // add preferences\r
- Form<Void> prefs = new Form<Void>("prefsForm");\r
-\r
- List<Language> languages = Arrays.asList(\r
+ \r
+ public static List<Language> getLanguages(){\r
+ return Arrays.asList(\r
new Language("Deutsch","de"),\r
new Language("English","en"),\r
new Language("Español", "es"),\r
new Language("Português", "pt_BR"),\r
new Language("簡體中文", "zh_CN"),\r
new Language("正體中文", "zh_TW"));\r
+ }\r
+ \r
+ private void addPreferences(UserModel user) {\r
+ // add preferences\r
+ Form<Void> prefs = new Form<Void>("prefsForm");\r
+\r
+ List<Language> languages = getLanguages();\r
\r
Locale locale = user.getPreferences().getLocale();\r
if (locale == null) {\r
add(new Fragment("sshKeysLink", "sshKeysLinkFragment", this).setRenderBodyOnly(true));\r
add(keysTab.setRenderBodyOnly(true));\r
}\r
-\r
- private class Language implements Serializable {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- final String name;\r
- final String code;\r
-\r
- public Language(String name, String code) {\r
- this.name = name;\r
- this.code = code;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return name + " (" + code +")";\r
- }\r
- }\r
}\r