wolpi / prim-ftpd

FTP server app for android
Other
637 stars 81 forks source link

Strings unused, yet still translatable #379

Closed trikaphundo closed 1 month ago

trikaphundo commented 1 month ago

The problem

There are a few strings available to translate, although they are no longer used in the UI.

Examples

See these, for instance.

Possible causes

I suspect that these strings fell in oblivion with successive changes of the program.

I have working on the translation of Primitive FTPd for some releases now, so I remember seeing some of the unused strings in the values.xml back when they were used; namely, when the user interface had a three-dot menu, instead of the current tabbed bar.

Possible solutions

Erase unused strings and update all translations with the changes.

hamidsafdari commented 1 month ago

The way to find unused strings would be to:

That will open a pane with all the unused strings. There's then a quick fix button to remove all the unused strings. This will also remove unused strings from the translated files. The inspection is not perfect and says some used strings are unused. So I went over all of the removed strings, added them back one by one and pressed Alt+F7 on each. Some of the strings were indeed used and I could find usages in either XML or Java files. For others, I couldn't find any usages so I removed them.

Running the inspection again, will only find 6 unused strings but they are false flags and have usages. I also kept a string I used in #363.

In case there is a need to restore any of the strings, here's how I would do it:

That will put all the removed strings in staging. I would then undo all the changes and only keep the string I need.

wolpi commented 1 month ago

I'll have a look

wolpi commented 1 month ago

I see #386 is already there. We are close to solve this :smile:

trikaphundo commented 1 month ago

The way to find unused strings would be to:

* Press Ctrl+Shift+A to open the "Find Action" menu

* Find "Run Inspection by Name..."

* Find "Unused resources"

* In the opened dialog, set a file mask of "strings.xml" and click OK

This is to be done in Android Studio, right? So I could do it as well. When opening the issue, I could not come up with an automated solution to find unused strings, so I decided to just point to an example. Thank you so much.

In case there is a need to restore any of the strings, here's how I would do it:

* `git revert [hash of this commit]`

* `git reset --soft HEAD~1`

That will put all the removed strings in staging. I would then undo all the changes and only keep the string I need.

Great.

hamidsafdari commented 1 month ago

This is to be done in Android Studio, right? So I could do it as well.

Yes. You can do it too. You can also access the menu from "Code > Analyze Code > Run Inspection by Name".