Kensuke Matsuzaki
2013-04-15 ed566a162c780faa0d6c84fac8fbbd3738586445
commit | author | age
b7f591 1 /*
JM 2  * Copyright 2011 gitblit.com.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.gitblit.client;
17
17820f 18 import java.util.MissingResourceException;
JM 19 import java.util.ResourceBundle;
b7f591 20
9adf62 21 import com.gitblit.utils.TimeUtils;
JM 22
17820f 23 /**
JM 24  * Loads the Gitblit language resource file.
25  * 
26  * @author James Moger
27  * 
28  */
b7f591 29 public class Translation {
JM 30
17820f 31     private final static ResourceBundle translation;
9adf62 32     
JM 33     private final static TimeUtils timeUtils;
b7f591 34
JM 35     static {
17820f 36         ResourceBundle bundle;
b7f591 37         try {
17820f 38             // development location
JM 39             bundle = ResourceBundle.getBundle("com/gitblit/wicket/GitBlitWebApp");
40         } catch (MissingResourceException e) {
41             // runtime location
42             bundle = ResourceBundle.getBundle("GitBlitWebApp");
b7f591 43         }
17820f 44         translation = bundle;
9adf62 45         
JM 46         timeUtils = new TimeUtils(translation);
b7f591 47     }
JM 48
49     public static String get(String key) {
50         if (translation.containsKey(key)) {
17820f 51             return translation.getString(key).trim();
b7f591 52         }
JM 53         return key;
54     }
9adf62 55     
JM 56     public static TimeUtils getTimeUtils() {
57         return timeUtils;
58     }
b7f591 59 }