How to translate a data from database using ng2-translate in angular?

401 Views Asked by At

need translate data from database using ng2-translate in angular without using JSON file or can we translate text using ng2-translate..

I tried by following code to translate text this.translate.get("SPANISH") .subscribe((data: string) => { this.value= data; });

Please guide me ..

1

There are 1 best solutions below

8
MaxXx1313 On

You should create a custom translation loader: https://www.npmjs.com/package/ng2-translate#write--use-your-own-loader

That also means all translations will be loaded at once. But if there is a lot of data to translate, it's better to use other approach to translate the data (for example - pass the desired language in the URL ?lang=en and return the data translated already).