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

Reword does not reword dialog to it is refreshed... #31

Closed adanecito closed 1 year ago

adanecito commented 1 year ago

Hi, I am not sure if Reword.reword() is expected to refresh a dialog fragment under a certain use case. I am seeing if I call Reword.reword from a dialog fragment via a callback to my MainActivity where I execute Reword.reword() the open dialog's fragment language is not reworded. But, if I close the dialog then open it the language is reworded on the fragment. Also, if the dialog has multiple tabs (fragments) and I switch to one of those tabs after Reword.reword() is executed on the MainActivity the language on that tab is reworded and if I switch back to the original tab on that same dialog it is reworded. I hope that makes sense. My hope is to solve the issue where the visible dialog tab that made the callback to the activity also is reworded without closing it. Thanks!

B3nedikt commented 1 year ago

I think what you want to do is reword both the root view of the hosting activity, as well as the root view of your DialogFragment. So something like this:

final View rootView = getWindow().getDecorView().findViewById(android.R.id.content);

// Your activities root view
Reword.reword(rootView);

// Your DialogFrament's root view
Reword.reword(this.getView())
adanecito commented 1 year ago

Hi Again, I tried what you recommended but it did not solve the issue. I did notice when I am done translating I update a button to indicate it was done and the language changed on the button to the language that was selected. I hope that helps.

B3nedikt commented 1 year ago

Are you using AlertDialog ?

adanecito commented 1 year ago

No. I am using DialogFragment. It in turn contains several Fragment classes that are displayed when when you select a tab. One fragment is called General. That fragment is where I have a dropdown for a language to select and a button to apply the selected language.

adanecito commented 1 year ago

Ok I retried your recommendation and it works. I made a mistake where I used your solution for the activity for the DialogFragment instead of just your getView() suggestion. Thanks for your help again for solving this issue! And please close the issue.

B3nedikt commented 1 year ago

You're welcome :)

adanecito commented 1 year ago

Thanks! I ran into another issue after that. Not a critical one but interesting. Seems to be everywhere where there is a dropdown or "spinner". The language is not updated there when it is changed. Maybe that was by design? Thanks,-Tony On Wednesday, October 26, 2022 at 03:19:27 AM PDT, Benedikt Löbbecke @.***> wrote:

You're welcome :)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

B3nedikt commented 1 year ago

Yeah, Reword can't update these, as they are normally filled dynamically by a Adapter. Only what you set in XML is updated by reword.

adanecito commented 1 year ago

Thanks  that is fine.

Sent from Yahoo Mail on Android

On Sat, Oct 29, 2022 at 12:40 PM, Benedikt @.***> wrote:

Yeah, Reword can't update these, as they are normally filled dynamically by a 'Adapter'. Only what you set in XML is updated by reword.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>