Skip to main content
Topic: Txt string cleanup (Read 2715 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Txt string cleanup

These are not bugs per sey but here we go.

I wrote a script to search for:
1)  $txt[''] strings defined but not used
2) used $txt[''] strings but not defined
3) duplicate key to one in index.english

I won't post the script since its a train wreck :P but here is the output.  I suspect the majority of these are false hits due to the way strings are defined in the code or used (meaning concatenation creation and passed as key names to functions) but they are worth looking at.  Some of what it tagged are listed as depreciated as well, we could remove those I would think. 

So now I need some help in doing the next step, check this list for things we should update !

//
// Keys used but not found in $txt
//
File: Load.php Uses key: image_lang but this was not found in any language strings.
File: Themes.subs.php Uses key: variant_pick but this was not found in any language strings.

//
// Key found in $txt but not found in sources
//
File: Errors.english has unused key: mods_only
File: Errors.english has unused key: already_a_user
File: Errors.english has unused key: cant_move
File: Errors.english has unused key: password_invalid_character
File: Errors.english has unused key: name_invalid_character
File: Errors.english has unused key: email_invalid_character
File: Errors.english has unused key: members_only
File: Errors.english has unused key: no_board
File: Errors.english has unused key: no_message
File: Errors.english has unused key: no_topic_id
File: Errors.english has unused key: split_first_post
File: Errors.english has unused key: topic_one_post
File: Errors.english has unused key: no_posts_selected
File: Errors.english has unused key: selected_all_posts
File: Errors.english has unused key: already_a_mod
File: Errors.english has unused key: poll_range_error
File: Errors.english has unused key: parent_error
File: Errors.english has unused key: missing_event_id
File: Errors.english has unused key: cant_edit_event
File: Errors.english has unused key: email_missing_data
File: Errors.english has unused key: unable_to_create_temporary
File: Errors.english has unused key: parent_topic_missing



File: ManageThemes.english has unused key: current_theme_style
File: ManageThemes.english has unused key: disable_recent_posts
File: ManageThemes.english has unused key: enable_single_post
File: ManageThemes.english has unused key: enable_multiple_posts
File: ManageThemes.english has unused key: member_list_bar


File: Mentions.english has unused key: mention_not_accessible


File: Packages.english has unused key: php_script
File: Packages.english has unused key: package_run
File: Packages.english has unused key: package_read
File: Packages.english has unused key: script_output
File: Packages.english has unused key: additional_notes
File: Packages.english has unused key: notes_file
File: Packages.english has unused key: package_get
File: Packages.english has unused key: sql_file
File: Packages.english has unused key: sql_queries
File: Packages.english has unused key: browse_installed
File: Packages.english has unused key: php_safe_mode
File: Packages.english has unused key: lets_try_anyway
File: Packages.english has unused key: create_package
File: Packages.english has unused key: download_new_package
File: Packages.english has unused key: archiving
File: Packages.english has unused key: execute_credits_remove




File: Profile.english has unused key: delete_user
File: Profile.english has unused key: current_status
File: Profile.english has unused key: picture_text
File: Profile.english has unused key: reset_form
File: Profile.english has unused key: age
File: Profile.english has unused key: latest_posts
File: Profile.english has unused key: additional_info
File: Profile.english has unused key: gravatar
File: Profile.english has unused key: secret_ask
File: Profile.english has unused key: cant_retrieve
File: Profile.english has unused key: incorrect_answer
File: Profile.english has unused key: theme_preferences
File: Profile.english has unused key: notifications_topics_list
File: Profile.english has unused key: notifications_boards_list
File: Profile.english has unused key: statPanel_timeOfDay
File: Profile.english has unused key: viewwarning
File: Profile.english has unused key: subscriptions
File: Profile.english has unused key: receive_from
Last Edit: July 02, 2014, 06:05:38 pm by Spuds

Re: Txt string cleanup

Reply #1

Can you add the line numbers? Maybe even link it to Github :)

Re: Txt string cleanup

Reply #2

Doh! ... Great idea, one I  wish I had when I did the script !  ... I'll get that updated with maybe links to the source lines to help.

Re: Txt string cleanup

Reply #3

If you are wanting the strings in the language files for 'Key found in $txt but not found in sources' deleted, then I can take those.

 

Re: Txt string cleanup

Reply #4

Having made a script to do this in the past, most of those "missing" strings are just ones that are _any, _all or something along those lines. In other words, dynamically created keys.

Re: Txt string cleanup

Reply #5

Quote from: Aggelos – If you are wanting the strings in the language files for 'Key found in $txt but not found in sources' deleted, then I can take those.
Quote from: groundup – Having made a script to do this in the past, most of those "missing" strings are just ones that are _any, _all or something along those lines. In other words, dynamically created keys.
Thank you and like groundup says thats the trick.  Sadly each has to be looked at to see if in fact its really not used ... The script did not deal with complex concatenations so if the string was defined like
Code: [Select]
 '$' . $bla_value['type'] . '[\'' . $other ? $bla_key : $bla_key1 . '\']
Ok thats made up but you get the idea.

So some will be very obvious that its a false hit, others may take some work, others will be real.  I actually had a large area of exceptions in the script, so thats why the list is even that short.  I'll try to get this in github tomorrow with some line numbers so they can be discussed and checked easier.


Re: Txt string cleanup

Reply #6

I opened a group of issues, one for each file, for the ones that are "Key found in $txt but not found in sources"  So those mean the program found a $txt['some_string'] but could not find that used in the sources.   As discussed above some of those are going to be false hits, especially ones that start like

bla_edit
bla_show
bla_save

Those are generally concatenated in the sources, so when you see those in the issue report you can almost just skip them.  Other are simply not used, or were used a long time ago, others should have been used but were not.

I fixed up the paid subscriptions one, most of those were not used and one should have been used, one of our tables was missing a column header.  Anyway if you want to help out, post a comment in the issue when you are working on that file so everyone else knows.   What I did then is search for the key name, or part of the key name (trailing, leading, etc) in an attempt to find it usage.  When convinced it was not use delete!

For the Keys used but not found in $txt and Duplicates (by key name) I made a PR to fix those, it was quicker than running the script again to get the line numbers and links. 

There was only key not found but used that needed to be fixed.  For the duplicates I just focused on ones listed in index and another file, as index is generally always loaded, if the strings were identical in the text, then I left what was in index and removed it from the "other" file.

Re: Txt string cleanup

Reply #7

Post the script :P

Re: Txt string cleanup

Reply #8

Updated the first post as some good progress was made on the files, so far the generated list was actually pretty accurate.

Once I find it again :P .... It was one of those exercises that you sometimes do late at night.  The list I posted was actually from a few months ago from when I was playing with finding unused txt and I came across it in my elk directory.   Of course as you can imagine it was slow and a memory hog,  I remember running it and adding in exceptions to skip a lot of the standard concatenations and it being a disaster.  Anyway I'll root around and see if I can come up with it, I'm sure its one of my many test_xxx.php files lol