Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Custom component with library-translate not working

Ruhtra
Tera Contributor

Hello everyone,

 

I don't know if this post is in the right forum, but we are currently facing an issue while developing a custom component and using the "library-translate" package (in 19.1.0). 

We are using it following the documentation in Zurich ; https://developer.servicenow.com/dev.do#!/reference/next-experience/zurich/ui-framework/recipes/tran...

I created a sys_ui_message with a key "test.my.message" on my instance ; installed the package in my project, imported the function "t" and using it in my code like that : 

Capture d’écran 2025-10-03 à 10.48.03.png

In development mode, it displays my key (it doesn't translate).

Capture d’écran 2025-10-03 à 10.41.34.png

But after deploying my component, it totally breaks with an error in the console ; 

Capture d’écran 2025-10-03 à 10.44.22.png

Capture d’écran 2025-10-03 à 10.44.48.png

The error is coming from the "library-translate" package itself.

Maybe I am using it wrong, but I can't find resources or examples on how to use it.

 

Do you have some resources or examples to fix this ?

6 REPLIES 6

Hello @regis_sarle_ev1,

Thanks a lot for your detailed reply — your solution works perfectly on our side too!

That said, we’re not really fans of forking or directly modifying the library code, so we’ll try to find a more sustainable solution if possible.


Do you know a better alternative than forking the library to make it work properly?


Also, do you have any updates from the ServiceNow support case you mentioned earlier?

And thanks again for sharing your explanation about how the library-translate and requiredTranslationKeys work — that clarification was super helpful!

Hello @Ruhtra ,

 


@Ruhtra wrote:

And thanks again for sharing your explanation about how the library-translate and requiredTranslationKeys work — that clarification was super helpful!


Yes I can imagine, I spent many hours to understand how to make it work !

 

About the case, I closed it because it was not progressing. After three weeks and a component written specifically so the support can reproduce the issue on their own, I was still asked to explain why it was a Snow issue.

I guess I will check updates on that library over time.

 

Did you notice the following message when deploying your component ?

Direct access to `process` or `process.env` is NOT RECOMMENDED. Please contact Tectonic Support for remediation advice.

This message appears just because the translate library is included in the component. I also added this to the case but it was not taken into account by the support.

 

Let me kwow if you finally find a proper solution !