1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package io.wcm.maven.plugins.i18n.readers;
21
22 import java.io.File;
23 import java.io.FileInputStream;
24 import java.io.IOException;
25 import java.io.InputStreamReader;
26 import java.nio.charset.StandardCharsets;
27 import java.util.HashMap;
28 import java.util.Map;
29 import java.util.Properties;
30
31
32
33
34 public class PropertiesI18nReader implements I18nReader {
35
36 @Override
37 public Map<String, String> read(File sourceFile) throws IOException {
38
39 Properties props = new Properties();
40 try (FileInputStream is = new FileInputStream(sourceFile);
41 InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
42 props.load(reader);
43 }
44
45
46 Map<String, String> map = new HashMap<>();
47 for (Map.Entry<Object, Object> entry : props.entrySet()) {
48 map.put(entry.getKey().toString(), entry.getValue().toString());
49 }
50 return map;
51 }
52
53 }