Projekt

Obecné

Profil

« Předchozí | Další » 

Revize e82df142

Přidáno uživatelem Pavel Fidransky před téměř 5 roky(ů)

re #36 drop localization from backend

Zobrazit rozdíly:

server/src/main/java/org/danekja/ymanager/Application.java
1 1
package org.danekja.ymanager;
2 2

  
3
import org.danekja.ymanager.util.localization.Language;
4
import org.danekja.ymanager.util.localization.Message;
5 3
import org.springframework.boot.SpringApplication;
6 4
import org.springframework.boot.autoconfigure.SpringBootApplication;
7 5

  
......
9 7
public class Application {
10 8

  
11 9
    public static void main(String[] args) {
12

  
13
        Message.config()
14
                .addLanguage(Language.EN)
15
                .addLanguage(Language.CZ);
16

  
17 10
        SpringApplication.run(Application.class, args);
18 11
    }
19 12
}
server/src/main/java/org/danekja/ymanager/business/ApiManager.java
149 149
        if (settings.getSickDayCount() != null) {
150 150

  
151 151
            if (user.getTakenSickDayCount() > settings.getSickDayCount()) {
152
                throw new IllegalArgumentException("settings.sick.day.lt.taken.error");
152
                throw new IllegalArgumentException("You cannot set a number of sick day lower than is taken at this moment.");
153 153
            }
154 154

  
155 155
            if (settings.getSickDayCount().equals(defaultSettings.getSickDayCount())) {
server/src/main/java/org/danekja/ymanager/domain/DefaultSettings.java
81 81

  
82 82
        if (sickDayCount == null) {
83 83
            DefaultSettings.log.warn("The given number of available sick days must not be null");
84
            throw new IllegalArgumentException("sick.day.null.error");
84
            throw new IllegalArgumentException("The number of sick days has to be filled in.");
85 85
        } else if (sickDayCount < 0) {
86 86
            DefaultSettings.log.warn("The number of available sick days was negative");
87
            throw new IllegalArgumentException("sick.day.count.error");
87
            throw new IllegalArgumentException("The number of sick days has to be non-negative number.");
88 88
        }
89 89

  
90 90
        this.sickDayCount = sickDayCount;
......
111 111

  
112 112
        if (notification == null) {
113 113
            DefaultSettings.log.warn("The notification must not be null");
114
            throw new IllegalArgumentException("notification.null.error");
114
            throw new IllegalArgumentException("The date of a notification has to be filled in.");
115 115
        }
116 116

  
117 117
        this.notification = notification;
server/src/main/java/org/danekja/ymanager/domain/RegisteredUser.java
146 146

  
147 147
        if (firstName == null) {
148 148
            User.log.warn("The given first name must not be null");
149
            throw new IllegalArgumentException("first.name.null.error");
149
            throw new IllegalArgumentException("The first name has to be filled in.");
150 150
        } else if (firstName.length() > NAME_LENGTH) {
151 151
            User.log.warn("The length of the given first name exceeded a limit");
152
            throw new IllegalArgumentException("name.length.error");
152
            throw new IllegalArgumentException("The length of a name mustn't exceed 45.");
153 153
        }
154 154

  
155 155
        this.firstName = firstName;
......
167 167

  
168 168
        if (lastName == null) {
169 169
            User.log.warn("The given last name must not be null");
170
            throw new IllegalArgumentException("last.name.null.error");
170
            throw new IllegalArgumentException("The last name has to be filled in.");
171 171
        } else if (lastName.length() > NAME_LENGTH) {
172 172
            User.log.warn("The length of the given last name exceeded a limit");
173
            throw new IllegalArgumentException("name.length.error");
173
            throw new IllegalArgumentException("The length of a name mustn't exceed 45.");
174 174
        }
175 175

  
176 176
        this.lastName = lastName;
......
188 188

  
189 189
        if (email == null) {
190 190
            User.log.warn("The given email must not be null");
191
            throw new IllegalArgumentException("email.null.error");
191
            throw new IllegalArgumentException("The email address has to be filled in.");
192 192
        } else if (email.length() > EMAIL_ADDRESS_LENGTH) {
193 193
            User.log.warn("The length of the email address exceeded a limit");
194
            throw new IllegalArgumentException("email.length.error");
194
            throw new IllegalArgumentException("The length of an email address mustn't exceed 100.");
195 195
        }
196 196

  
197 197
        this.email = email;
server/src/main/java/org/danekja/ymanager/domain/User.java
273 273

  
274 274
        if(from == null || to == null) {
275 275
            User.log.warn("A vacation has to have a starting and an ending time");
276
            throw new IllegalArgumentException("time.vacation.error");
276
            throw new IllegalArgumentException("A vacation has to have a starting and an ending time.");
277 277
        } else if (from.compareTo(to) >= 0) {
278 278
            User.log.warn("A vacation must not start after it ends. from={}, to={}", from, to);
279
            throw new IllegalArgumentException("time.order.error");
279
            throw new IllegalArgumentException("The overtime mustn't start after or at the same time it ends.");
280 280
        }
281 281

  
282 282
        final float difference = from.until(to, MINUTES) / 60f;
......
284 284

  
285 285
        if (tempVacationCount < 0) {
286 286
            User.log.warn("Cannot take a vacation, not enough available hours");
287
            throw new IllegalArgumentException("available.vacation.error");
287
            throw new IllegalArgumentException("You cannot take a vacation, not enough remaining hours.");
288 288
        }
289 289

  
290 290
        this.userData.setVacationCount(tempVacationCount);
server/src/main/java/org/danekja/ymanager/domain/UserData.java
70 70

  
71 71
        if (vacationCount == null) {
72 72
            User.log.warn("The number of remaining overtime must not be null");
73
            throw new IllegalArgumentException("vacation.null.error");
73
            throw new IllegalArgumentException("The number of overtime hours has to be filled in.");
74 74
        } else if (vacationCount < 0) {
75 75
            User.log.warn("The number of remaining overtime must not be negative");
76
            throw new IllegalArgumentException("negative.vacation.error");
76
            throw new IllegalArgumentException("The number of a remaining overtime mustn't be negative.");
77 77
        }
78 78

  
79 79
        this.vacationCount = vacationCount;
......
91 91

  
92 92
        if (value == null) {
93 93
            User.log.warn("The given value must not be null");
94
            throw new IllegalArgumentException("vacation.null.error");
94
            throw new IllegalArgumentException("The number of overtime hours has to be filled in.");
95 95
        } else if (this.vacationCount + value < 0) {
96 96
            User.log.warn("The number of remaining overtime must not be negative");
97
            throw new IllegalArgumentException("negative.vacation.error");
97
            throw new IllegalArgumentException("The number of a remaining overtime mustn't be negative.");
98 98
        }
99 99

  
100 100
        this.vacationCount += value;
......
115 115

  
116 116
        if (from == null || to == null) {
117 117
            User.log.warn("A vacation has to have a starting and an ending time");
118
            throw new IllegalArgumentException("time.vacation.error");
118
            throw new IllegalArgumentException("A vacation has to have a starting and an ending time.");
119 119
        } else if (from.compareTo(to) >= 0) {
120 120
            User.log.warn("A vacation must not start after it ends. from={}, to={}", from, to);
121
            throw new IllegalArgumentException("time.order.error");
121
            throw new IllegalArgumentException("The overtime mustn't start after or at the same time it ends.");
122 122
        }
123 123

  
124 124
        final float difference = from.until(to, ChronoUnit.MINUTES) / 60f;
......
146 146

  
147 147
        if (totalSickDayCount != null && totalSickDayCount < 0) {
148 148
            User.log.warn("The number of user's available sick days must not be negative");
149
            throw new IllegalArgumentException("negative.sick.day.error");
149
            throw new IllegalArgumentException("The number of sick days mustn't be negative.");
150 150
        }
151 151

  
152 152
        this.totalSickDayCount = totalSickDayCount;
......
173 173

  
174 174
        if (takenSickDayCount == null) {
175 175
            User.log.warn("The number number of user's taken sick days must not be null");
176
            throw new IllegalArgumentException("sick.day.null.error");
176
            throw new IllegalArgumentException("The number of sick days has to be filled in.");
177 177
        } else if (takenSickDayCount < 0) {
178 178
            User.log.warn("The number number of user's taken sick days must not be negative");
179
            throw new IllegalArgumentException("negative.sick.day.error");
179
            throw new IllegalArgumentException("The number of sick days mustn't be negative.");
180 180
        } else if (takenSickDayCount > this.totalSickDayCount) {
181 181
            User.log.warn("The number number of user's taken sick days must not greater than his/her available sick days");
182
            throw new IllegalArgumentException("taken.sick.day.count.error");
182
            throw new IllegalArgumentException("Not enough available sick days.");
183 183
        }
184 184

  
185 185
        this.takenSickDayCount = takenSickDayCount;
......
197 197

  
198 198
        if (value == null) {
199 199
            User.log.warn("The given value must not be null");
200
            throw new IllegalArgumentException("vacation.null.error");
200
            throw new IllegalArgumentException("The number of overtime hours has to be filled in.");
201 201
        } else if (this.takenSickDayCount + value < 0) {
202 202
            User.log.warn("The number number of user's taken sick days must not be negative");
203
            throw new IllegalArgumentException("negative.sick.day.error");
203
            throw new IllegalArgumentException("The number of sick days mustn't be negative.");
204 204
        } else if (this.takenSickDayCount + value > this.totalSickDayCount) {
205 205
            User.log.warn("The number number of user's taken sick days must not greater than his/her available sick days");
206
            throw new IllegalArgumentException("taken.sick.day.count.error");
206
            throw new IllegalArgumentException("Not enough available sick days.");
207 207
        }
208 208

  
209 209
        this.takenSickDayCount += value;
......
252 252

  
253 253
        if (role == null) {
254 254
            User.log.warn("The given role must not be null");
255
            throw new IllegalArgumentException("role.null.error");
255
            throw new IllegalArgumentException("The role has to be filled in.");
256 256
        }
257 257

  
258 258
        this.role = role;
......
277 277

  
278 278
        if (status == null) {
279 279
            User.log.warn("The given status must not be null");
280
            throw new IllegalArgumentException("status.null.error");
280
            throw new IllegalArgumentException("The status has to be filled in.");
281 281
        }
282 282

  
283 283
        this.status = status;
server/src/main/java/org/danekja/ymanager/domain/Vacation.java
95 95

  
96 96
        if (date == null) {
97 97
            Vacation.log.warn("The given date must not be null.");
98
            throw new IllegalArgumentException("date.null.error");
98
            throw new IllegalArgumentException("The date has to be filled in.");
99 99
        }
100 100

  
101 101
        this.date = date;
......
122 122

  
123 123
        if (from != null && this.type == VacationType.SICK_DAY) {
124 124
            Vacation.log.warn("A sick day must not have a starting or an ending time");
125
            throw new IllegalArgumentException("time.sick.day.error");
125
            throw new IllegalArgumentException("A sick day mustn't have a starting or an ending time.");
126 126
        } else if(from == null && this.type == VacationType.VACATION) {
127 127
            Vacation.log.warn("A vacation has to have a starting and an ending time");
128
            throw new IllegalArgumentException("time.vacation.error");
128
            throw new IllegalArgumentException("A vacation has to have a starting and an ending time.");
129 129
        } else if (from != null && this.to != null && from.compareTo(this.to) >= 0) {
130 130
            Vacation.log.warn("A vacation must not start after it ends. from={}, to={}", from, this.to);
131
            throw new IllegalArgumentException("time.order.error");
131
            throw new IllegalArgumentException("The overtime mustn't start after or at the same time it ends.");
132 132
        }
133 133

  
134 134
        this.from = from;
......
158 158
            throw new IllegalArgumentException("time.sick_day.error");
159 159
        } else if(to == null && this.type == VacationType.VACATION) {
160 160
            Vacation.log.warn("A vacation has to have a starting and an ending time");
161
            throw new IllegalArgumentException("time.vacation.error");
161
            throw new IllegalArgumentException("A vacation has to have a starting and an ending time.");
162 162
        } else if (to != null && this.from != null && to.compareTo(this.from) <= 0) {
163 163
            Vacation.log.warn("A vacation must not end after it starts. from={}, to={}", this.from, to);
164
            throw new IllegalArgumentException("time.order.error");
164
            throw new IllegalArgumentException("The overtime mustn't start after or at the same time it ends.");
165 165
        }
166 166

  
167 167
        this.to = to;
......
183 183
            throw new IllegalArgumentException("time.sick.day_error");
184 184
        } else if((from == null || to == null) && this.type == VacationType.VACATION) {
185 185
            Vacation.log.warn("A vacation has to have a starting and an ending time");
186
            throw new IllegalArgumentException("time.vacation.error");
186
            throw new IllegalArgumentException("A vacation has to have a starting and an ending time.");
187 187
        } else if (from != null && to != null && from.compareTo(to) >= 0) {
188 188
            Vacation.log.warn("A vacation must not start after it ends. from={}, to={}", from, to);
189
            throw new IllegalArgumentException("time.order.error");
189
            throw new IllegalArgumentException("The overtime mustn't start after or at the same time it ends.");
190 190
        }
