In the string.xml files, the only content structure change should be the string-arrayfood_info_serving_sizes_* elements. Other string.xml changes should only be formatting into a common order to support comparison via a common text compare tools.
Proposed food_info_serving_sizes_* content structure is shown below. Fewer elements. Easer to read. One-to-one correspondence to what the translator sees in a spreadsheet row.
<string-array name="food_info_serving_sizes_other_fruits_imperial">
<item>1 medium-sized fruit</item>
<item>1 cup cut-up fruit</item>
<item>¼ cup dried fruit</item>
</string-array>
<string-array name="food_info_serving_sizes_other_fruits_metric">
<item>1 medium-sized fruit</item>
<item>120 g cut-up fruit</item>
<item>40 g dried fruit</item>
</string-array>
The affected *.java would appear to be:
private static int getServingSizesResourceId(final Context context,
final String idSuffix) {
return context.getResources().getIdentifier(
"food_info_serving_sizes_" + idSuffix.toLowerCase(),
"array",
context.getApplicationInfo().packageName);
}
private static int getServingSizesResourceId(final Context context,
final String foodName,
@Units.Interface final int unitType) {
return getServingSizesResourceId(context,
foodName + (unitType == Units.IMPERIAL ? "_imperial" : "_metric"));
}
private static void initServingSizesForFood(final Context context, final String foodIdName) {
// ... SNIP ...
// Dynamically load the string-arrays for food.
// The naming convention below must be followed:
// food_info_serving_sizes_<formattedFoodIdName>
// food_info_serving_sizes_<formattedFoodIdName>_imperial
// food_info_serving_sizes_<formattedFoodIdName>_metric
String[] servingSizeTexts = res.getStringArray(getServingSizesResourceId(context, formattedFoodIdName));
String[] imperialServingSizes = res.getStringArray(getServingSizesResourceId(context, formattedFoodIdName, Units.IMPERIAL));
String[] metricServingSizes = res.getStringArray(getServingSizesResourceId(context, formattedFoodIdName, Units.METRIC));
final List<String> imperial = new ArrayList<>();
final List<String> metric = new ArrayList<>();
for (int i = 0; i < servingSizeTexts.length; i++) {
imperial.add(String.format(locale, servingSizeTexts[i], imperialServingSizes[i]));
metric.add(String.format(locale, servingSizeTexts[i], metricServingSizes[i]));
}
servingSizesImperial.put(foodIdName, imperial);
servingSizesMetric.put(foodIdName, metric);
// ... SNIP ...
}
See Issue https://github.com/nutritionfactsorg/daily-dozen-android/issues/201 for discussion. The normalized update XML file are linked. The needed java modified is mentioned here but not implemented.
In the
string.xml
files, the only content structure change should be thestring-array
food_info_serving_sizes_*
elements. Otherstring.xml
changes should only be formatting into a common order to support comparison via a common text compare tools.Existing release
food_info_serving_sizes_*
content structure:Proposed
food_info_serving_sizes_*
content structure is shown below. Fewer elements. Easer to read. One-to-one correspondence to what the translator sees in a spreadsheet row.The affected
*.java
would appear to be: