Search Unity

Question Changing track changes key creation

Discussion in 'Localization Tools' started by AlaaKhallouf, May 7, 2023.

  1. AlaaKhallouf

    AlaaKhallouf

    Joined:
    Dec 14, 2022
    Posts:
    10
    Using track changes and localising text directly in the scene view is a game changer, however, the way the system works is really not working out for me.
    track changes automatically creates an entry at the table, but it makes the path of the text in the hierarchy the key to the entry, which is really bad readability-wise.
    I want the default text that was written on that TMPro component to be used as the key for 2 reasons:
    1-Its way better for readability, especially for searching through the values.
    2-If 2 components use the same base text, I want them both to use the same entry, instead of creating a duplicate one; I don't want to go to every back button in my app and localise it manually each time I add a new locale to my project.

    is there a way to edit the way it works? am I missing something? because honestly this is a real deal breaker and I'm dumping the branch I moved the entire localisation system we have to use unities built in localisation
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    You can change the key after it's been created. If you want to change the default behaviour then you would need to embed the package and make changes to the code that creates the new key. I can walk you through it if you like.
     
  3. AlaaKhallouf

    AlaaKhallouf

    Joined:
    Dec 14, 2022
    Posts:
    10
    Thanks for the reply, I know I can change the key later, but that defeats the whole purpose of using "Track changes" if I'm going to manually manipulate the table.
    also I don't want to only change the key, I want different objects with the same text to use the same key rather than create a new entry and add a number at the end.

    I would love it if you would help me out with this one.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    You will first need to embed the Localization package, this will let you make changes to the code. By default the package will be in the Package cache folder, you can right click on the files in the project view and select open in explorer to see them. Copy this folder ("com.unity.localization...) into the projects Packages folder, so it looks like "MyProject/Packages/com.unity.localization".
    Let unity refresh itself.

    You can now make changes to the code.

    Go to the file com.unity.localization\Packages\com.unity.localization\Editor\Property Variants\TrackedObjectFactory.cs
    The method CreateTrackedProperty is what creates the new entry, inside the block
    if (serializedProperty.propertyType == SerializedPropertyType.String)
    .
    You can change the behavior so that instead of adding a new entry it will match an existing one.
     
  5. AlaaKhallouf

    AlaaKhallouf

    Joined:
    Dec 14, 2022
    Posts:
    10