191 191

  
192 192
        this.from = from;
......
234 234

  
235 235
        if (status == null) {
236 236
            Vacation.log.warn("The given status must not be null");
237
            throw new IllegalArgumentException("status.null.error");
237
            throw new IllegalArgumentException("The status has to be filled in.");
238 238
        }
239 239

  
240 240
        this.status = status;
......
265 265
            this.to = null;
266 266
        } else if (type == null) {
267 267
            Vacation.log.warn("The given type of a vacation must not be null");
268
            throw new IllegalArgumentException("type.null.error");
268
            throw new IllegalArgumentException("The type has to be filled in.");
269 269
        }
270 270

  
271 271
        this.type = type;
server/src/main/java/org/danekja/ymanager/util/localization/Language.java
1
package org.danekja.ymanager.util.localization;
2

  
3
import java.util.Locale;
4

  
5
public enum  Language {
6

  
7
    EN  (Locale.ENGLISH),
8
    CZ  (new Locale("cs", "")),
9

  
10
    ;
11
    private Locale locale;
12
    Language(Locale locale) {
13
        this.locale = locale;
14
    }
15

  
16
    public Locale getLocale() {
17
        return locale;
18
    }
19

  
20
    public static Language getLanguageOrDefault(String lang, Language defaultLang) {
21
        try {
22
            return lang != null ? valueOf(lang.toUpperCase()) : defaultLang;
23
        } catch (IllegalArgumentException | NullPointerException e) {
24
            return defaultLang;
25
        }
26
    }
27

  
28
    public static Language getLanguage(String lang) {
29
        return getLanguageOrDefault(lang, EN);
30
    }
31
}
server/src/main/java/org/danekja/ymanager/util/localization/Message.java
1
package org.danekja.ymanager.util.localization;
2

  
3
import java.util.HashMap;
4
import java.util.Map;
5
import java.util.ResourceBundle;
6

  
7
import static java.util.ResourceBundle.getBundle;
8

  
9
public final class Message {
10

  
11
    static Map<Language, ResourceBundle> BUNDLES;
12

  
13
    static {
14
        BUNDLES = new HashMap<>();
15

  
16
        config().addLanguage(Language.EN);
17
    }
18

  
19
    public interface Config {
20
        Config addLanguage(Language language);
21
    }
22

  
23
    public static Config config() {
24
        return new Config() {
25

  
26
            @Override
27
            public Config addLanguage(Language language) {
28
                if (!BUNDLES.containsKey(language)) {
29
                    BUNDLES.put(language, getBundle("Message", language.getLocale()));
30
                }
31
                return this;
32
            }
33
        };
34
    }
35

  
36
    public static String getString(Language language, String key) {
37
        if (!BUNDLES.containsKey(language)) return language.name()+" SOURCE MISSING";
38
        return BUNDLES.get(language).getString(key);
39
    }
40

  
41
    public static String getString(String key) {
42
        return getString(Language.EN, key);
43
    }
44
}
server/src/main/java/org/danekja/ymanager/ws/rest/ApiController.java
34 34
    // *********************** GET ****************************
35 35

  
36 36
    @GetMapping("/users/requests/vacation")
37
    public List<VacationRequest> usersRequestsVacation(
38
            @RequestParam(value = "lang", required = false) String lang,
39
            @RequestParam(value = "status", required = false) Status status)
40
    {
37
    public List<VacationRequest> usersRequestsVacation(@RequestParam(value = "status", required = false) Status status) {
41 38
        return manager.getVacationRequests(status);
42 39
    }
43 40

  
44 41
    @GetMapping("/users/requests/authorization")
45
    public List<AuthorizationRequest> userRequestsAuthorization(
46
            @RequestParam(value = "lang", required = false) String lang,
47
            @RequestParam(value = "status", required = false) Status status)
48
    {
42
    public List<AuthorizationRequest> userRequestsAuthorization(@RequestParam(value = "status", required = false) Status status) {
49 43
        return manager.getAuthorizationRequests(status);
50 44
    }
51 45

  
52 46
    @GetMapping("/user/{id}/calendar")
53
    public List<VacationDay> userCalendar(
54
            @PathVariable("id") Long id,
55
            @RequestParam(value = "lang", required = false) String lang,
56
            @RequestParam(value = "from") String from,
57
            @RequestParam(value = "to", required = false) String to,
58
            @RequestParam(value = "status", required = false) Status status)
59
    {
47
    public List<VacationDay> userCalendar(@PathVariable("id") Long id, @RequestParam(value = "from") String from, @RequestParam(value = "to", required = false) String to, @RequestParam(value = "status", required = false) Status status) {
60 48
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
61 49
        LocalDate fromDate = LocalDate.parse(from, formatter);
62 50
        LocalDate toDate = to != null ? LocalDate.parse(to, formatter) : null;
......
64 52
    }
65 53

  
66 54
    @GetMapping("/settings")
67
    public DefaultSettings settings(
68
            @RequestParam(value = "lang", required = false) String lang)
69
    {
55
    public DefaultSettings settings() {
70 56
        return new DefaultSettings(manager.getDefaultSettings());
71 57
    }
72 58

  
73 59
    // *********************** POST ****************************
74 60

  
75 61
    @PostMapping("/settings")
76
    public ResponseEntity<Void> settings(
77
            @RequestParam(value = "lang", required = false) String lang,
78
            @RequestBody DefaultSettings settings)
79
    {
62
    public ResponseEntity<Void> settings(@RequestBody DefaultSettings settings) {
80 63
        manager.createSettings(settings.toEntity());
81 64

  
82 65
        return ResponseEntity.ok().build();
83 66
    }
84 67

  
85 68
    @PostMapping("/user/calendar/create")
86
    public ResponseEntity<Void> userCalendarCreate(
87
            @RequestParam(value = "lang", required = false) String lang,
88
            @RequestBody VacationDay vacationDay,
89
            Authentication auth)
90
    {
69
    public ResponseEntity<Void> userCalendarCreate(@RequestBody VacationDay vacationDay, Authentication auth) {
91 70
        //TODO make api endpoint contain userId in path as part of #39, also drop the create part of path
92 71
        //TODO drop the auth parameter afterwards
93 72
        manager.createVacation(((User) auth.getPrincipal()).getId(), vacationDay);
......
99 78

  
100 79

  
101 80
    @PutMapping("/user/settings")
102
    public ResponseEntity<Void> userSettings(
103
            @RequestParam(value = "lang", required = false) String lang,
104
            @RequestBody UserSettings settings,
105
            Authentication auth)
106
    {
81
    public ResponseEntity<Void> userSettings(@RequestBody UserSettings settings, Authentication auth) {
107 82
        //TODO make api endpoint contain userId in path as part of #39
108 83
        //TODO drop the auth parameter afterwards
109 84
        manager.changeSettings(((User) auth.getPrincipal()).getId(), settings);
......
112 87
    }
113 88

  
114 89
    @PutMapping("/user/calendar/edit")
115
    public ResponseEntity<Void> userCalendarEdit(
116
            @RequestParam(value = "lang", required = false) String lang,
117
            @RequestBody VacationDay vacationDay)
118
    {
90
    public ResponseEntity<Void> userCalendarEdit(@RequestBody VacationDay vacationDay) {
119 91
        //TODO make api endpoint point to vacation endpoint as part of #39, also drop the edit part of path
120 92
        //TODO drop the auth parameter afterwards
121 93
        manager.changeVacation(vacationDay);
......
124 96
    }
125 97

  
126 98
    @PutMapping("/user/requests")
127
    public ResponseEntity<Void> userRequests(
128
            @RequestParam(value = "lang", required = false) String lang,
129
            @RequestParam(value = "type") RequestType type,
130
            @RequestBody BasicRequest request)
131
    {
99
    public ResponseEntity<Void> userRequests(@RequestParam("type") RequestType type, @RequestBody BasicRequest request) {
132 100
        manager.changeRequest(type, request);
133 101

  
134 102
        return ResponseEntity.ok().build();
......
137 105
    // *********************** DELETE ****************************
138 106

  
139 107
    @DeleteMapping("/calendar/{id}/delete")
140
    public ResponseEntity<Void> calendarDelete(
141
            @PathVariable("id") Long id,
142
            @RequestParam(value = "lang", required = false) String lang)
143
    {
108
    public ResponseEntity<Void> calendarDelete(@PathVariable("id") Long id) {
144 109
        manager.deleteVacation(id);
145 110

  
146 111
        return ResponseEntity.ok().build();
......
149 114
    // *********************** FILE ****************************
150 115

  
151 116
    @PostMapping("/import/xls")
152
    public ResponseEntity<Void> importXLSFile(@RequestParam(value = "lang", required = false) String lang, @RequestParam("file") MultipartFile file) throws Exception {
117
    public ResponseEntity<Void> importXLSFile(@RequestParam("file") MultipartFile file) throws Exception {
153 118
        fileService.parseXLSFile(file.getOriginalFilename(), file.getBytes());
154 119

  
155 120
        return ResponseEntity.ok().build();
156 121
    }
157 122

  
158 123
    @GetMapping("/export/pdf")
159
    public ResponseEntity<byte[]> exportPDFFile(@RequestParam(value = "lang", required = false) String lang) throws Exception {
124
    public ResponseEntity<byte[]> exportPDFFile() throws Exception {
160 125
        FileExportResult result = fileService.createPDFFile();
161 126

  
162 127
        return ResponseEntity.ok()
server/src/main/java/org/danekja/ymanager/ws/rest/UserController.java
27 27
    }
28 28

  
29 29
    @GetMapping
30
    public List<BasicProfileUser> users(
31
            @RequestParam(value = "lang", required = false) String lang,
32
            @RequestParam(value = "status", required = false) Status status) {
30
    public List<BasicProfileUser> users(@RequestParam(value = "status", required = false) Status status) {
33 31
        return userManager.getUsers(status);
34 32
    }
35 33

  
server/src/main/resources/Message_cs.properties
1
hello=Ahoj sv\u011Bte
2
rest.exception.generic=N\u011Bco se stalo :(
3
negative.sick.day.error = Po\u010Det sick days nesm\u00ED b\u00FDt z\u00E1porn\u00FD.
4
negative.vacation.error = Po\u010Det p\u0159es\u010Das\u016F nesm\u00ED b\u00FDt z\u00E1porn\u00FD.
5
available.vacation.error = Nen\u00ED mo\u017En\u00E9 vybrat p\u0159es\u010Das. Nem\u00E1te dostate\u010Dn\u00FD po\u010Det nad\u011Blan\u00FDch hodin.
6
available.sick.day.error = Nen\u00ED mo\u017En\u00E9 vybrat sick day, ji\u017E V\u00E1m \u017E\u00E1dn\u00E9 nezb\u00FDvaj\u00ED.
7
name.length.error = D\u00E9lka jm\u00E9na nesm\u00ED p\u0159ekro\u010Dit 45 znak\u016F.
8
email.length.error = D\u00E9lka emailu nesm\u00ED p\u0159ekro\u010Dit 100 znak\u016F.
9
time.sick.day.error = Sick day nesm\u00ED m\u00EDt nastaven \u010Das za\u010D\u00E1tku nebo konce.
10
time.vacation.error = Dovolen\u00E1 mus\u00ED obsahovat \u010Das za\u010D\u00E1tku a konce.
11
time.order.error = Dovolen\u00E1 nesm\u00ED za\u010D\u00EDnat pozd\u011Bji nebo ve stejn\u00FD \u010Das jako kon\u010D\u00ED.
12
taken.sick.day.count.error = Nen\u00ED dovoleno vybrat v\u00EDce sick days ne\u017E je p\u0159id\u011Bleno.
13
first.name.null.error = Jm\u00E9no mus\u00ED b\u00FDt zad\u00E1no.
14
last.name.null.error = P\u0159\u00EDjmen\u00ED mus\u00ED b\u00FDt zad\u00E1no.
15
token.null.error = Token mus\u00ED b\u00FDt zad\u00E1n.
16
email.null.error = Emailov\u00E1 adresa mus\u00ED b\u00FDt zad\u00E1na.
17
creation.null.error = Datum a \u010Das vytvo\u0159en\u00ED objektu  mus\u00ED b\u00FDt zad\u00E1n.
18
date.null.error = Datum mus\u00ED b\u00FDt zad\u00E1n.
19
status.null.error = Status mus\u00ED b\u00FDt zad\u00E1n.
20
type.null.error = Typ mus\u00ED b\u00FDt zad\u00E1n.
21
sick.day.null.error = Po\u010Det sick days mus\u00ED b\u00FDt zad\u00E1n.
22
notification.null.error = Datum upozorn\u011Bn\u00ED mus\u00ED b\u00FDt zad\u00E1n.
23
vacation.null.error = Po\u010Det hodin dovolen\u00E9 mus\u00ED b\u00FDt zad\u00E1n.
24
role.null.error = Role mus\u00ED b\u00FDt zad\u00E1n.
25
database.error = Vyskytl se probl\u00E9m s datab\u00E1z\u00ED.
26
vacation.past.error = Nelze vybrat volno v minulosti.
27
vacation.double.error = Nelze vybrat v\u00EDce voln pro stejn\u00FD den.
28
settings.sick.day.lt.taken.error = Nelze nastavit po\u010Det sick day men\u0161\u00ED ne\u017E je je aktu\u00E1ln\u011B vybr\u00E1no.
server/src/main/resources/Message_en.properties
1
hello=Hello world
2
rest.exception.generic=Something happened :(
3
negative.sick.day.error = The number of sick days mustn't be negative.
4
negative.vacation.error = The number of a remaining overtime mustn't be negative.
5
available.vacation.error = You cannot take a vacation, not enough remaining hours.
6
available.sick.day.error = You cannot take a sick day. You don't have any available sick days.
7
name.length.error = The length of a name mustn't exceed 45.
8
email.length.error = The length of an email address mustn't exceed 100.
9
time.sick.day.error = A sick day mustn't have a starting or an ending time.
10
time.vacation.error = A vacation has to have a starting and an ending time.
11
time.order.error = The overtime mustn't start after or at the same time it ends.
12
taken.sick.day.count.error = Not enough available sick days.
13
first.name.null.error = The first name has to be filled in.
14
last.name.null.error = The last name has to be filled in.
15
token.null.error = The token has to be filled in.
16
email.null.error = The email address has to be filled in.
17
creation.null.error = The creation date has to be filled in.
18
date.null.error = The date has to be filled in.
19
status.null.error = The status has to be filled in.
20
type.null.error = The type has to be filled in.
21
sick.day.null.error = The number of sick days has to be filled in.
22
notification.null.error = The date of a notification has to be filled in.
23
vacation.null.error = The number of overtime hours has to be filled in.
24
role.null.error = The role has to be filled in.
25
database.error = There was a problem with the database.
26
vacation.past.error = You cannot take a vacation in past.
27
vacation.double.error = You cannot take a vacation at the same day.
28
settings.sick.day.lt.taken.error = You cannot set a number of sick day lower than is taken at this moment.
server/src/test/java/org/danekja/ymanager/util/localization/MessageTest.java
1
package org.danekja.ymanager.util.localization;
2

  
3
import org.junit.jupiter.api.AfterEach;
4
import org.junit.jupiter.api.Test;
5

  
6
import static org.junit.jupiter.api.Assertions.assertEquals;
7

  
8
class MessageTest {
9

  
10
    @AfterEach
11
    void tearDown() {
12
        Message.BUNDLES.clear();
13
    }
14

  
15
    @Test
16
    void getString_inCzech_true() {
17
        Message.config().addLanguage(Language.CZ);
18

  
19
        assertEquals("český jazyk", Message.getString(Language.CZ, "hello"));
20
    }
21

  
22
    @Test
23
    void getString_inEnglish_true() {
24
        Message.config().addLanguage(Language.EN);
25

  
26
        assertEquals("english language", Message.getString(Language.EN, "hello"));
27
    }
28

  
29
    @Test
30
    void getString_general_true() {
31
        assertEquals("english language", Message.getString("hello"));
32
    }
33

  
34
    @Test
35
    void getString_multiple_true() {
36
        Message.config()
37
                .addLanguage(Language.CZ)
38
                .addLanguage(Language.EN);
39

  
40
        assertEquals("český jazyk", Message.getString(Language.CZ, "hello"));
41
        assertEquals("english language", Message.getString(Language.EN, "hello"));
42
        assertEquals("english language", Message.getString("hello"));
43
    }
44

  
45
    @Test
46
    void getString_missingSource_true() {
47
        assertEquals("CZ SOURCE MISSING", Message.getString(Language.CZ, "hello"));
48
    }
49
}

Také k dispozici: Unified diff