Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion: imperial/metric static strings #201

Closed
marc-medley opened this issue Mar 23, 2022 · 2 comments
Closed

Discussion: imperial/metric static strings #201

marc-medley opened this issue Mar 23, 2022 · 2 comments

Comments

@marc-medley
Copy link
Member

@slavick Below are some observations on how the imperial/metric static strings are handled.

Currently Android and iOS handle the imperial/metric static strings for the detailed description differently.

Android separates the number value from rest of the string in XML and then recombines the number to the string in the code at run time.

The translation TSV spreadsheets have a full imperial string and separate a full metric string. Thus, for the translator, the string reads as is displayed and does not need to deal with any %s separations and formatting as exits in the XML file.

For iOS, the imperial and metric translation strings from the spreadsheets are displayed without any additional processing.

If dynamic valued internationalized strings were needed, then iOS would use an object which supports value + units + description; and the spreadsheets would need to add value and units columns. However, since the values are static the spreadsheet string is used directly for iOS.

The XmlFromTsvProcessor.swift code has a method measureDescriptionSplit(…) which splits the 2 translator strings (imperial and metric) into the 3 strings (description, imperialMeasure, and metricMeasure) as used by Android XML. The Hebrew translator being (right-to-left) highlighted that this particular method is left-to-right centric. For example, the multi character values such as 1/2 appeared to have issues which were subsequently avoided by using the single character ½.

I'm wondering if the overall process could be more robust and simplified if the Android app also used the static imperial and metric strings directly.

It would be a minor adaption to disable the measureDescriptionSplit(…) and generate the Android localized strings.xml files with the two separate imperial|metric strings instead of the 3 description|imperialMeasure|metricMeasure strings.

Your thoughts?

@marc-medley
Copy link
Member Author

@slavick Updated XML files (1st pass) are provided with PR #204 for review.

In the string.xml files, the only content structure change should be the string-array food_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.

Existing release food_info_serving_sizes_* content structure:

<string-array name="food_info_serving_sizes_other_fruits">
    <item>%s1 medium-sized fruit</item>
    <item>1%s cut-up fruit</item>
    <item>%s dried fruit</item>
</string-array>
<string-array name="food_info_serving_sizes_other_fruits_imperial">
    <item />
    <item> cup</item>
    <item>¼ cup</item>
</string-array>
<string-array name="food_info_serving_sizes_other_fruits_metric">
    <item />
    <item>20 g</item>
    <item>40 g</item>
</string-array>

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>

@slavick
Copy link
Member

slavick commented May 9, 2022

I like the suggestion and have pushed the code for implementing the change: 830eff3

@slavick slavick closed this as completed May 9, 2022
slavick added a commit that referenced this issue Aug 14, 2022
* unified imperial, metric strings (removes need for %s) (#204)

see #201

* Implement change to read full serving size strings instead of building them

* russian update, escaped quotes, %s simplification  (#205)

* russian update

* xml fixes: `\\'` to `\'`, `\ N` to `\n\n`

* escaped double quotes `\"`

* fixed "about_text_lines" mapping. also some misc update (fractions)

* some Italian updates. French: l\\'application --> l\'application

* Update versionCode and versionName

* Remove redundant label

* Add try/catch for exception that has been observed

* Remove unpopular translations

* Update strings

* Change createWeightsIfDoesNotExist to return boolean (indicating weights saved) instead of the unused Weights object

* Remove unused code

* Revert "Remove unpopular translations"

This reverts commit a6b9c9c.

* Update strings

* Update versionCode

* Update Spanish translation

* Update versionCode and versionName

* Update Spanish (#206)

Co-authored-by: --marc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants