Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Automatically importing XLIFF files for the Localization package

Discussion in 'Localization Tools' started by castanciu, Feb 4, 2022.

  1. castanciu

    castanciu

    Joined:
    May 20, 2021
    Posts:
    18
    Hi,
    I am working on a project and trying to use the Localization package in our workflow.
    Here is situation:
    - developper exports a XLIFF file from the Localization package and gives it to the internal localization team
    - the localization team fills up the file with the missing data (different languages) but not using the Unity interface
    - the localization team saves the XLIFF file in same repo location where they picked it up
    - when the developer pulls the repo and starts Unity, the XLIFF modifications are not visible and he needs to manually import the XLIFF from the Unity menu

    Question:
    Is there a setting that exists or any scripting way to have unity automatically import all the XLIFF files that exist in the project without actually having someone doing it manually?
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,147
  3. castanciu

    castanciu

    Joined:
    May 20, 2021
    Posts:
    18
    Thanks Karl.
    Yes I am aware of those APIs. My question is more related to when I load the project in Unity, is it possible to have the XLIFF automatically imported without me running a particular script in order to import the XLIFF file?
     
  4. castanciu

    castanciu

    Joined:
    May 20, 2021
    Posts:
    18
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,147
  6. castanciu

    castanciu

    Joined:
    May 20, 2021
    Posts:
    18
    Thanks Karl,
    That was very helpful
     
  7. castanciu

    castanciu

    Joined:
    May 20, 2021
    Posts:
    18
    is the xliff api only for editor mode? could I have a MonoBehaviour load an xliff file at runtime in the awake/start functionality?
     
  8. castanciu

    castanciu

    Joined:
    May 20, 2021
    Posts:
    18
    I have found the Xliff.ImportFile from UnityEngine. Would this be the equivalent to the Editor one?
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,147
    Xliff support is editor only, it won't work in the player. Why do you need it at runtime?
     
  10. castanciu

    castanciu

    Joined:
    May 20, 2021
    Posts:
    18
    I am trying to find a process to make the Xliff import automatic and reduce the impact on manually import it and then save all the modified assets in the git repo.
    Any suggestions would be greatly appreciated.
     
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,147
    You can use the Xliff Api to import through script.
    https://docs.unity3d.com/Packages/com.unity.localization@1.1/manual/XLIFF.html#xliff-api

    If you want it to be automatic then you could try making a scripted importer for xliff files which will trigger the import and then save the assets.

    https://docs.unity3d.com/ScriptReference/AssetImporters.ScriptedImporter.html
     
  12. castanciu

    castanciu

    Joined:
    May 20, 2021
    Posts:
    18
    Thanks a lot. that is actually what I did but wasnt sure if there are any other ways.
    I used scripter importer to trigger the import of xliff files when modified and while the user is working on the project.
    I also used the xliff api to trigger from command line updates when the xliff are modified outside Unity. this way when someone updates xliff file they will need to call the a script from cmd and update the assets. Then they can commit the modified files to the repo for others to use
     
    karl_jones likes this.
  13. BenIVRE

    BenIVRE

    Joined:
    Jun 25, 2020
    Posts:
    4
    Are you saying it's not possible to update/import Xliff at runtime at all? I'm currently investigating switching to Unity Localization package, but in our production environment, we rely on pulling in the latest translations at app start up. This allows translations to be updated without requiring a new build.
     
  14. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,147
    We don't support doing this outside of the editor at the moment. For updating during app start we recommend using the content update approach. We do also have API that lets you update or provide tables at runtime if you want to provide your own custom provider, such as reading xliff however our xliff parser is editor only so you would need to provide your own.

    https://docs.unity3d.com/Packages/c....4/manual/Scripting.html#custom-table-loading
    https://docs.unity3d.com/Packages/c...ng-changes-to-a-table-after-the-game-is-built