B3nedikt / reword

Reword is a android library to update the texts of views when the apps texts have changed due to a language change or an update of the apps string resources.
Apache License 2.0
32 stars 7 forks source link

Support for content description and tooltip text in all view types #37

Closed Petrakeas closed 7 months ago

Petrakeas commented 7 months ago

Using the following view:

             <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:contentDescription="@string/image_description"
                    android:src="@android:drawable/btn_star"
                    android:tooltipText="@string/tooltip" />

I was expecting the tooltip text to be handled by reword.

I have this functionality in a similar library as reword . You can get ideas for implementation from here.

I also noticed two other areas that reword does not work. You may have figured this out yourself, but I haven't found a solution.

Reword does not handle menu items.

Also, when the androidx.appcompat.widget.Toolbar title is provided by navgraph via the "android:label" attribute.

B3nedikt commented 7 months ago

Hi :) Yes, Tooltips & content descriptions are currently not supported by Reword. However this should be easy to implement, I might do it if I find the time. If this is something you need right now, feel free to create a PR though. I think you can likely copy from your own library ;)

Reword does handle menu items, just have a look at its sample app, it uses multiple menus. If you think there is a bug, please fork this repository and change the sample app so that it reproduces the problem, then create an issue referencing your fork.

Regarding support of the navigation library used with XML I currently have no plans of supporting this. I think this might be a lot of effort. But if you already have an idea, feel free to create a PR. If not I would recommend to just set the title normally in code like it is done in the sample app.

Do you use Reword in an app actively, or are you just trying things out?

Petrakeas commented 7 months ago

Regarding menu items, it seems that using the "app:menu" toobar attribute is required for reword to handle them. I was using the override method and the strings did not pass through reword:

 @Override
        public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
            inflater.inflate(R.menu.main_menu, menu);
            super.onCreateOptionsMenu(menu,inflater);
    }

I don't use Reword. I am using ViewPump and recently I moved from the original version of the library to your version. I have my own ViewTransformers and ResourceWrapper for handling translations. It seems that Reword's transformers handle more cases and also support menus. So, I was thinking of moving to Reword and supply my own Resources wrapper. I won't be using ReString.

B3nedikt commented 7 months ago

Yes, intercepting the MenuInflater is not supported at the moment. If this is something you need feel free to create a PR for it, but I think the "app:menu" approach is far more common anyway.

I think you are right in that Reword would suit your approach of using your own Resources wrapper better then Restring. Restring is mainly intended for use cases where you only want to customize how the string resources which you want to replace are stored.