Commits

Juha Kuitunen committed a4266a7

Display localized Strings instead of API compatible strings

  • Participants
  • Parent commits f46f52d

Comments (0)

Files changed (5)

res/values/strings.xml

     <!-- LauncherActivity.java -->
     <string name="changeset_not_found">Changeset not found!</string>
     <string name="link_not_supported">Unsupported link type!</string>
-
+    
+    <!-- These Strings are translated versions of various Strings used in API queries if we need to show them to user. -->
+    <string name="api_status_new">New</string>
+    <string name="api_status_open">Open</string>
+    <string name="api_status_resolved">Resolved</string>
+    <string name="api_status_on_hold">On Hold</string>
+    <string name="api_status_invalid">Invalid</string>
+    <string name="api_status_duplicate">Duplicate</string>
+    <string name="api_status_wontfix">Won\'t Fix</string>
+    <string name="api_priority_trivial">Trivial</string>
+    <string name="api_priority_minor">Minor</string>
+    <string name="api_priority_major">Major</string>
+    <string name="api_priority_critical">Critical</string>
+    <string name="api_priority_blocker">Blocker</string>
+    <string name="api_kind_bug">Bug</string>
+    <string name="api_kind_enhancement">Enhancement</string>
+    <string name="api_kind_proposal">Proposal</string>
+    <string name="api_kind_task">Task</string>
 </resources>

src/com/saibotd/bitbeaker/Bitbeaker.java

 	public void onCreate(){
 		super.onCreate();
 		Helper.setContext(getApplicationContext());
+		Helper.initTranslatedApiStrings();
 		settings = getSharedPreferences("bitbeaker", 0);
 		kv = new LinkedHashMap<String,String>();
 	}

src/com/saibotd/bitbeaker/Helper.java

 		Helper.context = context;
 	}
 	
+	public static TwoWayMap<String,String> translatedApiStrings;
+	
+	/**
+	 * Context MUST be set with setContext(Context) before you can call this!
+	 */
+	public static void initTranslatedApiStrings() {
+		translatedApiStrings = new TwoWayMap<String,String>("", "ERROR: value not found");
+		translatedApiStrings.put("new", context.getString(R.string.api_status_new));
+		translatedApiStrings.put("open", context.getString(R.string.api_status_open));
+		translatedApiStrings.put("resolved", context.getString(R.string.api_status_resolved));
+		translatedApiStrings.put("on hold", context.getString(R.string.api_status_on_hold));
+		translatedApiStrings.put("invalid", context.getString(R.string.api_status_invalid));
+		translatedApiStrings.put("duplicate", context.getString(R.string.api_status_duplicate));
+		translatedApiStrings.put("wontfix", context.getString(R.string.api_status_wontfix));
+		translatedApiStrings.put("trivial", context.getString(R.string.api_priority_trivial));
+		translatedApiStrings.put("minor", context.getString(R.string.api_priority_minor));
+		translatedApiStrings.put("major", context.getString(R.string.api_priority_major));
+		translatedApiStrings.put("critical", context.getString(R.string.api_priority_critical));
+		translatedApiStrings.put("blocker", context.getString(R.string.api_priority_blocker));
+		translatedApiStrings.put("bug", context.getString(R.string.api_kind_bug));
+		translatedApiStrings.put("enhancement", context.getString(R.string.api_kind_enhancement));
+		translatedApiStrings.put("proposal", context.getString(R.string.api_kind_proposal));
+		translatedApiStrings.put("task", context.getString(R.string.api_kind_task));
+	}
+	
 	/**
 	 * Check if file is an image based on it's extension.
 	 * 

src/com/saibotd/bitbeaker/IssueActivity.java

 	@Override
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
+
 		setContentView(R.layout.issue);
 		Bundle b = getIntent().getExtras();
 		slug = b.getString("slug");
 			title = jsonObject.getString("title");
 			issue_title.setText(title);
 
-			issue_status.setText(jsonObject.getString("status"));
-			issue_type.setText(jsonObject.getJSONObject("metadata").getString("kind"));
-			issue_priority.setText(jsonObject.getString("priority"));
+			issue_status.setText(Helper.translatedApiStrings.getByKey(jsonObject.getString("status")));
+			issue_type.setText(Helper.translatedApiStrings.getByKey(jsonObject.getJSONObject("metadata").getString("kind")));
+			issue_priority.setText(Helper.translatedApiStrings.getByKey(jsonObject.getString("priority")));
 
 			TextView issue_content = (TextView) listViewHeader.findViewById(R.id.issue_content);
 			TextView comments_count = (TextView) listViewHeader.findViewById(R.id.issue_comments_count);

src/com/saibotd/bitbeaker/IssuesActivity.java

     		ImageView icon = (ImageView) view.findViewById(R.id.issues_what);
     		try {
     			String type = this.getItem(position).getJSONObject("metadata").getString("kind");
-    			String status = this.getItem(position).getString("status");
+    			String status = Helper.translatedApiStrings.getByKey(this.getItem(position).getString("status"));
     			title.setText(this.getItem(position).getString("title"));
     			Resources res = getResources();
     			int num_comments = Integer.parseInt(this.getItem(position).getString("comment_count"));