yubioath-android icon indicating copy to clipboard operation
yubioath-android copied to clipboard

Hard coded strings

Open ikajdan opened this issue 4 years ago • 3 comments

I am currently translating this app into Polish, however I have noticed that some strings are hard coded. For example "Star credential" or "Change icon" in app/src/main/res/menu/code_select_actions.xml. Also when I try to translate strings from app/src/main/res/values/arrays.xml file and recompile the app, translated settings don't work anymore. Would it be possible to move all these strings into app/src/main/res/values/strings.xml?

ikajdan avatar Sep 07 '20 17:09 ikajdan

How are you translating the strings from arrays.xml? It should be feasible by creating multiple arrays files with the translated texts in different values folders (eg. values-en, values-es etc). For what regards "Star credential" or "Change icon" they seem to be menu items instead, so they should be extracted to strings!

marinomeneghel avatar Nov 05 '20 19:11 marinomeneghel

IIRC that's what I have done. I have translated both arrays.xml and strings.xml and placed them in values-pl directory.

Here is a snippet from the translated arrays.xml file:

    [...]
    <string-array name="themeSelection">
        <item>Jasny</item>
        <item>Ciemny</item>
        <item>AMOLED</item>
    </string-array>
    [...]

So I assume, I shouldn't translate these strings between <item> tags?

For what regards "Star credential" or "Change icon" they seem to be menu items instead, so they should be extracted to strings!

How can I "extract them to strings"?

ikajdan avatar Nov 05 '20 20:11 ikajdan

So regarding arrays.xml that approach you took should be correct. You can copy just the arrays that need translation. For example, in the new arrays.xml file you created and moved to values-pl you can completely omit the ones that do no need translation (such as themeSelection or icon_colors) as they'll be taken from the default arrays file. Basically the only one that should be in there is icon_choices as its items do need translation.

Regarding how to extract to strings the strings in the menu (eg. "Star Credential") you can do in it multiple ways, such as:

  • Go to each strings.xml file and add a new entry (eg. <string name="star_credentials">Star Credentials</string>) with translated text. More info on this here
  • A quicker alternative to get the same result might be to use the AS translations editor

Once the strings are extracted, you can use them in the code_select_actions.xml menu as follows:

    <item
        android:id="@+id/pin"
        android:icon="@drawable/ic_star_filled_24dp"
        android:orderInCategory="100"
        **android:title="@string/star_credentials"**
        app:showAsAction="ifRoom" />

marinomeneghel avatar Nov 08 '20 19:11 marinomeneghel

Sorry for the late response. The development of the app moved to https://github.com/Yubico/yubioath-flutter. Please open a new issue there if it is still relevant.

AdamVe avatar Nov 16 '22 09:11 AdamVe