1
2
3
4
5
6
7 package com.octo.captcha;
8
9 import java.util.Locale;
10 import java.util.ResourceBundle;
11
12 /***
13 * Helps to retrieve internationalized questions for captchas. Used by captcha factories.
14 *
15 * @author <a href="mailto:mag@jcaptcha.net">Marc-Antoine Garrigue</a>
16 * @version 1.0
17 */
18 public final class CaptchaQuestionHelper {
19
20 /***
21 * The bundle name used by this helper
22 */
23 public static final String BUNDLE_NAME =
24 CaptchaQuestionHelper.class.getName();
25
26 private CaptchaQuestionHelper() {
27 }
28
29
30 /***
31 * Return a localized question for the catpcha
32 *
33 * @param locale the locale
34 * @param key the key to retrieve a localized question : should be the captcha name
35 *
36 * @return a localized question
37 */
38 public static String getQuestion(Locale locale, String key) {
39 return ResourceBundle.getBundle(BUNDLE_NAME, locale).getString(key);
40 }
41
42 }