Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Including Localisation Tables in Build

Discussion in 'Localization Tools' started by darthmorf, Jun 29, 2021.

  1. darthmorf

    darthmorf

    Joined:
    Jun 21, 2017
    Posts:
    11
    Hi,
    I've been working with the localisation system in the editor for a little while now and it's all working well!
    However, I'm trying to include them in the build, to no avail. I think I'm not properly including the asset somehow, but I'm afraid I'm not really familiar with how this is meant to be done - is there a guide anywhere?

    I've had a look at https://docs.unity3d.com/Packages/com.unity.localization@1.0/manual/Addressables.html and https://docs.unity3d.com/Packages/c...tGuide.html#9-build-preview-and-configuration but I've not quite managed to get it to work.

    This is the error that I get in the build (that I don't get in the editor):
    upload_2021-6-29_16-48-7.png
     
  2. alexmartinio

    alexmartinio

    Joined:
    Apr 19, 2020
    Posts:
    21
    This might be a bit of a stetch, but I notice from your screenshot that you are running from the G: drive. I think there may have been a bug with the Addressables package relating to building projects not on the C:\ drive.

    Not sure if it's been resolved but it might be worth moving the project to the C:\ drive and try again repeating those steps.
     
    Last edited: Jun 29, 2021
  3. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,876
    That error is coming from a missing name for the table. When you call `GetLocalizedString` you dont seem to be providing a name. See the ArgumentException Error message ;)

    In the Script from the other post, did you assign a TableName to
    Code (csharp):
    1. [SerializeField] LocalizedStringTable localizationTable;
    Go to the MonoBehaviour Inspector and check it has a Table assigned.
     
  4. darthmorf

    darthmorf

    Joined:
    Jun 21, 2017
    Posts:
    11
    Surely if that were the case this would be an issue in the editor too? Because it's only happening when inside of a build, I assumed it was a packaging issue.
     
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,876
    Yeah I would expect it to also happen in the editor. Can you share the full player log file?
     
  6. darthmorf

    darthmorf

    Joined:
    Jun 21, 2017
    Posts:
    11
    Here it is. Had to change it to a txt for the forum to accept it.
     

    Attached Files:

  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,876
    I couldn't see anything in the log file. Are you able to share the project so I can debug it?
     
  8. darthmorf

    darthmorf

    Joined:
    Jun 21, 2017
    Posts:
    11
    I'm not able to at the moment I'm afraid - I guess I could try and reproduce it in a blank project but I don't know if I'll be able to.
     
    karl_jones likes this.
  9. darthmorf

    darthmorf

    Joined:
    Jun 21, 2017
    Posts:
    11
    OK, I have attached a stripped down version of the project. It's a black screen with a few words that get localised at runtime. It looks like this (correct) when ran from the editor:

    upload_2021-6-30_18-53-57.png

    However when I create a windows build, the words are not localised and the error occurs:
    upload_2021-6-30_18-55-10.png

    Hopefully this helps! In theory if you manage to get this working, I should be able to apply those steps to our actual project and fix it also :)

    Here's the project: https://drive.google.com/file/d/1h1Q30XHhIU1JbOQbP7od4imsBgbHBrML/view?usp=sharing
     
    flippi273 and karl_jones like this.
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,876
    Hi I found the issue.
    In your script
    Code (csharp):
    1. public static string ApplyLocalization(string pLocalizationTableName, string pStringToLocalize)
    Your pLocalizationTableName argument requires a string so when you pass in a TableReference it will implicitly convert it to a string which will cause it to use the TableName value. A TableReference can either be a Table Name Guid or Table Name, you can find out the type by querying ReferenceType. When set via the inspector we use the Guid as its safer, it means you can rename the table without losing the reference. So when calling TableName it will be null HOWEVER we added some debugging features in the editor such as the ability to convert the Guid into a Name so its easier to understand when debugging, so in the Editor you can actually get the TableName even when its a Guid. Which I can see is a little confusing ;)

    So to fix your issue all you need to do it change the signature to
    Code (csharp):
    1. public static string ApplyLocalization(TableReference pLocalizationTableName, string pStringToLocalize)
    I also encountered another issue when running after this fix which I was able to solve by updating to the latest version of Addressables, so I would also do that. You can Add the Addressables package in the package manager.
     
    flippi273 and darthmorf like this.
  11. darthmorf

    darthmorf

    Joined:
    Jun 21, 2017
    Posts:
    11
    Amazing, that totally did it - thank you so much! I don't think I'd have ever found that.
     
    flippi273 and karl_jones like this.