1
2
3
4
5 package com.jcabi.ssl.maven.plugin;
6
7 import java.util.HashMap;
8 import java.util.Locale;
9 import java.util.Map;
10
11
12
13
14
15
16
17 public final class Yes {
18
19
20
21
22 private final transient Map<String, String> translations;
23
24
25
26
27 @SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
28 public Yes() {
29 this.translations = new HashMap<String, String>();
30 this.translations.put("en", "yes");
31 this.translations.put("de", "ja");
32 this.translations.put("fr", "oui");
33 this.translations.put("ru", "да");
34 this.translations.put("es", "sí");
35 this.translations.put("ua", "так");
36 this.translations.put("jp", "はい");
37 }
38
39
40
41
42
43
44 public String translate(final Locale locale) {
45 final String language = locale.getLanguage();
46 final String translation = this.translations.get(language);
47 if (translation == null) {
48 throw new IllegalArgumentException(
49 String.format(
50 new StringBuilder()
51 .append("Language %s is not supported, you can create ")
52 .append("an issue on Github and we'll fix it")
53 .toString(),
54 language
55 )
56 );
57 }
58 return translation;
59 }
60 }