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 work with DialogFragment? #30

Closed adanecito closed 1 year ago

adanecito commented 1 year ago

I can not seem to find any examples of Reword.reword() working for DialogFragment or even a fragment? These might be corner cases where something is done differently from a Activity?

B3nedikt commented 1 year ago

It works the exact same way as with activities, pass in the root view of your view hierarchy. Depending on your architecture this root view may be part of the activity which hosts the fragment. Viewpump & Reword need to be setup for the hosting activity of course.

adanecito commented 1 year ago

I believe any DialogFragment the root view is the dialog itself. I could be wrong though. Anyway, I have a working sample with Viewpump and Reword and I was planning tonight to verify that by adding a simple dialog. I was also planning to look close at the Restring to see for the strings.xml to see what the key is that is being used for the hashmap. I was wondering if that is the old value or the "name" value. Again many thanks!

adanecito commented 1 year ago

Ok. I added a dialogfragment object with two buttons with labels. The in the strings.xml I added names and values for the two buttons. Then I added the english and spanish keys and values in the two languages and when I ran a test everything worked without having to add any statements to the dialog. The view hierarchy was captured as you mention. So close this out. I did discover when changing to AppCompatActivity the previous evening it forced me to change the theme and ActionBar code a bit. Then I discovered the BaseActivity was not getting the request from the MainActivity. So, I put the getDelegate code in the MainActivity and the reguest for the getDelegate worked there just fine. Now, with what works with the example from tonight and what I have learned hopefully I can get my apps to work. Many Thanks again!!

B3nedikt commented 1 year ago

You`re welcome, I wish you success with your apps :)