Search Unity

Feature Request Find Unused Keys

Discussion in 'Localization Tools' started by Ferazel, Oct 6, 2020.

  1. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    Hello, having written a localization system or two in my day I am watching this package with much interest! The smart string system and metadata is really interesting. I personally haven’t used it in a production so forgive me if I missed this functionality in the docs.

    As anyone knows, as you develop a game, keys are added to the table that are no longer being used. Either they were temp/test or the label was deleted. I would love to have a tool in the localization system that helps remove or flag these table entries in some way. So that the keys can be evaluated and removed prior to being localized. Keeping these old strings around can add up in terms of translation costs and increasing disk/ram requirements.

    I appreciate that doing a usage search has always been a weak point of Unity. It requires doing an asset search through all assets (prefabs, scriptable object, and scenes). I realize it is a bit tricky, but it isn’t impossible. I feel it could really be a helpful and save development time/costs. In terms of scripting usage I feel that an IDE code search on top of this isn’t too onerous. It is really the Unity asset side that is not immediately searchable.

    Do other people think this would be useful? Are there any plans to add a “Find Unused Keys” to the localization system?
     
    Last edited: Oct 6, 2020
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    Hi,
    Interesting suggestion.
    I have added a task to our board to look into this further in the future. It certainly is possible, as you say we would need to scan through all the assets which would be a little slow but maybe we can find some ways to speed this up. Perhaps do a step during the build to check as scenes and assets are being serialized.
     
    StephanieRowlinson and Ferazel like this.
  3. StephanieRowlinson

    StephanieRowlinson

    Joined:
    Jul 23, 2014
    Posts:
    137
    Pardon the necroing, but as someone who works on a product in Unity that's been going for 8 years now this feature would be very welcome. Our current localisation system doesn't allow for this and that's really led to a lot of clutter.

    We're probably going to be switching systems, for other reasons and knowing the one we'd be moving too has support (planned) for this would be a huge plus.
     
    karl_jones likes this.
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    Its certainly on our roadmap. We still need to look into the details on how it will work. Most likely scanning through the assets and scenes.
     
    Upian and StephanieRowlinson like this.
  5. StephanieRowlinson

    StephanieRowlinson

    Joined:
    Jul 23, 2014
    Posts:
    137
  6. HG_Seon_geun

    HG_Seon_geun

    Joined:
    Jun 18, 2020
    Posts:
    1
    Hi, any updates regarding this feature?
    Thanks.
     
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    It's on our roadmap. Probably something later next year.
     
  8. hugeandy

    hugeandy

    Joined:
    Nov 2, 2016
    Posts:
    131
    @karl_jones any updates about this feature? If not, any guidance on how to scan through the assets so we can make a tool ourselves? Cheers!
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    No news at the moment. What are you using in your scenes, just LocalizedStringEvent or do you also have scripts with LocalizedStrings?
     
  10. hugeandy

    hugeandy

    Joined:
    Nov 2, 2016
    Posts:
    131
    I believe we only use LocalizedStrings in scripts.
     
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    Ok here is a rough idea on how this could be done
    https://gist.github.com/karljj1/f34a483b035415418f8b7b3021d62640

    The general idea is to iterate through each scene and examine each GameObjects components. We use a SerializedObject to iterate through the values of each component looking for LocalizedStrings. When we find one we record it in a HashSet. Once we have scanned the project we then compare it against the tables to see what's missing.
    This does not currently handle prefabs but would be simple to expand on, just search prefabs and use the same code.

    In this example, we just print out the results however you could instead remove the missing entries from the table. If so I would first record the missing entries in a list and then use that list to remove the entries.
    Ill move this to one of our next sprints since its already started ;)
     
    Last edited: May 20, 2022
  12. hugeandy

    hugeandy

    Joined:
    Nov 2, 2016
    Posts:
    131
    Perfect, thanks!
     
    karl_jones likes this.
  13. Zulug

    Zulug

    Joined:
    Sep 15, 2012
    Posts:
    5
    Hello @karl_jones!
    Thank you for the suggestion. It is good, but the search is very flat, i.e. it ignores prefabs referenced from the scenes.

    Would be good to have a tool to search across the whole project for usages of LocalizedStrings, including LocalizeStringEvents referenced from all the assets included into a build (scenes in build settings, Streaming assets and Resources, assets marked as Addressables). Would be great to have this tool out of the box. It is okay if the processing takes a while, as this will only be used occasionally. Without this tool localization tables grow in size without any control.
     
    rbitard and karl_jones like this.
  14. Off0

    Off0

    Joined:
    Feb 5, 2018
    Posts:
    8
    Hello @karl_jones , any news about these feature?

    It's possible to see somewhere next steps on the roadmap of the Localization package or it's yours internally?

    Will the localization system also get a ui/ux?

    (Would be also possible use localization data without their move automating to the addressables?)

    Thanks :)
     
  15. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    Hi,

    No news at the moment I'm afraid. As for roadmap it's something we have but it's not in any official state. We do plan to put something together later in the year, hopefully in time for Unite.

    We have gone through a UI/Ux review and have some plans for improvements, initially planned for 1.5.x.

    We don't have plans to remove the addressables dependency, it's key to a lot of our internals so removing it would require us writing our own addressable system which we would like to avoid :(
    We do have support for loading from other sources with the the ITableProvider and ITablePostProcessor. We will likely go further down this line to make it easier to supplement the data.

    We are also more integrated with the UI Toolkit team now so expect to see better integration and tooling in the future.