Search code examples
angularlocalizationinternationalizationngx-translate

angular - How can I translate a text inputted by user (not specified during the development process)


I am working on a website allows the user to input objects contain texts, and those texts must be translated when the website's language changed. I have read about i18n and ngx-translate but both of them work with hard coded texts.


Solution

  • I believe you are interchangeably using the terms 'translation' and 'localization'.

    They are not exactly the same thing. Like you pointed out, ngx-translate, angular's built in localization engine, transloco, etc are the tools used to localize your app based on browser language.

    What you need is a translation service that will perform a real-time translation on the input given to it. See if this article is of any help for your problem

    https://ivywalobwa.medium.com/use-google-translation-api-in-your-angular-app-d55096bbbe67